max_stars_repo_path stringlengths 4 261 | max_stars_repo_name stringlengths 6 106 | max_stars_count int64 0 38.8k | id stringlengths 1 6 | text stringlengths 7 1.05M |
|---|---|---|---|---|
programs/oeis/253/A253946.asm | karttu/loda | 1 | 27535 | <reponame>karttu/loda<filename>programs/oeis/253/A253946.asm
; A253946: a(n) = 6*binomial(n+1, 6).
; 6,42,168,504,1260,2772,5544,10296,18018,30030,48048,74256,111384,162792,232560,325584,447678,605682,807576,1062600,1381380,1776060,2260440,2850120,3562650,4417686,5437152,6645408,8069424,9738960,11686752,13948704,16564086,19575738,23030280,26978328,31474716,36578724,42354312,48870360,56200914,64425438,73629072,83902896,95344200,108056760,122151120,137744880,154962990,173938050,194810616,217729512,242852148,270344844,300383160,333152232,368847114,407673126,449846208,495593280,545152608,598774176,656720064,719264832,786695910,859313994,937433448,1021382712,1111504716,1208157300,1311713640,1422562680,1541109570,1667776110,1803001200,1947241296,2100970872,2264682888,2438889264,2624121360,2820930462,3029888274,3251587416,3486641928,3735687780,3999383388,4278410136,4573472904,4885300602,5214646710,5562289824,5929034208,6315710352,6723175536,7152314400,7604039520,8079291990,8579042010,9104289480,9656064600,10235428476,10843473732,11481325128,12150140184,12851109810,13585458942,14354447184,15159369456,16001556648,16882376280,17803233168,18765570096,19770868494,20820649122,21916472760,23059940904,24252696468,25496424492,26792852856,28143753000,29550940650,31016276550,32541667200,34129065600,35780472000,37497934656,39283550592,41139466368,43067878854,45071036010,47151237672,49310836344,51552237996,53877902868,56290346280,58792139448,61385910306,64074344334,66860185392,69746236560,72735360984,75830482728,79034587632,82350724176,85782004350,89331604530,93002766360,96798797640,100723073220,104779035900,108970197336,113300138952,117772512858,122391042774,127159524960,132081829152,137161899504,142403755536,147811493088,153389285280,159141383478,165072118266,171185900424,177487221912,183980656860,190670862564,197562580488,204660637272,211969945746,219495505950,227242406160,235215823920,243421027080,251863374840,260548318800,269481404016,278668270062,288114652098,297826381944,307809389160,318069702132,328613449164,339446859576,350576264808,362008099530,373748902758,385805318976,398184099264,410892102432,423936296160,437323758144,451061677248,465157354662,479618205066,494451757800,509665658040,525267667980,541265668020,557667657960,574481758200,591716210946,609379381422,627479759088,646025958864,665026722360,684490919112,704427547824,724845737616,745754749278,767163976530,789082947288,811521324936,834488909604,857995639452,882051591960,906666985224,931852179258,957617677302,983974127136,1010932322400,1038503203920,1066697861040,1095527532960,1125003610080,1155137635350,1185941305626,1217426473032,1249605146328,1282489492284,1316091837060,1350424667592,1385500632984,1421332545906,1457933383998,1495316291280,1533494579568,1572481729896,1612291393944,1652937395472,1694433731760,1736794575054,1780034274018,1824167355192,1869208524456,1915172668500,1962074856300,2009930340600,2058754559400,2108563137450,2159371887750
add $0,6
bin $0,6
mov $1,$0
mul $1,6
|
PRG/maps/World4OI.asm | narfman0/smb3_pp1 | 0 | 165890 | .byte $00, $00, $07, $09, $08, $00, $00, $00, $00
|
models/aleks/ints5.als | transclosure/Amalgam | 4 | 497 | <reponame>transclosure/Amalgam
open util/integer
one sig S {
a : one Int,
b : one Int
}{
a >= 0 and b >=0
}
run {
add[S.a, S.b] = 2
} for 1
|
src/shared/generic/lsc-internal-io.ads | Componolit/libsparkcrypto | 30 | 17483 | <filename>src/shared/generic/lsc-internal-io.ads
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, <NAME>
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 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.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
use type LSC.Internal.Types.Index;
-------------------------------------------------------------------------------
-- Input/Output operations
-------------------------------------------------------------------------------
package LSC.Internal.IO is
pragma Pure;
-- Output string @T@
procedure Put (T : String)
with Depends => (null => T);
-- Output string @T@ followed by a line terminator
procedure Put_Line (T : String)
with Depends => (null => T);
-- Start a new line
procedure New_Line
with Depends => null;
-- Read one byte from input
function Read_Byte return Types.Byte;
-- True if End_Of_Stream is reached
function End_Of_Stream return Boolean;
-- Output byte @Item@
procedure Print_Byte (Item : in Types.Byte)
with Depends => (null => Item);
-- Output 32-bit word @Item@
procedure Print_Word32 (Item : in Types.Word32)
with Depends => (null => Item);
-- Output 64-bit word @Item@
procedure Print_Word64 (Item : in Types.Word64)
with Depends => (null => Item);
-- Output index @I@
procedure Print_Index (I : in Types.Index)
with Depends => (null => I);
-- Output natural number @I@
procedure Print_Natural (I : in Natural)
with Depends => (null => I);
-- Output @Block@, an array of 32-bit words
--
-- @Space@ - Number of spaces to separate Word32 values <br>
-- @Break@ - Insert a line terminator after @Break@ Word32 values <br>
-- @Newln@ - Insert a line terminator after printing all Word32 values <br>
--
procedure Print_Word32_Array (Block : in Types.Word32_Array_Type;
Space : in Natural;
Break : in Types.Index;
Newln : in Boolean)
with
Depends => (null => (Block, Space, Break, Newln)),
Pre =>
Break > 0;
-- Output @Block@, an array of 64-bit words
--
-- @Space@ - Number of spaces to separate Word64 values <br>
-- @Break@ - Insert a line terminator after @Break@ Word64 values <br>
-- @Newln@ - Insert a line terminator after printing all Word64 values <br>
--
procedure Print_Word64_Array (Block : in Types.Word64_Array_Type;
Space : in Natural;
Break : in Types.Index;
Newln : in Boolean)
with
Depends => (null => (Block, Space, Break, Newln)),
Pre =>
Break > 0;
end LSC.Internal.IO;
|
examples/stm32f0/i2c/peripherals.ads | ekoeppen/STM32_Generic_Ada_Drivers | 1 | 5770 | <gh_stars>1-10
with STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.I2C;
with STM32GD.I2C.Peripheral;
with Drivers.Si7006;
package Peripherals is
package GPIO renames STM32GD.GPIO;
package SCL is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_B,
Mode => GPIO.Mode_AF, Alternate_Function => 1);
package SCL_OUT is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_B,
Mode => GPIO.Mode_Out);
package SDA is new GPIO.Pin (Pin => GPIO.Pin_7, Port => GPIO.Port_B,
Mode => GPIO.Mode_AF, Alternate_Function => 1);
package I2C is new STM32GD.I2C.Peripheral (
I2C => STM32GD.I2C.I2C_1);
package Si7006 is new Drivers.Si7006 (I2C => I2C);
procedure Init;
end Peripherals;
|
chp04/src/main/antlr/Expr.g4 | zhhe-me/book-antlr4 | 1 | 283 | grammar Expr;
import CommonLexerRules ;
/**
supported input like below:
193
a = 5
b = 6
a
a+b*2
(1+2)*3
*/
/** The start rule; begin parsing here. */
prag: stat+ ;
stat: expr NEWLINE
| ID '=' expr NEWLINE
| NEWLINE
;
expr: expr ('*' | '/') expr
| expr ('+' | '-') expr
| INT
| ID
| '(' expr ')'
;
|
programs/oeis/053/A053585.asm | neoneye/loda | 22 | 240102 | ; A053585: If n = p_1^e_1 * ... * p_k^e_k, p_1 < ... < p_k primes, then a(n) = p_k^e_k.
; 1,2,3,4,5,3,7,8,9,5,11,3,13,7,5,16,17,9,19,5,7,11,23,3,25,13,27,7,29,5,31,32,11,17,7,9,37,19,13,5,41,7,43,11,5,23,47,3,49,25,17,13,53,27,11,7,19,29,59,5,61,31,7,64,13,11,67,17,23,7,71,9,73,37,25,19,11,13,79,5,81,41,83,7,17,43,29,11,89,5,13,23,31,47,19,3,97,49,11,25
mov $1,1
lpb $0
mov $1,$0
seq $1,28233 ; If n = p_1^e_1 * ... * p_k^e_k, p_1 < ... < p_k primes, then a(n) = p_1^e_1, with a(1) = 1.
div $0,$1
lpe
mov $0,$1
|
ada/core/agar-config.ads | auzkok/libagar | 286 | 2184 | <filename>ada/core/agar-config.ads<gh_stars>100-1000
------------------------------------------------------------------------------
-- AGAR CORE LIBRARY --
-- A G A R . C O N F I G --
-- S p e c --
-- --
-- Copyright (c) 2018-2020, <NAME> (<EMAIL>) --
-- Copyright (c) 2010, coreland (<EMAIL>) --
-- --
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Interfaces.C;
with Interfaces.C.Strings;
--
-- Interface to Agar "application preferences" object. For a list of the
-- built-in settings, see AG_Config(3), "CONFIGURATION PARAMETERS". Extra,
-- application-specific settings can be defined using Agar.Variable.
--
package Agar.Config is
function Load return Boolean;
-- Load previously saved configuration settings from the data directory.
function Save return Boolean;
-- Save configuration settings to the application data directory.
private
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
function AG_ConfigFind
(Name : in CS.chars_ptr;
Dest_Path : in CS.chars_ptr;
Dest_Len : in C.size_t) return C.int
with Import, Convention => C, Link_Name => "AG_ConfigFind";
function AG_ConfigLoad return C.int
with Import, Convention => C, Link_Name => "AG_ConfigLoad";
function AG_ConfigSave return C.int
with Import, Convention => C, Link_Name => "AG_ConfigSave";
end Agar.Config;
|
Tooling/GCodeParser/GCodeParser/SiemensGCodeParser.g4 | philmccarthy24/gemstone | 0 | 6009 | parser grammar SiemensGCodeParser;
options { tokenVocab=SiemensGCodeLexer; }
////////////////////////////////////////////////////////////////////////
// Start of Siemens parser definition. Make this quite loose at first,
// then tighten up as more rules become evident.
// Because Siemens is so freeform, it's sensible to do quite a lot of
// checking in the semantic analysis stage
comment: SEMICOLON COMMENT_TEXT;
program: block+;
block: N_WORD? (statement | expr)? comment? BLOCK_END;
statement: gcode_word+
| if
| goto
| label
| STOPRE
| message
| procdef
| declaration
;
// TODO: add lots more statements here
// GCode addresses: Some addresses take parameters in square brackets, eg POS[Axis]=...
// p2-9 and 11 - "Extended addresses" you can have notation like "X4=20" which refers to axis X4, as well as a variable identifier enclosed in square brackets.
addr_extension: integer | (SQUAREDBRACKET_OPEN expr SQUAREDBRACKET_CLOSE);
// Address '=' designation - see p2-13. '=' must appear between addr and param if param is expr.
// if param is a literal (and the addr is one letter), the '=' is optional.
gcode_word: ADDRESS addr_extension? EQUALS expr
| ADDRESS (real | integer); // semantic analysis: check ADDRESS is single letter
message: MSG PARENTHESIS_LEFT string PARENTHESIS_RIGHT;
goto: (GOTOB | GOTOF) IDENTIFIER; // !!! are DIGITS to go to an N number allowed also? I think they are.
if: IF PARENTHESIS_LEFT expr PARENTHESIS_RIGHT goto;
label: IDENTIFIER COLON;
procdef: PROC L_WORD;
declaration: DEF TYPE IDENTIFIER (SQUAREDBRACKET_OPEN expr SQUAREDBRACKET_CLOSE)?;
/* not implemented yet:
ELSE: 'ELSE';
ENDIF: 'ENDIF';
CASE: 'CASE';
OF: 'OF';
DEFAULT: 'DEFAULT';
DELETE: 'DELETE';
WRITE: 'WRITE';
FOR: 'FOR';
TO: 'TO';
ENDFOR: 'ENDFOR';
SAVE: 'SAVE';
ENDPROC: 'ENDPROC';
EXTERN: 'EXTERN';
GETT: 'GETT';
*/
expr: PARENTHESIS_LEFT expr PARENTHESIS_RIGHT
| (BUILTIN_FUNCTION | IDENTIFIER) PARENTHESIS_LEFT expr (COMMA expr)* PARENTHESIS_RIGHT
| expr (MULTIPLY|DIVIDE|DIVIDE_2|MODULUS) expr
| expr (PLUS|MINUS) expr
| expr EQUALS expr
| expr RELATIONAL_OP expr
| expr LOGICAL_OP expr
// | variable
| string
| integer
| real
| bool
| (PLUS|MINUS) expr
;
// type literal rules
string: QUOTE STRING_TEXT QUOTE (CONCAT_OP expr CONCAT_OP)?; // from eg on p2-20. Can you concat more than one var?
real: (PLUS|MINUS)? REAL_VAL;
integer: (PLUS|MINUS)? INTEGER_VAL;
bool: BOOL_VAL; |
support/MinGW/lib/gcc/mingw32/9.2.0/adainclude/a-cdlili.adb | orb-zhuchen/Orb | 0 | 7695 | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . D O U B L Y _ L I N K E D _ L I S T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by <NAME>. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with System; use type System.Address;
package body Ada.Containers.Doubly_Linked_Lists is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
procedure Free (X : in out Node_Access);
procedure Insert_Internal
(Container : in out List;
Before : Node_Access;
New_Node : Node_Access);
procedure Splice_Internal
(Target : in out List;
Before : Node_Access;
Source : in out List);
procedure Splice_Internal
(Target : in out List;
Before : Node_Access;
Source : in out List;
Position : Node_Access);
function Vet (Position : Cursor) return Boolean;
-- Checks invariants of the cursor and its designated container, as a
-- simple way of detecting dangling references (see operation Free for a
-- description of the detection mechanism), returning True if all checks
-- pass. Invocations of Vet are used here as the argument of pragma Assert,
-- so the checks are performed only when assertions are enabled.
---------
-- "=" --
---------
function "=" (Left, Right : List) return Boolean is
begin
if Left.Length /= Right.Length then
return False;
end if;
if Left.Length = 0 then
return True;
end if;
declare
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
L : Node_Access := Left.First;
R : Node_Access := Right.First;
begin
for J in 1 .. Left.Length loop
if L.Element /= R.Element then
return False;
end if;
L := L.Next;
R := R.Next;
end loop;
end;
return True;
end "=";
------------
-- Adjust --
------------
procedure Adjust (Container : in out List) is
Src : Node_Access := Container.First;
begin
-- If the counts are nonzero, execution is technically erroneous, but
-- it seems friendly to allow things like concurrent "=" on shared
-- constants.
Zero_Counts (Container.TC);
if Src = null then
pragma Assert (Container.Last = null);
pragma Assert (Container.Length = 0);
return;
end if;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
pragma Assert (Container.Length > 0);
Container.First := null;
Container.Last := null;
Container.Length := 0;
Zero_Counts (Container.TC);
Container.First := new Node_Type'(Src.Element, null, null);
Container.Last := Container.First;
Container.Length := 1;
Src := Src.Next;
while Src /= null loop
Container.Last.Next := new Node_Type'(Element => Src.Element,
Prev => Container.Last,
Next => null);
Container.Last := Container.Last.Next;
Container.Length := Container.Length + 1;
Src := Src.Next;
end loop;
end Adjust;
------------
-- Append --
------------
procedure Append
(Container : in out List;
New_Item : Element_Type;
Count : Count_Type := 1)
is
begin
Insert (Container, No_Element, New_Item, Count);
end Append;
------------
-- Assign --
------------
procedure Assign (Target : in out List; Source : List) is
Node : Node_Access;
begin
if Target'Address = Source'Address then
return;
end if;
Target.Clear;
Node := Source.First;
while Node /= null loop
Target.Append (Node.Element);
Node := Node.Next;
end loop;
end Assign;
-----------
-- Clear --
-----------
procedure Clear (Container : in out List) is
X : Node_Access;
begin
if Container.Length = 0 then
pragma Assert (Container.First = null);
pragma Assert (Container.Last = null);
pragma Assert (Container.TC = (Busy => 0, Lock => 0));
return;
end if;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
TC_Check (Container.TC);
while Container.Length > 1 loop
X := Container.First;
pragma Assert (X.Next.Prev = Container.First);
Container.First := X.Next;
Container.First.Prev := null;
Container.Length := Container.Length - 1;
Free (X);
end loop;
X := Container.First;
pragma Assert (X = Container.Last);
Container.First := null;
Container.Last := null;
Container.Length := 0;
pragma Warnings (Off);
Free (X);
pragma Warnings (On);
end Clear;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased List;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in Constant_Reference");
declare
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => Position.Node.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains
(Container : List;
Item : Element_Type) return Boolean
is
begin
return Find (Container, Item) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy (Source : List) return List is
begin
return Target : List do
Target.Assign (Source);
end return;
end Copy;
------------
-- Delete --
------------
procedure Delete
(Container : in out List;
Position : in out Cursor;
Count : Count_Type := 1)
is
X : Node_Access;
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in Delete");
if Position.Node = Container.First then
Delete_First (Container, Count);
Position := No_Element; -- Post-York behavior
return;
end if;
if Count = 0 then
Position := No_Element; -- Post-York behavior
return;
end if;
TC_Check (Container.TC);
for Index in 1 .. Count loop
X := Position.Node;
Container.Length := Container.Length - 1;
if X = Container.Last then
Position := No_Element;
Container.Last := X.Prev;
Container.Last.Next := null;
Free (X);
return;
end if;
Position.Node := X.Next;
X.Next.Prev := X.Prev;
X.Prev.Next := X.Next;
Free (X);
end loop;
-- The following comment is unacceptable, more detail needed ???
Position := No_Element; -- Post-York behavior
end Delete;
------------------
-- Delete_First --
------------------
procedure Delete_First
(Container : in out List;
Count : Count_Type := 1)
is
X : Node_Access;
begin
if Count >= Container.Length then
Clear (Container);
return;
end if;
if Count = 0 then
return;
end if;
TC_Check (Container.TC);
for J in 1 .. Count loop
X := Container.First;
pragma Assert (X.Next.Prev = Container.First);
Container.First := X.Next;
Container.First.Prev := null;
Container.Length := Container.Length - 1;
Free (X);
end loop;
end Delete_First;
-----------------
-- Delete_Last --
-----------------
procedure Delete_Last
(Container : in out List;
Count : Count_Type := 1)
is
X : Node_Access;
begin
if Count >= Container.Length then
Clear (Container);
return;
end if;
if Count = 0 then
return;
end if;
TC_Check (Container.TC);
for J in 1 .. Count loop
X := Container.Last;
pragma Assert (X.Prev.Next = Container.Last);
Container.Last := X.Prev;
Container.Last.Next := null;
Container.Length := Container.Length - 1;
Free (X);
end loop;
end Delete_Last;
-------------
-- Element --
-------------
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
pragma Assert (Vet (Position), "bad cursor in Element");
return Position.Node.Element;
end Element;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find
(Container : List;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
Node : Node_Access := Position.Node;
begin
if Node = null then
Node := Container.First;
else
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in Find");
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
while Node /= null loop
if Node.Element = Item then
return Cursor'(Container'Unrestricted_Access, Node);
end if;
Node := Node.Next;
end loop;
return No_Element;
end;
end Find;
-----------
-- First --
-----------
function First (Container : List) return Cursor is
begin
if Container.First = null then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Container.First);
end if;
end First;
function First (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the First (and Last) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (forward)
-- iteration starts from the (logical) beginning of the entire sequence
-- of items (corresponding to Container.First, for a forward iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (forward) partial iteration begins.
if Object.Node = null then
return Doubly_Linked_Lists.First (Object.Container.all);
else
return Cursor'(Object.Container, Object.Node);
end if;
end First;
-------------------
-- First_Element --
-------------------
function First_Element (Container : List) return Element_Type is
begin
if Checks and then Container.First = null then
raise Constraint_Error with "list is empty";
end if;
return Container.First.Element;
end First_Element;
----------
-- Free --
----------
procedure Free (X : in out Node_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
begin
-- While a node is in use, as an active link in a list, its Previous and
-- Next components must be null, or designate a different node; this is
-- a node invariant. Before actually deallocating the node, we set both
-- access value components of the node to point to the node itself, thus
-- falsifying the node invariant. Subprogram Vet inspects the value of
-- the node components when interrogating the node, in order to detect
-- whether the cursor's node access value is dangling.
-- Note that we have no guarantee that the storage for the node isn't
-- modified when it is deallocated, but there are other tests that Vet
-- does if node invariants appear to be satisifed. However, in practice
-- this simple test works well enough, detecting dangling references
-- immediately, without needing further interrogation.
X.Prev := X;
X.Next := X;
Deallocate (X);
end Free;
---------------------
-- Generic_Sorting --
---------------------
package body Generic_Sorting is
---------------
-- Is_Sorted --
---------------
function Is_Sorted (Container : List) return Boolean is
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock : With_Lock (Container.TC'Unrestricted_Access);
Node : Node_Access;
begin
Node := Container.First;
for Idx in 2 .. Container.Length loop
if Node.Next.Element < Node.Element then
return False;
end if;
Node := Node.Next;
end loop;
return True;
end Is_Sorted;
-----------
-- Merge --
-----------
procedure Merge
(Target : in out List;
Source : in out List)
is
begin
-- The semantics of Merge changed slightly per AI05-0021. It was
-- originally the case that if Target and Source denoted the same
-- container object, then the GNAT implementation of Merge did
-- nothing. However, it was argued that RM05 did not precisely
-- specify the semantics for this corner case. The decision of the
-- ARG was that if Target and Source denote the same non-empty
-- container object, then Program_Error is raised.
if Source.Is_Empty then
return;
end if;
if Checks and then Target'Address = Source'Address then
raise Program_Error with
"Target and Source denote same non-empty container";
end if;
if Checks and then Target.Length > Count_Type'Last - Source.Length
then
raise Constraint_Error with "new length exceeds maximum";
end if;
TC_Check (Target.TC);
TC_Check (Source.TC);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock_Target : With_Lock (Target.TC'Unchecked_Access);
Lock_Source : With_Lock (Source.TC'Unchecked_Access);
LI, RI, RJ : Node_Access;
begin
LI := Target.First;
RI := Source.First;
while RI /= null loop
pragma Assert (RI.Next = null
or else not (RI.Next.Element < RI.Element));
if LI = null then
Splice_Internal (Target, null, Source);
exit;
end if;
pragma Assert (LI.Next = null
or else not (LI.Next.Element < LI.Element));
if RI.Element < LI.Element then
RJ := RI;
RI := RI.Next;
Splice_Internal (Target, LI, Source, RJ);
else
LI := LI.Next;
end if;
end loop;
end;
end Merge;
----------
-- Sort --
----------
procedure Sort (Container : in out List) is
procedure Partition (Pivot : Node_Access; Back : Node_Access);
procedure Sort (Front, Back : Node_Access);
---------------
-- Partition --
---------------
procedure Partition (Pivot : Node_Access; Back : Node_Access) is
Node : Node_Access;
begin
Node := Pivot.Next;
while Node /= Back loop
if Node.Element < Pivot.Element then
declare
Prev : constant Node_Access := Node.Prev;
Next : constant Node_Access := Node.Next;
begin
Prev.Next := Next;
if Next = null then
Container.Last := Prev;
else
Next.Prev := Prev;
end if;
Node.Next := Pivot;
Node.Prev := Pivot.Prev;
Pivot.Prev := Node;
if Node.Prev = null then
Container.First := Node;
else
Node.Prev.Next := Node;
end if;
Node := Next;
end;
else
Node := Node.Next;
end if;
end loop;
end Partition;
----------
-- Sort --
----------
procedure Sort (Front, Back : Node_Access) is
Pivot : constant Node_Access :=
(if Front = null then Container.First else Front.Next);
begin
if Pivot /= Back then
Partition (Pivot, Back);
Sort (Front, Pivot);
Sort (Pivot, Back);
end if;
end Sort;
-- Start of processing for Sort
begin
if Container.Length <= 1 then
return;
end if;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
TC_Check (Container.TC);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unchecked_Access);
begin
Sort (Front => null, Back => null);
end;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
end Sort;
end Generic_Sorting;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Node.Element'Access;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
pragma Assert (Vet (Position), "bad cursor in Has_Element");
return Position.Node /= null;
end Has_Element;
------------
-- Insert --
------------
procedure Insert
(Container : in out List;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1)
is
First_Node : Node_Access;
New_Node : Node_Access;
begin
if Before.Container /= null then
if Checks and then Before.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Before cursor designates wrong list";
end if;
pragma Assert (Vet (Before), "bad cursor in Insert");
end if;
if Count = 0 then
Position := Before;
return;
end if;
if Checks and then Container.Length > Count_Type'Last - Count then
raise Constraint_Error with "new length exceeds maximum";
end if;
TC_Check (Container.TC);
New_Node := new Node_Type'(New_Item, null, null);
First_Node := New_Node;
Insert_Internal (Container, Before.Node, New_Node);
for J in 2 .. Count loop
New_Node := new Node_Type'(New_Item, null, null);
Insert_Internal (Container, Before.Node, New_Node);
end loop;
Position := Cursor'(Container'Unchecked_Access, First_Node);
end Insert;
procedure Insert
(Container : in out List;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1)
is
Position : Cursor;
pragma Unreferenced (Position);
begin
Insert (Container, Before, New_Item, Position, Count);
end Insert;
procedure Insert
(Container : in out List;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
First_Node : Node_Access;
New_Node : Node_Access;
begin
if Before.Container /= null then
if Checks and then Before.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Before cursor designates wrong list";
end if;
pragma Assert (Vet (Before), "bad cursor in Insert");
end if;
if Count = 0 then
Position := Before;
return;
end if;
if Checks and then Container.Length > Count_Type'Last - Count then
raise Constraint_Error with "new length exceeds maximum";
end if;
TC_Check (Container.TC);
New_Node := new Node_Type;
First_Node := New_Node;
Insert_Internal (Container, Before.Node, New_Node);
for J in 2 .. Count loop
New_Node := new Node_Type;
Insert_Internal (Container, Before.Node, New_Node);
end loop;
Position := Cursor'(Container'Unchecked_Access, First_Node);
end Insert;
---------------------
-- Insert_Internal --
---------------------
procedure Insert_Internal
(Container : in out List;
Before : Node_Access;
New_Node : Node_Access)
is
begin
if Container.Length = 0 then
pragma Assert (Before = null);
pragma Assert (Container.First = null);
pragma Assert (Container.Last = null);
Container.First := New_Node;
Container.Last := New_Node;
elsif Before = null then
pragma Assert (Container.Last.Next = null);
Container.Last.Next := New_Node;
New_Node.Prev := Container.Last;
Container.Last := New_Node;
elsif Before = Container.First then
pragma Assert (Container.First.Prev = null);
Container.First.Prev := New_Node;
New_Node.Next := Container.First;
Container.First := New_Node;
else
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
New_Node.Next := Before;
New_Node.Prev := Before.Prev;
Before.Prev.Next := New_Node;
Before.Prev := New_Node;
end if;
Container.Length := Container.Length + 1;
end Insert_Internal;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : List) return Boolean is
begin
return Container.Length = 0;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : List;
Process : not null access procedure (Position : Cursor))
is
Busy : With_Busy (Container.TC'Unrestricted_Access);
Node : Node_Access := Container.First;
begin
while Node /= null loop
Process (Cursor'(Container'Unrestricted_Access, Node));
Node := Node.Next;
end loop;
end Iterate;
function Iterate (Container : List)
return List_Iterator_Interfaces.Reversible_Iterator'Class
is
begin
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is null (as is the case here), this means the iterator
-- object was constructed without a start expression. This is a
-- complete iterator, meaning that the iteration starts from the
-- (logical) beginning of the sequence of items.
-- Note: For a forward iterator, Container.First is the beginning, and
-- for a reverse iterator, Container.Last is the beginning.
return It : constant Iterator :=
Iterator'(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => null)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
function Iterate (Container : List; Start : Cursor)
return List_Iterator_Interfaces.Reversible_Iterator'Class
is
begin
-- It was formerly the case that when Start = No_Element, the partial
-- iterator was defined to behave the same as for a complete iterator,
-- and iterate over the entire sequence of items. However, those
-- semantics were unintuitive and arguably error-prone (it is too easy
-- to accidentally create an endless loop), and so they were changed,
-- per the ARG meeting in Denver on 2011/11. However, there was no
-- consensus about what positive meaning this corner case should have,
-- and so it was decided to simply raise an exception. This does imply,
-- however, that it is not possible to use a partial iterator to specify
-- an empty sequence of items.
if Checks and then Start = No_Element then
raise Constraint_Error with
"Start position for iterator equals No_Element";
end if;
if Checks and then Start.Container /= Container'Unrestricted_Access then
raise Program_Error with
"Start cursor of Iterate designates wrong list";
end if;
pragma Assert (Vet (Start), "Start cursor of Iterate is bad");
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is non-null (as is the case here), it means that this is a
-- partial iteration, over a subset of the complete sequence of items.
-- The iterator object was constructed with a start expression,
-- indicating the position from which the iteration begins. Note that
-- the start position has the same value irrespective of whether this is
-- a forward or reverse iteration.
return It : constant Iterator :=
Iterator'(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => Start.Node)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
----------
-- Last --
----------
function Last (Container : List) return Cursor is
begin
if Container.Last = null then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Container.Last);
end if;
end Last;
function Last (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the Last (and First) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (reverse)
-- iteration starts from the (logical) beginning of the entire sequence
-- (corresponding to Container.Last, for a reverse iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (reverse) partial iteration begins.
if Object.Node = null then
return Doubly_Linked_Lists.Last (Object.Container.all);
else
return Cursor'(Object.Container, Object.Node);
end if;
end Last;
------------------
-- Last_Element --
------------------
function Last_Element (Container : List) return Element_Type is
begin
if Checks and then Container.Last = null then
raise Constraint_Error with "list is empty";
end if;
return Container.Last.Element;
end Last_Element;
------------
-- Length --
------------
function Length (Container : List) return Count_Type is
begin
return Container.Length;
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out List;
Source : in out List)
is
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Source.TC);
Clear (Target);
Target.First := Source.First;
Source.First := null;
Target.Last := Source.Last;
Source.Last := null;
Target.Length := Source.Length;
Source.Length := 0;
end Move;
----------
-- Next --
----------
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next (Position : Cursor) return Cursor is
begin
if Position.Node = null then
return No_Element;
else
pragma Assert (Vet (Position), "bad cursor in Next");
declare
Next_Node : constant Node_Access := Position.Node.Next;
begin
if Next_Node = null then
return No_Element;
else
return Cursor'(Position.Container, Next_Node);
end if;
end;
end if;
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong list";
end if;
return Next (Position);
end Next;
-------------
-- Prepend --
-------------
procedure Prepend
(Container : in out List;
New_Item : Element_Type;
Count : Count_Type := 1)
is
begin
Insert (Container, First (Container), New_Item, Count);
end Prepend;
--------------
-- Previous --
--------------
procedure Previous (Position : in out Cursor) is
begin
Position := Previous (Position);
end Previous;
function Previous (Position : Cursor) return Cursor is
begin
if Position.Node = null then
return No_Element;
else
pragma Assert (Vet (Position), "bad cursor in Previous");
declare
Prev_Node : constant Node_Access := Position.Node.Prev;
begin
if Prev_Node = null then
return No_Element;
else
return Cursor'(Position.Container, Prev_Node);
end if;
end;
end if;
end Previous;
function Previous
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Previous designates wrong list";
end if;
return Previous (Position);
end Previous;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased List'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Lock (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type))
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
pragma Assert (Vet (Position), "bad cursor in Query_Element");
declare
Lock : With_Lock (Position.Container.TC'Unrestricted_Access);
begin
Process (Position.Node.Element);
end;
end Query_Element;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out List)
is
N : Count_Type'Base;
X : Node_Access;
begin
Clear (Item);
Count_Type'Base'Read (Stream, N);
if N = 0 then
return;
end if;
X := new Node_Type;
begin
Element_Type'Read (Stream, X.Element);
exception
when others =>
Free (X);
raise;
end;
Item.First := X;
Item.Last := X;
loop
Item.Length := Item.Length + 1;
exit when Item.Length = N;
X := new Node_Type;
begin
Element_Type'Read (Stream, X.Element);
exception
when others =>
Free (X);
raise;
end;
X.Prev := Item.Last;
Item.Last.Next := X;
Item.Last := X;
end loop;
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream list cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out List;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unchecked_Access then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in function Reference");
declare
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => Position.Node.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out List;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unchecked_Access then
raise Program_Error with
"Position cursor designates wrong container";
end if;
TE_Check (Container.TC);
pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Position.Node.Element := New_Item;
end Replace_Element;
----------------------
-- Reverse_Elements --
----------------------
procedure Reverse_Elements (Container : in out List) is
I : Node_Access := Container.First;
J : Node_Access := Container.Last;
procedure Swap (L, R : Node_Access);
----------
-- Swap --
----------
procedure Swap (L, R : Node_Access) is
LN : constant Node_Access := L.Next;
LP : constant Node_Access := L.Prev;
RN : constant Node_Access := R.Next;
RP : constant Node_Access := R.Prev;
begin
if LP /= null then
LP.Next := R;
end if;
if RN /= null then
RN.Prev := L;
end if;
L.Next := RN;
R.Prev := LP;
if LN = R then
pragma Assert (RP = L);
L.Prev := R;
R.Next := L;
else
L.Prev := RP;
RP.Next := L;
R.Next := LN;
LN.Prev := R;
end if;
end Swap;
-- Start of processing for Reverse_Elements
begin
if Container.Length <= 1 then
return;
end if;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
TC_Check (Container.TC);
Container.First := J;
Container.Last := I;
loop
Swap (L => I, R => J);
J := J.Next;
exit when I = J;
I := I.Prev;
exit when I = J;
Swap (L => J, R => I);
I := I.Next;
exit when I = J;
J := J.Prev;
exit when I = J;
end loop;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
end Reverse_Elements;
------------------
-- Reverse_Find --
------------------
function Reverse_Find
(Container : List;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
Node : Node_Access := Position.Node;
begin
if Node = null then
Node := Container.Last;
else
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in Reverse_Find");
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
while Node /= null loop
if Node.Element = Item then
return Cursor'(Container'Unrestricted_Access, Node);
end if;
Node := Node.Prev;
end loop;
return No_Element;
end;
end Reverse_Find;
---------------------
-- Reverse_Iterate --
---------------------
procedure Reverse_Iterate
(Container : List;
Process : not null access procedure (Position : Cursor))
is
Busy : With_Busy (Container.TC'Unrestricted_Access);
Node : Node_Access := Container.Last;
begin
while Node /= null loop
Process (Cursor'(Container'Unrestricted_Access, Node));
Node := Node.Prev;
end loop;
end Reverse_Iterate;
------------
-- Splice --
------------
procedure Splice
(Target : in out List;
Before : Cursor;
Source : in out List)
is
begin
if Before.Container /= null then
if Checks and then Before.Container /= Target'Unrestricted_Access then
raise Program_Error with
"Before cursor designates wrong container";
end if;
pragma Assert (Vet (Before), "bad cursor in Splice");
end if;
if Target'Address = Source'Address or else Source.Length = 0 then
return;
end if;
if Checks and then Target.Length > Count_Type'Last - Source.Length then
raise Constraint_Error with "new length exceeds maximum";
end if;
TC_Check (Target.TC);
TC_Check (Source.TC);
Splice_Internal (Target, Before.Node, Source);
end Splice;
procedure Splice
(Container : in out List;
Before : Cursor;
Position : Cursor)
is
begin
if Before.Container /= null then
if Checks and then Before.Container /= Container'Unchecked_Access then
raise Program_Error with
"Before cursor designates wrong container";
end if;
pragma Assert (Vet (Before), "bad Before cursor in Splice");
end if;
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad Position cursor in Splice");
if Position.Node = Before.Node
or else Position.Node.Next = Before.Node
then
return;
end if;
pragma Assert (Container.Length >= 2);
TC_Check (Container.TC);
if Before.Node = null then
pragma Assert (Position.Node /= Container.Last);
if Position.Node = Container.First then
Container.First := Position.Node.Next;
Container.First.Prev := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
Container.Last.Next := Position.Node;
Position.Node.Prev := Container.Last;
Container.Last := Position.Node;
Container.Last.Next := null;
return;
end if;
if Before.Node = Container.First then
pragma Assert (Position.Node /= Container.First);
if Position.Node = Container.Last then
Container.Last := Position.Node.Prev;
Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
Container.First.Prev := Position.Node;
Position.Node.Next := Container.First;
Container.First := Position.Node;
Container.First.Prev := null;
return;
end if;
if Position.Node = Container.First then
Container.First := Position.Node.Next;
Container.First.Prev := null;
elsif Position.Node = Container.Last then
Container.Last := Position.Node.Prev;
Container.Last.Next := null;
else
Position.Node.Prev.Next := Position.Node.Next;
Position.Node.Next.Prev := Position.Node.Prev;
end if;
Before.Node.Prev.Next := Position.Node;
Position.Node.Prev := Before.Node.Prev;
Before.Node.Prev := Position.Node;
Position.Node.Next := Before.Node;
pragma Assert (Container.First.Prev = null);
pragma Assert (Container.Last.Next = null);
end Splice;
procedure Splice
(Target : in out List;
Before : Cursor;
Source : in out List;
Position : in out Cursor)
is
begin
if Target'Address = Source'Address then
Splice (Target, Before, Position);
return;
end if;
if Before.Container /= null then
if Checks and then Before.Container /= Target'Unrestricted_Access then
raise Program_Error with
"Before cursor designates wrong container";
end if;
pragma Assert (Vet (Before), "bad Before cursor in Splice");
end if;
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Source'Unrestricted_Access then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad Position cursor in Splice");
if Checks and then Target.Length = Count_Type'Last then
raise Constraint_Error with "Target is full";
end if;
TC_Check (Target.TC);
TC_Check (Source.TC);
Splice_Internal (Target, Before.Node, Source, Position.Node);
Position.Container := Target'Unchecked_Access;
end Splice;
---------------------
-- Splice_Internal --
---------------------
procedure Splice_Internal
(Target : in out List;
Before : Node_Access;
Source : in out List)
is
begin
-- This implements the corresponding Splice operation, after the
-- parameters have been vetted, and corner-cases disposed of.
pragma Assert (Target'Address /= Source'Address);
pragma Assert (Source.Length > 0);
pragma Assert (Source.First /= null);
pragma Assert (Source.First.Prev = null);
pragma Assert (Source.Last /= null);
pragma Assert (Source.Last.Next = null);
pragma Assert (Target.Length <= Count_Type'Last - Source.Length);
if Target.Length = 0 then
pragma Assert (Target.First = null);
pragma Assert (Target.Last = null);
pragma Assert (Before = null);
Target.First := Source.First;
Target.Last := Source.Last;
elsif Before = null then
pragma Assert (Target.Last.Next = null);
Target.Last.Next := Source.First;
Source.First.Prev := Target.Last;
Target.Last := Source.Last;
elsif Before = Target.First then
pragma Assert (Target.First.Prev = null);
Source.Last.Next := Target.First;
Target.First.Prev := Source.Last;
Target.First := Source.First;
else
pragma Assert (Target.Length >= 2);
Before.Prev.Next := Source.First;
Source.First.Prev := Before.Prev;
Before.Prev := Source.Last;
Source.Last.Next := Before;
end if;
Source.First := null;
Source.Last := null;
Target.Length := Target.Length + Source.Length;
Source.Length := 0;
end Splice_Internal;
procedure Splice_Internal
(Target : in out List;
Before : Node_Access; -- node of Target
Source : in out List;
Position : Node_Access) -- node of Source
is
begin
-- This implements the corresponding Splice operation, after the
-- parameters have been vetted.
pragma Assert (Target'Address /= Source'Address);
pragma Assert (Target.Length < Count_Type'Last);
pragma Assert (Source.Length > 0);
pragma Assert (Source.First /= null);
pragma Assert (Source.First.Prev = null);
pragma Assert (Source.Last /= null);
pragma Assert (Source.Last.Next = null);
pragma Assert (Position /= null);
if Position = Source.First then
Source.First := Position.Next;
if Position = Source.Last then
pragma Assert (Source.First = null);
pragma Assert (Source.Length = 1);
Source.Last := null;
else
Source.First.Prev := null;
end if;
elsif Position = Source.Last then
pragma Assert (Source.Length >= 2);
Source.Last := Position.Prev;
Source.Last.Next := null;
else
pragma Assert (Source.Length >= 3);
Position.Prev.Next := Position.Next;
Position.Next.Prev := Position.Prev;
end if;
if Target.Length = 0 then
pragma Assert (Target.First = null);
pragma Assert (Target.Last = null);
pragma Assert (Before = null);
Target.First := Position;
Target.Last := Position;
Target.First.Prev := null;
Target.Last.Next := null;
elsif Before = null then
pragma Assert (Target.Last.Next = null);
Target.Last.Next := Position;
Position.Prev := Target.Last;
Target.Last := Position;
Target.Last.Next := null;
elsif Before = Target.First then
pragma Assert (Target.First.Prev = null);
Target.First.Prev := Position;
Position.Next := Target.First;
Target.First := Position;
Target.First.Prev := null;
else
pragma Assert (Target.Length >= 2);
Before.Prev.Next := Position;
Position.Prev := Before.Prev;
Before.Prev := Position;
Position.Next := Before;
end if;
Target.Length := Target.Length + 1;
Source.Length := Source.Length - 1;
end Splice_Internal;
----------
-- Swap --
----------
procedure Swap
(Container : in out List;
I, J : Cursor)
is
begin
if Checks and then I.Node = null then
raise Constraint_Error with "I cursor has no element";
end if;
if Checks and then J.Node = null then
raise Constraint_Error with "J cursor has no element";
end if;
if Checks and then I.Container /= Container'Unchecked_Access then
raise Program_Error with "I cursor designates wrong container";
end if;
if Checks and then J.Container /= Container'Unchecked_Access then
raise Program_Error with "J cursor designates wrong container";
end if;
if I.Node = J.Node then
return;
end if;
TE_Check (Container.TC);
pragma Assert (Vet (I), "bad I cursor in Swap");
pragma Assert (Vet (J), "bad J cursor in Swap");
declare
EI : Element_Type renames I.Node.Element;
EJ : Element_Type renames J.Node.Element;
EI_Copy : constant Element_Type := EI;
begin
EI := EJ;
EJ := EI_Copy;
end;
end Swap;
----------------
-- Swap_Links --
----------------
procedure Swap_Links
(Container : in out List;
I, J : Cursor)
is
begin
if Checks and then I.Node = null then
raise Constraint_Error with "I cursor has no element";
end if;
if Checks and then J.Node = null then
raise Constraint_Error with "J cursor has no element";
end if;
if Checks and then I.Container /= Container'Unrestricted_Access then
raise Program_Error with "I cursor designates wrong container";
end if;
if Checks and then J.Container /= Container'Unrestricted_Access then
raise Program_Error with "J cursor designates wrong container";
end if;
if I.Node = J.Node then
return;
end if;
TC_Check (Container.TC);
pragma Assert (Vet (I), "bad I cursor in Swap_Links");
pragma Assert (Vet (J), "bad J cursor in Swap_Links");
declare
I_Next : constant Cursor := Next (I);
begin
if I_Next = J then
Splice (Container, Before => I, Position => J);
else
declare
J_Next : constant Cursor := Next (J);
begin
if J_Next = I then
Splice (Container, Before => J, Position => I);
else
pragma Assert (Container.Length >= 3);
Splice (Container, Before => I_Next, Position => J);
Splice (Container, Before => J_Next, Position => I);
end if;
end;
end if;
end;
end Swap_Links;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out List;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type))
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unchecked_Access then
raise Program_Error with
"Position cursor designates wrong container";
end if;
pragma Assert (Vet (Position), "bad cursor in Update_Element");
declare
Lock : With_Lock (Container.TC'Unchecked_Access);
begin
Process (Position.Node.Element);
end;
end Update_Element;
---------
-- Vet --
---------
function Vet (Position : Cursor) return Boolean is
begin
if Position.Node = null then
return Position.Container = null;
end if;
if Position.Container = null then
return False;
end if;
-- An invariant of a node is that its Previous and Next components can
-- be null, or designate a different node. Operation Free sets the
-- access value components of the node to designate the node itself
-- before actually deallocating the node, thus deliberately violating
-- the node invariant. This gives us a simple way to detect a dangling
-- reference to a node.
if Position.Node.Next = Position.Node then
return False;
end if;
if Position.Node.Prev = Position.Node then
return False;
end if;
-- In practice the tests above will detect most instances of a dangling
-- reference. If we get here, it means that the invariants of the
-- designated node are satisfied (they at least appear to be satisfied),
-- so we perform some more tests, to determine whether invariants of the
-- designated list are satisfied too.
declare
L : List renames Position.Container.all;
begin
if L.Length = 0 then
return False;
end if;
if L.First = null then
return False;
end if;
if L.Last = null then
return False;
end if;
if L.First.Prev /= null then
return False;
end if;
if L.Last.Next /= null then
return False;
end if;
if Position.Node.Prev = null and then Position.Node /= L.First then
return False;
end if;
pragma Assert
(Position.Node.Prev /= null or else Position.Node = L.First);
if Position.Node.Next = null and then Position.Node /= L.Last then
return False;
end if;
pragma Assert
(Position.Node.Next /= null
or else Position.Node = L.Last);
if L.Length = 1 then
return L.First = L.Last;
end if;
if L.First = L.Last then
return False;
end if;
if L.First.Next = null then
return False;
end if;
if L.Last.Prev = null then
return False;
end if;
if L.First.Next.Prev /= L.First then
return False;
end if;
if L.Last.Prev.Next /= L.Last then
return False;
end if;
if L.Length = 2 then
if L.First.Next /= L.Last then
return False;
elsif L.Last.Prev /= L.First then
return False;
else
return True;
end if;
end if;
if L.First.Next = L.Last then
return False;
end if;
if L.Last.Prev = L.First then
return False;
end if;
-- Eliminate earlier possibility
if Position.Node = L.First then
return True;
end if;
pragma Assert (Position.Node.Prev /= null);
-- Eliminate earlier possibility
if Position.Node = L.Last then
return True;
end if;
pragma Assert (Position.Node.Next /= null);
if Position.Node.Next.Prev /= Position.Node then
return False;
end if;
if Position.Node.Prev.Next /= Position.Node then
return False;
end if;
if L.Length = 3 then
if L.First.Next /= Position.Node then
return False;
elsif L.Last.Prev /= Position.Node then
return False;
end if;
end if;
return True;
end;
end Vet;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : List)
is
Node : Node_Access;
begin
Count_Type'Base'Write (Stream, Item.Length);
Node := Item.First;
while Node /= null loop
Element_Type'Write (Stream, Node.Element);
Node := Node.Next;
end loop;
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream list cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Doubly_Linked_Lists;
|
macros.asm | Potolski/OAC_2018_2_LAB_1 | 1 | 179808 | .macro print_int (%x)
li $v0, 1
add $a0, $zero, %x
syscall
.end_macro
.macro loadImage(%buffer, %image_pointer, %buffersize)
move $t6, %buffer
addi $t6, $t6, 54 # header offset
move $t8,%image_pointer
addi $t0, %buffersize, -54
add $t0, $t0, $t6 # t0 = buffer's end
loop:
sub $t4, $t0, $t6
beqz $t4, return
lbu $t1, ($t0) # load B byte from buffer
addi $t0, $t0, -1
lbu $t2, ($t0) # load G byte from buffer
addi $t0, $t0, -1
lbu $t3, ($t0) # load R byte from buffer
addi $t0, $t0, -1
sll $t3,$t3,8
sll $t2,$t2,16
or $t5,$t2,$t3
or $t5,$t5,$t1
sw $t5, ($t8)
addi $t8, $t8,4
b loop #teste
return:
move $t1,%image_pointer
addi $t8,$zero,512
Mirror:
add $t3,$t1,2048
addi $t9,$zero,256
internalLoop:
lw $t6,0($t1)
lw $t7,0($t3)
add $t4,$t6,$zero
add $t6,$t7,$zero
add $t7,$t4,$zero
sw $t6, 0($t1)
sw $t7 ,0($t3)
addi $t1, $t1,4
addi $t3,$t3,-4
addi $t9,$t9,-1
bne $t9,0,internalLoop
add $t1,$t1,1024
addi $t8,$t8,-1
bne $t8,0,Mirror
.end_macro
.macro showBlackWhite (%image_pointer, %size,%intensity)
li $t0,10
addi $t4,%intensity,2
move $t3, %size
add $t3,%image_pointer,$t3 #End
move $t2,%image_pointer #Beginning
addi $t7,$zero,0x007f7f7f #Threshold
mulu $t7,$t7,$t4
divu $t7,$t7,$t0 #Intensity
addi $t9,$zero,3
loop2:
lbu $t0, 0($t2) #
lbu $t5,1($t2) #
lbu $t6,2($t2) #
add $t0,$t0,$t5 # GRAYSCALE
add $t0,$t0,$t6 #
divu $t0,$t0,$t9 #
sb $t0, 0($t2) #
sb $t0, 1($t2) #
sb $t0, 2($t2) #
#### Binary Threshold ####
lw $t4, ($t2)
slt $t5,$t4,$t7 #Compare to Threshold
beq $t5,1,Black
White: addi $t4,$zero,0xffffffff
j continue
Black:
addi $t4,$zero,0
continue:
sw $t4, ($t2)
addi $t2,$t2,4
ble $t2, $t3, loop2
.end_macro
.macro Blur3 (%image_pointer, %size)
move $t0, %image_pointer
addi $t0,$t0,2052 # Blur's Beggining
li $t2,3 #Kernel size
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
li $t1,0
li $t8, 516 #Number of lines
li $t9,510 #Nunber of columns
move $t7,$t0
li $t3,3
j loopKernel1
loopBlur:
li $t9,510 #N�mero de colunas. Valor � 512 - 8 para 3x3 512 - 16 para 5x5 e - 24 para 7x7
addi $t0,$t0,8
addi $t8,$t8,-1
beqz $t8,exit
j loopKernel1
loop:
li $t3,3 #Kernel size
divu $t4,$t4,$t3
divu $t4,$t4,$t3
divu $t5,$t5,$t3
divu $t5,$t5,$t3
divu $t6,$t6,$t3
divu $t6,$t6,$t3
sll $t5,$t5,8
sll $t6,$t6,16
or $t4,$t4,$t5
or $t4,$t4,$t6
sw $t4,0($t0)
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
addi $t0,$t0,4
addi $t7,$t0,-2052 #Pixel 0x0 of 3x3 Matrix
addi $t9,$t9,-1
bne $t9,0 loopKernel1
j loopBlur
loopKernel1:
li $t2,3 #Kernel size
loopKernel2:
lbu $t1,0($t7)
addu $t4,$t4,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t5,$t5,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t6,$t6,$t1
addi $t7,$t7,2 #Jump byte zero
addi $t2,$t2,-1
bgtz $t2 loopKernel2
addi $t3,$t3,-1
beqz $t3, loop
addi $t7,$t7,2040 #jump for next line
j loopKernel1
exit:
.end_macro
.macro Blur5 (%image_pointer, %size)
move $t0, %image_pointer
addi $t0,$t0,4104 # Blur's Beggining
li $t2,5 #Kernel size
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
li $t1,0
li $t8, 508 #Number of lines
li $t9,508 #Nunber of columns
move $t7,$t0
li $t3,5
j loopKernel1
loopBlur:
li $t9,508 #Nunber of columns
addi $t0,$t0,16
addi $t8,$t8,-1
beqz $t8,exit
j loopKernel1
loop:
li $t3,5 #Kernel size
divu $t4,$t4,$t3
divu $t4,$t4,$t3
divu $t5,$t5,$t3
divu $t5,$t5,$t3
divu $t6,$t6,$t3
divu $t6,$t6,$t3
sll $t5,$t5,8
sll $t6,$t6,16
or $t4,$t4,$t5
or $t4,$t4,$t6
sw $t4,0($t0)
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
addi $t0,$t0,4
addi $t7,$t0,-4104 #Pixel 0x0 of 5x5 Matrix
addi $t9,$t9,-1
bgtz $t9 loopKernel1
j loopBlur
loopKernel1:
li $t2,5 #Kernel size
loopKernel2:
lbu $t1,0($t7)
addu $t4,$t4,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t5,$t5,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t6,$t6,$t1
addi $t7,$t7,2 #Jump byte zero
addi $t2,$t2,-1
bgtz $t2 loopKernel2
addi $t3,$t3,-1
beqz $t3, loop
addi $t7,$t7,2032 #jump for next line
j loopKernel1
exit:
.end_macro
.macro Blur7 (%image_pointer, %size)
move $t0, %image_pointer
addi $t0,$t0,6156 # Blur's Beggining
li $t2,7 #Kernel size
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
li $t1,0
li $t8, 506 #Number of lines
li $t9,506 #Nunber of columns
move $t7,$t0
li $t3,7
j loopKernel1
loopBlur:
li $t9,506
addi $t0,$t0,24
addi $t8,$t8,-1
beqz $t8,exit
j loopKernel1
loop:
li $t3,7 #Kernel size
divu $t4,$t4,$t3
divu $t4,$t4,$t3
divu $t5,$t5,$t3
divu $t5,$t5,$t3
divu $t6,$t6,$t3
divu $t6,$t6,$t3
sll $t5,$t5,8
sll $t6,$t6,16
or $t4,$t4,$t5
or $t4,$t4,$t6
sw $t4,0($t0)
li $t4, 0 # R
li $t5, 0 # G
li $t6, 0 # B
addi $t0,$t0,4
addi $t7,$t0,-6156 #Pixel 0x0 of 7x7 Matrix
addi $t9,$t9,-1
bgtz $t9 loopKernel1
j loopBlur
loopKernel1:
li $t2,7 #Kernel size
loopKernel2:
lbu $t1,0($t7)
addu $t4,$t4,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t5,$t5,$t1
addi $t7,$t7,1
lbu $t1,0($t7)
addu $t6,$t6,$t1
addi $t7,$t7,2 #Jump byte zero
addi $t2,$t2,-1
bgtz $t2 loopKernel2
addi $t3,$t3,-1
beqz $t3, loop
addi $t7,$t7,2024 #jump for next line
j loopKernel1
exit:
.end_macro
.macro showImage (%image_pointer, %size)
move $t3, %size
sll $t3,$t3,2
move $t1, %image_pointer #começo
add $t3,%image_pointer,$t3 #fim
move $t2,%image_pointer
loop: #vira de cabeça pra cima
lw $t6,0($t1)
lw $t7,0($t3)
add $t4,$t6,$zero
add $t6,$t7,$zero
add $t7,$t4,$zero
sw $t6, 0($t1)
sw $t7 ,0($t3)
addi $t1, $t1,4
addi $t3,$t3,-4
bne $t3,$t1,loop
move $t1,%image_pointer
addi $t8,$zero,512 #número de linhas que o loop deverá passar
loopespelho:#loop das linas
add $t3,$t1,2048
addi $t9,$zero,256 #número de repetições da troca de colunas
loopinterno:#loop das colunas
lw $t6,0($t1)
lw $t7,0($t3)
add $t4,$t6,$zero
add $t6,$t7,$zero
add $t7,$t4,$zero
sw $t6, 0($t1)
sw $t7 ,0($t3)
addi $t1, $t1,4
addi $t3,$t3,-4
addi $t9,$t9,-1
bne $t9,0,loopinterno
add $t1,$t1,1024
addi $t8,$t8,-1
bne $t8,0,loopespelho
move $t3,%size
sll $t3,$t3,2
add $t3,%image_pointer,$t3
loop2:#loop de impressão
lw $t4, ($t2) # move from space to register
sw $t4, ($gp)
addi $gp, $gp, 4
addi $t2,$t2,4
#bne $t2,%image_pointer,loop
bne $t2, $t3, loop2
.end_macro
.macro showBlackWhite (%image_pointer, %size)
move $t3, %size
sll $t3,$t3,2
move $t1, %image_pointer #começo
add $t3,%image_pointer,$t3 #fim
move $t2,%image_pointer
loop:
lw $t6,0($t1)
lw $t7,0($t3)
add $t4,$t6,$zero
add $t6,$t7,$zero
add $t7,$t4,$zero
sw $t6, 0($t1)
sw $t7 ,0($t3)
addi $t1, $t1,4
addi $t3,$t3,-4
bne $t3,$t1,loop
move $t1,%image_pointer
addi $t8,$zero,512
loopespelho:
add $t3,$t1,2048
addi $t9,$zero,256
loopinterno:
lw $t6,0($t1)
lw $t7,0($t3)
add $t4,$t6,$zero
add $t6,$t7,$zero
add $t7,$t4,$zero
sw $t6, 0($t1)
sw $t7 ,0($t3)
addi $t1, $t1,4
addi $t3,$t3,-4
addi $t9,$t9,-1
bne $t9,0,loopinterno
add $t1,$t1,1024
addi $t8,$t8,-1
bne $t8,0,loopespelho
move $t3,%size
sll $t3,$t3,2
add $t3,%image_pointer,$t3
addi $t7,$zero,0x007f7f7f #Filtro de cor
loop2:
lw $t4, ($t2) # move from space to register
slt $t5,$t4,$t7 #compara a cor de t4 com o tom médio de cinza
beq $t5,1,preto
branco: addi $t4,$zero,0xffffffff
j continua
preto:
addi $t4,$zero,0
continua:
sw $t4, ($gp)
addi $gp, $gp, 4
addi $t2,$t2,4
#bne $t2,%image_pointer,loop
bne $t2, $t3, loop2
.end_macro
|
dv3/qlf/ld5b.asm | olifink/smsqe | 0 | 15762 | <reponame>olifink/smsqe
; DV3 QL5B Format Load File V3.00 1994 <NAME> QJUMP
section dv3
xdef qlf_ld5b
xref qlf_ls5b
xref dv3_sload
xref dv3_sbloc
include 'dev8_keys_ql5b'
include 'dev8_dv3_keys'
include 'dev8_dv3_qlf_keys'
include 'dev8_keys_hdr'
include 'dev8_keys_err'
;+++
; DV3 QL5B format load file.
; It checks whether the first sector of a file is in slave blocks, and if
; it is, it does ordinary IO.
;
; d1 cr amount read so far
; d2 c p amount to load
; d3 s
; d4 s
; d5 s
; d6 c p file id
; d7 c p drive ID / number
; a0 c p channel block (end address of load)
; a1 c u pointer to memory to load into
; a2 s start address of load
; a3 c p pointer to linkage block
; a4 c p pointer to physical definition
; a5 p
;---
qlf_ld5b
tst.l d1 ; any loaded already?
bne.l dv3_sload ; ... yes, standard load
;*** d1 must be zero for code below
move.l d3c_feof(a0),d3 ; get length
moveq #hdr.len,d0
sub.l d0,d3 ; real length!!
cmp.l #1024,d3 ; at least 1024 bytes?
blt.l dv3_sload ; ... no
tst.b ddf_slld(a4) ; slaved loading preferred?
beq.s ql5_load ; ... no, direct load
moveq #0,d5 ; first sector
lea d3c_csb(a0),a2
jsr dv3_sbloc ; locate slave block
seq ddf_slld(a4) ; slaved loading preferred
beq.l dv3_sload ; do standard load
ql5_load
ql5.rege reg d3/d6/a0/a5 ; length on entry
ql5.regx reg d1/d6/a0/a5 ; is d1 on exit
movem.l ql5.rege,-(sp)
ql5_flush
moveq #-1,d0
jsr ddl_fflush(a3)
addq.l #-err.nc,d0 ; not complete?
beq.s ql5_flush ; ... yes, wait
subq.l #-err.nc,d0
bne.l ql5_exit ; ... oops
subq.w #1,d6 ; file ID is one different in map
move.l a1,a2 ; start address of load
lea (a1,d3.l),a0 ; end address of load
lea qdf_map(a4),a5 ; map
moveq #0,d5
move.w ddf_slen(a4),d5 ; sector length
moveq #0,d3 ; start looking at track 0
ql5_tr_loop
moveq #0,d4 ; side 0
ql5_si_loop
clr.w d4 ; start at physical sector 0 (offset)
ql5_se_loop
move.l d4,d0
bpl.s ql5_ps_set ; side 0
tas d0 ; side 1
ql5_ps_set
moveq #0,d1 ; find logical sector
move.w q5a_scyl(a5),d1
subq.w #1,d1
ql5_ps_look
cmp.b q5a_lgph(a5,d1.w),d0 ; the right sector?
dbeq d1,ql5_ps_look
move.w d3,d0 ; track
mulu q5a_scyl(a5),d0 ; * nr of sectors (msw end d0=0)
add.w d1,d0 ; logical sector on drive
move.l d0,d2
divu q5a_allc(a5),d2 ; posn in map (msw is posn in group)
move.w d2,d1
add.w d2,d2
add.w d1,d2 ; address in map
lea q5a_gmap(a5,d2.w),a1
move.b (a1)+,d1 ; get 12 bits of map
lsl.w #8,d1
move.b (a1)+,d1
ror.l #4,d1
cmp.w d6,d1 ; is the file the same?
bne.s ql5_se_next ; ... no
swap d1 ; ... yes
lsr.w #4,d1
move.b (a1)+,d1 ; get group number
mulu q5a_allc(a5),d1 ; as sector number
swap d2
add.w d2,d1 ; + sector within group
mulu d5,d1 ; gives address from base of load
bne.s ql5_sa1 ; not the first sector
lea (a2),a1 ; load into start
moveq #hdr.len,d1 ; offset of start in sector
bra.s ql5_ckend
ql5_sa1
lea -hdr.len(a2,d1.l),a1 ; set start address (less header)
moveq #0,d1 ; and no offset
ql5_ckend
cmp.l a0,a1 ; is start of sector off end of file?
bge.s ql5_se_next ; ... yes
move.l a0,d2 ; end of file
sub.l a1,d2 ; amount to read
add.l d1,d2 ; corrected
cmp.l d5,d2 ; at least a sector?
blt.s ql5_buff ; ... no, buffer it
move.l d5,d2
tst.w d1 ; part sector?
beq.s ql5_rdo ; ... no
ql5_buff
move.l a1,a5
move.l ddl_bfbas(a3),a1 ; ... yes, use buffer
bsr.s ql5_rsect ; read sector
bne.s ql5_exit ; ... oops
add.w d1,a1 ; start copying from here
sub.w d1,d2
bra.s ql5_plend
ql5_ploop
move.b (a1)+,(a5)+
ql5_plend
dbra d2,ql5_ploop
lea qdf_map(a4),a5 ; restore map
bra.s ql5_se_next
ql5_rsect
jsr qlf_ls5b ; get physical sector number
move.l d2,-(sp)
moveq #1,d2
jsr ddl_rsect(a3) ; read sector
move.l (sp)+,d2
tst.l d0
rts
ql5_rdo
bsr.s ql5_rsect ; read sector
bne.s ql5_exit ; ... oops
ql5_se_next
addq.w #1,d4 ; next physical sector
cmp.w q5a_strk(a5),d4 ; off end?
blt.l ql5_se_loop ; ... no
bset #31,d4 ; side 1
bne.s ql5_tr_next ; ... already
cmp.w q5a_scyl(a5),d4 ; is it single sided?
bne.l ql5_si_loop ; ... no
ql5_tr_next
addq.l #1,d3 ; next track (cylinder)
cmp.w q5a_trak(a5),d3 ; off end?
blt.l ql5_tr_loop ; ... no
move.l a0,a1 ; end pointer
moveq #0,d0
ql5_exit
movem.l (sp)+,ql5.regx
rts
end
|
programs/oeis/001/A001604.asm | neoneye/loda | 22 | 88117 | ; A001604: Odd-indexed terms of A124297.
; 11,31,151,911,5951,40051,272611,1863551,12760031,87424711,599129311,4106261531,28144128251,192901135711,1322159893351,9062207833151,62113268013311,425730597768451,2918000731816531,20000274041790911,137083916295800111,939587136717207031,6440026032054760351,44140595064968052011,302544139363297302251,2073668380322538222751,14213134522487170035511,97418273276021326202351,667714778406870436132031,4576585175564763020798611,31368381450527336268937411,215002084978076496246124031,1473646213395876988047533951,10100521408792719066483062311,69230003648152257565929645151,474509504128270730514415233851,3252336525249736694804553589211,22291846172619870002806798902751,152790586683089311095141479169031,1047242260609005197104389537585311,7177905237579946779188904790403711,49198094402450621499436696532362531,337208755579574401732970909041024051
seq $0,122367 ; Dimension of 3-variable non-commutative harmonics (twisted derivative). The dimension of the space of non-commutative polynomials in 3 variables which are killed by all symmetric differential operators (where for a monomial w, d_{xi} ( xi w ) = w and d_{xi} ( xj w ) = 0 for i != j).
add $0,1
bin $0,2
div $0,2
mul $0,20
add $0,11
|
tests/syntax_examples/src/main.adb | TNO/Dependency_Graph_Extractor-Ada | 1 | 971 | <reponame>TNO/Dependency_Graph_Extractor-Ada
with Ada.Containers.Vectors;
with Ada.Exceptions;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with Rejuvenation.Factory;
with Rejuvenation.Finder;
with Rejuvenation.Navigation;
with Libadalang.Analysis;
with Libadalang.Common;
with Langkit_Support.Slocs;
with Langkit_Support.Text;
with Basic_Declaration;
with Basic_Subprogram_Calls;
with Generic_Subprogram_Calls;
with Task_Subprogram_Calls;
with Aspect_Subprogram_Calls;
with Tagged_Subprogram_Calls;
with Operator_Subprogram_Calls;
with Test_Call_Filtering;
with Test_Operator_Attribute;
with Package_Without_Body;
with Subprogram_Unit;
with Subprogram_Unit_2;
with Deferred_Constant;
with Forward_Declaration;
procedure Main is
package LAL renames Libadalang.Analysis;
package LALCO renames Libadalang.Common;
Context : Rejuvenation.Factory.Project_Context := Rejuvenation.Factory.Open_Project("syntax_examples.gpr");
Units : Rejuvenation.Factory.Analysis_Unit_Vectors.Vector := Rejuvenation.Factory.Open_Files_From_Project(Context, False);
function Get_Filename(Node : LAL.Ada_Node'Class) return String is
use Ada.Strings;
use Ada.Strings.Fixed;
Unit_Filename : constant String := Node.Unit.Get_Filename;
Filename_Start : constant Natural := Index(Unit_Filename, "\", Backward);
begin
return Delete(Unit_Filename, Unit_Filename'First, Filename_Start);
end Get_Filename;
function Get_Location(Node : LAL.Ada_Node'Class) return String is
Filename : constant String := Get_Filename(Node);
Sloc_Range : constant String := Langkit_Support.Slocs.Image(Node.Sloc_Range);
begin
return Filename & "[" & Sloc_Range & "]";
end Get_Location;
function Find_Node_Of_Kind(Node : LAL.Ada_Node'Class; Node_Kind : LALCO.Ada_Node_Kind_Type) return Boolean is
Filename : constant String := Get_Filename(Node);
Found : Boolean := False;
begin
for Node_Of_Kind of Rejuvenation.Finder.Find(Node, Node_Kind) loop
Found := True;
Ada.Text_IO.New_Line;
Node_Of_Kind.Print(Line_Prefix => Filename & ": ");
Ada.Text_IO.New_Line;
end loop;
return Found;
end Find_Node_Of_Kind;
procedure Find_Basic_Decls is
use type LALCO.Ada_Basic_Decl;
package Ada_Basic_Decl_Vectors is new Ada.Containers.Vectors(Positive, LALCO.Ada_Basic_Decl);
use Ada_Basic_Decl_Vectors;
Unit_Specification, Unit_Body : LAL.Analysis_Unit;
Missing_Basic_Decls : Vector;
begin
Unit_Specification := Rejuvenation.Factory.Open_File("src/basic_declaration.ads", Context);
Unit_Body := Rejuvenation.Factory.Open_File("src/basic_declaration.adb", Context);
for Node_Kind in LALCO.Ada_Basic_Decl loop
if Node_Kind not in LALCO.Synthetic_Nodes then
Ada.Text_IO.Put_Line("=== " & Node_Kind'Image & " ===");
if not Find_Node_Of_Kind(Unit_Specification.Root, Node_Kind)
and not Find_Node_Of_Kind(Unit_Body.Root, Node_Kind) then
Missing_Basic_Decls.Append(Node_Kind);
end if;
end if;
end loop;
if Missing_Basic_Decls /= Empty_Vector then
Ada.Text_IO.Put_Line("Missing basic declarations:");
for Node_Kind of Missing_Basic_Decls loop
Ada.Text_IO.Put_Line(" - " & Node_Kind'Image);
end loop;
end if;
end Find_Basic_Decls;
procedure Find_Calls is
Unit : LAL.Analysis_Unit;
function Visit(Node : LAL.Ada_Node'Class) return LALCO.Visit_Status is
use LAL;
use LALCO;
use Langkit_Support.Text;
begin
--if Node.Kind = Ada_Identifier
-- and then Node.Parent.Kind = Ada_Attribute_Ref
-- and then Node.Parent.As_Attribute_Ref.F_Attribute = Node
--then
-- Node.Parent.Parent.Print;
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Is_Defining'Image);
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Referenced_Decl.Is_Null'Image);
-- Ada.Text_IO.Put_Line(Node.As_Identifier.P_Is_Call'Image);
-- Ada.Text_IO.Put_Line(Node.Parent.As_Attribute_Ref.P_Referenced_Decl.Is_Null'Image);
--end if;
if Node.Kind = Ada_Identifier
and then not Node.As_Identifier.P_Is_Defining
and then Node.As_Identifier.P_Is_Call
then
declare
Identifier : LAL.Identifier := Node.As_Identifier;
Identifier_Parent : LAL.Basic_Decl := Identifier.P_Parent_Basic_Decl;
Identifier_Parent_Name : String :=
Encode(Identifier_Parent.P_Fully_Qualified_Name, Identifier_Parent.Unit.Get_Charset) & " at " & Get_Location(Identifier);
Basic_Decl : LAL.Basic_Decl := Identifier.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Basic_Decl.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("1) " & Identifier_Parent_Name & " calls " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Identifier_Parent_Name & " is " & Identifier.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
-- below should be
-- - look at parent, and if dotted name look at type of prefix
-- - look at parent (or parent of parent), and if call expr look at types of parameters
--if Call_Expr /= No_Ada_Node
-- and then (for some E of Call_Expr.As_Call_Expr.F_Suffix.As_Assoc_List => E.As_Param_Assoc.F_R_Expr.P_Expression_Type.Kind = Ada_Classwide_Type_Decl)
--then
-- Ada.Text_IO.Put_Line(" - is dispatching");
--end if;
--if Identifier.P_Is_Dot_Call
-- and then not Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Is_Null
--then
-- if Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Kind = Ada_Classwide_Type_Decl then -- Crashes in print if this check is missing
-- Dotted_Name.As_Dotted_Name.F_Prefix.Print;
-- Dotted_Name.As_Dotted_Name.F_Prefix.P_Expression_Type.Print;
-- if Call_Expr /= No_Ada_Node
-- and then not Call_Expr.As_Call_Expr.P_Expression_Type.Is_Null
-- then
-- Call_Expr.As_Call_Expr.P_Expression_Type.Print;
-- end if;
-- end if;
--end if;
end;
elsif Node.Kind = Ada_Identifier
and then Node.Parent.Kind /= Ada_End_Name
and then not Node.As_Identifier.P_Is_Defining
and then not Node.As_Identifier.P_Referenced_Decl.Is_Null
and then Node.Parent.Kind not in Ada_Accept_Stmt_Range
and then (Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Null_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Expr_Function
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Entry_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Entry_Body
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Body
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Renaming_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Renaming_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Generic_Subp_Instantiation
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Subp_Body_Stub
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Abstract_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Abstract_Formal_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Concrete_Formal_Subp_Decl
or else Node.As_Identifier.P_Referenced_Decl.Kind = Ada_Enum_Literal_Decl) -- Enum literals are parameterless functions
and then (Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Generic_Package_Instantiation) = No_Ada_Node -- Skip designator in instantiation
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc) = No_Ada_Node
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc).As_Param_Assoc.F_Designator /= Node)
and then (Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Generic_Subp_Instantiation) = No_Ada_Node -- Skip designator in instantiation
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc) = No_Ada_Node
or else Rejuvenation.Navigation.Get_Ancestor_Of_Type(Node, Ada_Param_Assoc).As_Param_Assoc.F_Designator /= Node)
then
declare
Identifier : LAL.Identifier := Node.As_Identifier;
Identifier_Parent : LAL.Basic_Decl:= Identifier.P_Parent_Basic_Decl;
Identifier_Parent_Name : String :=
Encode(Identifier_Parent.P_Fully_Qualified_Name, Identifier.Unit.Get_Charset) & " at " & Get_Location(Identifier);
Basic_Decl : LAL.Basic_Decl := Identifier.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("2) " & Identifier_Parent_Name & " references " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Identifier_Parent_Name & " is " & Identifier.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Decl
then
declare
Subp_Decl : LAL.Subp_Decl := Node.As_Subp_Decl;
Subp_Decl_Name : String :=
Encode(Subp_Decl.P_Fully_Qualified_Name, Subp_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Decl);
Subp_Body : LAL.Body_Node := Subp_Decl.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
-- Foo : Basic_Decl_Array := Subp_Decl.P_Base_Subp_Declarations; -- Finds subprograms overriden (including the current one)
begin
Ada.Text_IO.Put_Line("3) " & Subp_Decl_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Decl_Name & " is " & Subp_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
-- for I in Foo'Range loop
-- Foo(I).Print;
--end loop;
end;
elsif Node.Kind = Ada_Generic_Subp_Decl
then
declare
Subp_Decl : LAL.Generic_Subp_Decl := Node.As_Generic_Subp_Decl;
Subp_Decl_Name : String :=
Encode(Subp_Decl.P_Fully_Qualified_Name, Subp_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Decl);
Subp_Body : LAL.Body_Node := Subp_Decl.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
begin
Ada.Text_IO.Put_Line("4) " & Subp_Decl_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Decl_Name & " is " & Subp_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Body_Stub then
declare
Subp_Body_Stub : LAL.Subp_Body_Stub := Node.As_Subp_Body_Stub;
Subp_Body_Stub_Name : String :=
Encode(Subp_Body_Stub.P_Fully_Qualified_Name, Subp_Body_Stub.Unit.Get_Charset) & " at " & Get_Location(Subp_Body_Stub);
Subp_Body : LAL.Body_Node := Subp_Body_Stub.P_Body_Part_For_Decl;
Subp_Body_Name : String :=
Encode(Subp_Body.P_Fully_Qualified_Name, Subp_Body.Unit.Get_Charset) & " at " & Get_Location(Subp_Body);
begin
Ada.Text_IO.Put_Line("5) " & Subp_Body_Stub_Name & " is implemented by " & Subp_Body_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Stub_Name & " is " & Subp_Body_Stub.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Body_Name & " is " & Subp_Body.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Subp_Renaming_Decl
and then not Node.As_Subp_Renaming_Decl.F_Renames.F_Renamed_Object.P_Referenced_Decl.Is_Null
then
declare
Subp_Renaming_Decl : LAL.Subp_Renaming_Decl := Node.As_Subp_Renaming_Decl;
Subp_Renaming_Decl_Name : String :=
Encode(Subp_Renaming_Decl.P_Fully_Qualified_Name, Subp_Renaming_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Renaming_Decl);
Basic_Decl : LAL.Basic_Decl := Subp_Renaming_Decl.F_Renames.F_Renamed_Object.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("6) " & Subp_Renaming_Decl_Name & " renames " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Renaming_Decl_Name & " is " & Subp_Renaming_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Generic_Subp_Renaming_Decl then
declare
Subp_Renaming_Decl : LAL.Generic_Subp_Renaming_Decl := Node.As_Generic_Subp_Renaming_Decl;
Subp_Renaming_Decl_Name : String :=
Encode(Subp_Renaming_Decl.P_Fully_Qualified_Name, Subp_Renaming_Decl.Unit.Get_Charset) & " at " & Get_Location(Subp_Renaming_Decl);
Basic_Decl : LAL.Basic_Decl := Subp_Renaming_Decl.F_Renames.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("7) " & Subp_Renaming_Decl_Name & " renames " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Renaming_Decl_Name & " is " & Subp_Renaming_Decl.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Generic_Subp_Instantiation then
declare
Subp_Instantiation : LAL.Generic_Subp_Instantiation := Node.As_Generic_Subp_Instantiation;
Subp_Instantiation_Name : String :=
Encode(Subp_Instantiation.P_Fully_Qualified_Name, Subp_Instantiation.Unit.Get_Charset) & " at " & Get_Location(Subp_Instantiation);
Basic_Decl : LAL.Basic_Decl := Subp_Instantiation.F_Generic_Subp_Name.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("8) " & Subp_Instantiation_Name & " instantiates " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Subp_Instantiation_Name & " is " & Subp_Instantiation.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Entry_Body then -- We do not reason starting from the entry declaration, to be consistent with accept statements
declare
Entry_Body : LAL.Entry_Body := Node.As_Entry_Body;
Entry_Body_Name : String :=
Encode(Entry_Body.P_Fully_Qualified_Name, Entry_Body.Unit.Get_Charset) & " at " & Get_Location(Entry_Body);
Entry_Decl : LAL.Basic_Decl := Entry_Body.P_Decl_Part;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("9) " & Entry_Body_Name & " implements " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Body_Name & " is " & Entry_Body.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Accept_Stmt then -- We do not reason starting from the entry declaration, because there can be multiple accepts for the same entry.
declare
Accept_Stmt : LAL.Accept_Stmt := Node.As_Accept_Stmt;
Accept_Stmt_Line : String := Accept_Stmt.Sloc_Range.Start_Line'Image;
Accept_Stmt_Parent : LAL.Basic_Decl := Accept_Stmt.P_Parent_Basic_Decl;
Accept_Stmt_Parent_Name : String :=
Encode(Accept_Stmt_Parent.P_Fully_Qualified_Name, Accept_Stmt.Unit.Get_Charset) & " at " & Get_Location(Accept_Stmt);
Entry_Decl : LAL.Entry_Decl := Accept_Stmt.F_Name.P_Referenced_Decl.As_Entry_Decl;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("10) " & Accept_Stmt_Parent_Name & " accepts " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Accept_Stmt_Parent_Name & " is " & Accept_Stmt.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind = Ada_Accept_Stmt_With_Stmts then -- We do not reason starting from the entry declaration, because there can be multiple accepts for the same entry.
declare
Accept_Stmt : LAL.Accept_Stmt_With_Stmts := Node.As_Accept_Stmt_With_Stmts;
Accept_Stmt_Line : String := Accept_Stmt.Sloc_Range.Start_Line'Image;
Accept_Stmt_Parent : LAL.Basic_Decl := Accept_Stmt.P_Parent_Basic_Decl;
Accept_Stmt_Parent_Name : String :=
Encode(Accept_Stmt_Parent.P_Fully_Qualified_Name, Accept_Stmt.Unit.Get_Charset) & " at " & Get_Location(Accept_Stmt);
Entry_Decl : LAL.Entry_Decl := Accept_Stmt.F_Name.P_Referenced_Decl.As_Entry_Decl;
Entry_Decl_Name : String :=
Encode(Entry_Decl.P_Fully_Qualified_Name, Entry_Decl.Unit.Get_Charset) & " at " & Get_Location(Entry_Decl);
begin
Ada.Text_IO.Put_Line("11) " & Accept_Stmt_Parent_Name & " accepts " & Entry_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Accept_Stmt_Parent_Name & " is " & Accept_Stmt.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Entry_Decl_Name & " is " & Entry_Decl.Unit.Get_Filename);
end;
elsif Node.Kind in Ada_Op
and then not Node.As_Op.P_Referenced_Decl.Is_Null
then
declare
Op : LAL.Op := Node.As_Op;
Op_Line : String := Op.Sloc_Range.Start_Line'Image;
Op_Parent : LAL.Basic_Decl := Op.P_Parent_Basic_Decl;
Op_Parent_Name : String :=
Encode(Op_Parent.P_Fully_Qualified_Name, Op.Unit.Get_Charset) & " at " & Get_Location(Op);
Basic_Decl : LAL.Basic_Decl := Op.P_Referenced_Decl;
Basic_Decl_Name : String :=
Encode(Basic_Decl.P_Fully_Qualified_Name, Node.Unit.Get_Charset) & " at " & Get_Location(Basic_Decl);
begin
Ada.Text_IO.Put_Line("12) " & Op_Parent_Name & " calls " & Basic_Decl_Name);
Ada.Text_IO.Put_Line(" - full path of " & Op_Parent_Name & " is " & Op.Unit.Get_Filename);
Ada.Text_IO.Put_Line(" - full path of " & Basic_Decl_Name & " is " & Basic_Decl.Unit.Get_Filename);
end;
end if;
return Into;
exception when E : Property_Error =>
Ada.Text_IO.Put_Line("Encountered Libadalang problem: " & Ada.Exceptions.Exception_Message (E));
Node.Print;
return Into;
end Visit;
begin
for Unit of Units loop
Ada.Text_IO.Put_Line("== " & Unit.Get_Filename & " ==");
Unit.Root.Traverse(Visit'Access);
end loop;
end Find_Calls;
begin
-- Find_Basic_Decls;
Find_Calls;
end Main;
|
test/Succeed/Issue5787.agda | KDr2/agda | 1 | 12513 |
postulate
A B : Set
f : @0 {{A}} → B
g : @0 {{A}} → B
g = f
|
oeis/071/A071953.asm | neoneye/loda-programs | 11 | 94815 | ; A071953: Diagonal T(n,n-2) of triangle in A071951.
; 4,52,292,1092,3192,7896,17304,34584,64284,112684,188188,301756,467376,702576,1028976,1472880,2065908,2845668,3856468,5150068,6786472,8834760,11373960,14493960,18296460,22895964,28420812,35014252,42835552,52061152,62885856,75524064,90211044,107204244,126784644,149258148,174957016,204241336,237500536,275154936,317657340,365494668,419189628,479302428,546432528,621220432,704349520,796547920,898590420,1011300420,1135551924,1272271572,1422440712,1587097512,1767339112,1964323816,2179273324,2413475004
lpb $0
mov $2,$0
sub $0,1
seq $2,208139 ; Number of n X 5 0..1 arrays avoiding 0 0 1 and 0 1 1 horizontally and 0 0 1 and 1 0 1 vertically.
add $1,$2
lpe
div $1,3
add $1,4
mov $0,$1
|
old/Spaces/Circle.agda | UlrikBuchholtz/HoTT-Agda | 294 | 9146 | <reponame>UlrikBuchholtz/HoTT-Agda
{-# OPTIONS --without-K #-}
open import Base
module Spaces.Circle where
{-
Idea :
data S¹ : Set where
base : S¹
loop : base ≡ base
I’m using Dan Licata’s trick to have a higher inductive type with definitional
reduction rule for [base]
-}
private
data #S¹ : Set where
#base : #S¹
S¹ : Set
S¹ = #S¹
base : S¹
base = #base
postulate -- HIT
loop : base ≡ base
S¹-rec : ∀ {i} (P : S¹ → Set i) (x : P base) (p : transport P loop x ≡ x)
→ ((t : S¹) → P t)
S¹-rec P x p #base = x
postulate -- HIT
S¹-β-loop : ∀ {i} (P : S¹ → Set i) (x : P base) (p : transport P loop x ≡ x)
→ apd (S¹-rec P x p) loop ≡ p
S¹-rec-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x) → (S¹ → A)
S¹-rec-nondep A x p #base = x
postulate -- HIT
S¹-β-loop-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x)
→ ap (S¹-rec-nondep A x p) loop ≡ p
-- S¹-rec-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x) → (S¹ → A)
-- S¹-rec-nondep A x p = S¹-rec (λ _ → A) x (trans-cst loop x ∘ p)
-- β-nondep : ∀ {i} (A : Set i) (x : A) (p : x ≡ x)
-- → ap (S¹-rec-nondep A x p) loop ≡ p
-- β-nondep A x p =
-- apd-trivial (S¹-rec-nondep A x p) loop ∘
-- (whisker-left (! (trans-cst loop _)) (β (λ _ → A) x (trans-cst loop _ ∘ p))
-- ∘ (! (concat-assoc (! (trans-cst loop _)) (trans-cst loop _) p)
-- ∘ whisker-right p (opposite-left-inverse (trans-cst loop _))))
|
examples/shared/serial_ports/src/message_buffers.adb | rocher/Ada_Drivers_Library | 192 | 21664 | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body Message_Buffers is
-------------
-- Content --
-------------
function Content (This : Message) return String is
begin
return This.Content (1 .. This.Length);
end Content;
----------------
-- Content_At --
----------------
function Content_At (This : Message; Index : Positive) return Character is
begin
return This.Content (Index);
end Content_At;
------------
-- Length --
------------
function Length (This : Message) return Natural is
begin
return This.Length;
end Length;
-----------
-- Clear --
-----------
procedure Clear (This : in out Message) is
begin
This.Length := 0;
end Clear;
------------
-- Append --
------------
procedure Append (This : in out Message; Value : Character) is
begin
This.Length := This.Length + 1;
This.Content (This.Length) := Value;
end Append;
---------
-- Set --
---------
procedure Set (This : in out Message; To : String) is
begin
This.Content (1 .. To'Length) := To;
This.Length := To'Length;
end Set;
---------
-- Set --
---------
procedure Set (This : in out Message; To : Character) is
begin
This.Content (1) := To;
This.Length := 1;
end Set;
--------------------
-- Set_Terminator --
--------------------
procedure Set_Terminator (This : in out Message; To : Character) is
begin
This.Terminator := To;
end Set_Terminator;
----------------
-- Terminator --
----------------
function Terminator (This : Message) return Character is
begin
return This.Terminator;
end Terminator;
---------------------------------
-- Await_Transmission_Complete --
---------------------------------
procedure Await_Transmission_Complete (This : in out Message) is
begin
Suspend_Until_True (This.Transmission_Complete);
end Await_Transmission_Complete;
------------------------------
-- Await_Reception_Complete --
------------------------------
procedure Await_Reception_Complete (This : in out Message) is
begin
Suspend_Until_True (This.Reception_Complete);
end Await_Reception_Complete;
----------------------------------
-- Signal_Transmission_Complete --
----------------------------------
procedure Signal_Transmission_Complete (This : in out Message) is
begin
Set_True (This.Transmission_Complete);
end Signal_Transmission_Complete;
-------------------------------
-- Signal_Reception_Complete --
-------------------------------
procedure Signal_Reception_Complete (This : in out Message) is
begin
Set_True (This.Reception_Complete);
end Signal_Reception_Complete;
----------------
-- Note_Error --
----------------
procedure Note_Error (This : in out Message; Condition : Error_Conditions) is
begin
This.Error_Status := This.Error_Status or Condition;
end Note_Error;
---------------------
-- Errors_Detected --
---------------------
function Errors_Detected (This : Message) return Error_Conditions is
begin
return This.Error_Status;
end Errors_Detected;
------------------
-- Clear_Errors --
------------------
procedure Clear_Errors (This : in out Message) is
begin
This.Error_Status := No_Error_Detected;
end Clear_Errors;
---------------
-- Has_Error --
---------------
function Has_Error (This : Message; Condition : Error_Conditions) return Boolean is
begin
return (This.Error_Status and Condition) /= 0;
end Has_Error;
end Message_Buffers;
|
programs/oeis/303/A303609.asm | karttu/loda | 1 | 170011 | ; A303609: a(n) = 2*n^3 + 9*n^2 + 9*n.
; 0,20,70,162,308,520,810,1190,1672,2268,2990,3850,4860,6032,7378,8910,10640,12580,14742,17138,19780,22680,25850,29302,33048,37100,41470,46170,51212,56608,62370,68510,75040,81972,89318,97090,105300,113960,123082,132678,142760
mov $1,$0
mul $0,2
add $0,5
bin $0,2
sub $0,1
mul $1,$0
|
programs/oeis/231/A231896.asm | neoneye/loda | 22 | 18472 | <reponame>neoneye/loda
; A231896: a(n) = 4*a(n-1) - a(n-2) with a(0) = 0, a(1) = 4.
; 0,4,16,60,224,836,3120,11644,43456,162180,605264,2258876,8430240,31462084,117418096,438210300,1635423104,6103482116,22778505360,85010539324,317263651936,1184044068420,4418912621744,16491606418556,61547513052480,229698445791364,857246270112976,3199286634660540,11939900268529184,44560314439456196,166301357489295600,620645115517726204,2316279104581609216,8644471302808710660,32261606106653233424,120401953123804223036,449346206388563658720,1676982872430450411844,6258585283333237988656,23357358260902501542780,87170847760276768182464,325326032780204571187076,1214133283360541516565840,4531207100661961495076284,16910695119287304463739296,63111573376487256359880900,235535598386661720975784304,879030820170159627543256316,3280587682293976789197240960,12243319909005747529245707524,45692691953729013327785589136,170527447905910305781896649020,636417099669912209799801006944,2375140950773738533417307378756,8864146703425041923869428508080,33081445862926429162060406653564,123461636748280674724372198106176,460765101130196269735428385771140,1719598767772504404217341344978384,6417629969959821347133936994142396,23950921112066780984318406631591200,89386054478307302590139689532222404,333593296801162429376240351497298416
mov $2,4
lpb $0
sub $0,1
add $2,$1
add $1,$2
add $2,$1
lpe
mov $0,$1
|
alloy4fun_models/trashltl/models/11/7MEWsRCR2QHykYucm.als | Kaixi26/org.alloytools.alloy | 0 | 3917 | <filename>alloy4fun_models/trashltl/models/11/7MEWsRCR2QHykYucm.als
open main
pred id7MEWsRCR2QHykYucm_prop12 {
eventually some Trash and all f: File | f in Trash implies always f in Trash
}
pred __repair { id7MEWsRCR2QHykYucm_prop12 }
check __repair { id7MEWsRCR2QHykYucm_prop12 <=> prop12o } |
test/Test4.agda | mchristianl/synthetic-reals | 3 | 15695 | {-# OPTIONS --cubical --no-import-sorts #-}
module Test4 where
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Foundations.Logic
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
record !_ {ℓ} (X : Type ℓ) : Type ℓ where
inductive
constructor !!_
field x : X
open !_ hiding (x)
infix 1 !!_
infix 1 !_
!-iso : ∀{ℓ} {X : Type ℓ} → Iso (! X) X
Iso.fun !-iso = !_.x
Iso.inv !-iso = !!_
Iso.rightInv !-iso = λ x → refl
Iso.leftInv !-iso = λ{ (!! x) → refl }
!-≡ : ∀{ℓ} {X : Type ℓ} → (! X) ≡ X
!-≡ {X = X} = isoToPath !-iso
!-equiv : ∀{ℓ} {X : Type ℓ} → (! X) ≃ X
!-equiv = !_.x , λ where .equiv-proof x → ((!! x) , refl) , λ{ ((!! y) , p) → λ i → (!! p (~ i)) , (λ j → p (~ i ∨ j)) }
hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
hPropRel A B ℓ' = A → B → hProp ℓ'
module TestB {ℓ ℓ'} (X : Type ℓ)
(0ˣ : X) (_+_ _·_ : X → X → X) (_<_ : hPropRel X X ℓ')
(let infixl 5 _+_; _+_ = _+_) where
_≤_ : hPropRel X X ℓ'
x ≤ y = ¬(y < x)
postulate
sqrt : (x : X) → {{ ! [ 0ˣ ≤ x ] }} → X
0≤x² : ∀ x → [ 0ˣ ≤ (x · x) ]
instance -- module-scope instances
_ = λ {x} → !! 0≤x² x
test4 : (x y z : X) → [ 0ˣ ≤ x ] → [ 0ˣ ≤ y ] → X
test4 x y z 0≤x 0≤y =
let instance -- let-scope instances
_ = !! 0≤x
_ = !! 0≤y
_ = !! 0≤x² x -- preferred over the instance from module-scope
in ( (sqrt x) -- works
+ (sqrt y) -- also works
+ (sqrt (z · z)) -- uses instance from module scope
+ (sqrt (x · x)) -- uses instance from let-scope (?) -- NOTE: see https://github.com/agda/agda/issues/4688
)
|
Examples/Precedence.agda | nad/pretty | 0 | 14840 | <gh_stars>0
------------------------------------------------------------------------
-- A general grammar and pretty-printer for binary operators of
-- various (not necessarily linearly ordered) precedences
------------------------------------------------------------------------
-- The code below uses a variant of the operator grammars described by
-- <NAME> and me in "Parsing Mixfix Operators". For simplicity the
-- code only handles binary infix operators.
{-# OPTIONS --guardedness #-}
module Examples.Precedence where
open import Codata.Musical.Notation
open import Data.Bool using (Bool; T)
import Data.Bool.Properties as Bool-prop
open import Data.Char as Char using (Char; _==_)
open import Data.Fin using (Fin; zero; suc; #_)
open import Data.Fin.Properties as Fin using () renaming (_≟_ to _≟F_)
open import Data.List as List
open import Data.List.Membership.Propositional
open import Data.List.NonEmpty as List⁺
import Data.List.Properties as List
open import Data.List.Relation.Unary.Any as Any
open import Data.Nat using (ℕ)
open import Data.Product as Prod
import Data.String as String
open import Data.Unit
import Data.Vec as Vec
open import Data.Vec.Membership.Propositional.Properties
open import Function using (id; _∘_; _∘′_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import Relation.Nullary.Decidable as Decidable
open import Relation.Nullary.Product
open import Examples.Identifier
open import Grammar.Infinite as Grammar using (Grammar-for)
open import Pretty using (Pretty-printer-for)
open import Renderer
open import Utilities
------------------------------------------------------------------------
-- Binary operators
-- Associativities.
data Associativity : Set where
- -- Non-associative.
⇾ -- Right associative.
⇽ -- Left associative.
: Associativity
-- Operator names.
is-operator-char : Char → Bool
is-operator-char t =
List.any (_==_ t) (String.toList "+-*/.:^<>=!&|")
Operator-name : Set
Operator-name = List⁺ (∃ (T ∘ is-operator-char))
-- Operators (parametrised by their associativity).
record Operator (assoc : Associativity) : Set where
constructor ⟪_⟫
field name : Operator-name
-- Equality of operators can be decided.
_≟O_ : ∀ {assoc} → Decidable (_≡_ {A = Operator assoc})
⟪ n₁ ∷ ns₁ ⟫ ≟O ⟪ n₂ ∷ ns₂ ⟫ =
Decidable.map′
(P.cong ⟪_⟫ ∘ uncurry (P.cong₂ _∷_))
(< P.cong List⁺.head , P.cong List⁺.tail > ∘′ P.cong Operator.name)
((n₁ ≟OC n₂)
×-dec
List.≡-dec _≟OC_ ns₁ ns₂)
where
_≟OC_ : Decidable (_≡_ {A = ∃ (T ∘ is-operator-char)})
(c₁ , _) ≟OC (c₂ , _) =
Decidable.map′ lemma (P.cong proj₁) (c₁ Char.≟ c₂)
where
lemma : {p₁ p₂ : ∃ (T ∘ is-operator-char)} →
proj₁ p₁ ≡ proj₁ p₂ → p₁ ≡ p₂
lemma {p₁ = _ , _} {p₂ = ._ , _} P.refl =
P.cong -,_ (Bool-prop.T-irrelevant _ _)
-- A grammar for a given operator name.
operator-name : Grammar-for Operator-name
operator-name n = list⁺ (tok-sat _) n
where open Grammar
-- A pretty-printer for operator names.
operator-name-printer : Pretty-printer-for operator-name
operator-name-printer n = list⁺ tok-sat n
where open Pretty
-- A grammar for a given operator.
operator : ∀ {assoc} → Grammar-for (Operator assoc)
operator op =
Prod.map ⟪_⟫ (P.cong ⟪_⟫) <$> operator-name (Operator.name op)
where open Grammar
-- A pretty-printer for operators.
operator-printer : ∀ {assoc} →
Pretty-printer-for (operator {assoc = assoc})
operator-printer op = <$> operator-name-printer (Operator.name op)
where open Pretty
------------------------------------------------------------------------
-- Precedence graphs
-- Precedence graphs are represented by the number of precedence
-- levels, plus functions mapping node identifiers (precedences) to
-- node contents and successor precedences.
record Precedence-graph : Set where
field
-- The number of precedence levels.
levels : ℕ
-- Precedence levels.
Precedence : Set
Precedence = Fin levels
field
-- The precedence level's operators.
ops : Precedence → (assoc : Associativity) → List (Operator assoc)
-- The immediate successors of the precedence level.
↑ : Precedence → List Precedence
-- All precedence levels.
all-precedences : List Precedence
all-precedences = Vec.toList (Vec.allFin levels)
-- Every precedence level is a member of all-precedences.
∈-all-precedences : ∀ {p} → p ∈ all-precedences
∈-all-precedences {p} = ∈-toList⁺ (∈-allFin⁺ p)
-- A membership test for precedences.
_∈?_ : ∀ (p : Precedence) ps → Dec (p ∈ ps)
p ∈? ps = Any.any? (_≟F_ p) ps
------------------------------------------------------------------------
-- Expressions
-- The code is parametrised by a precedence graph.
module Expr (g : Precedence-graph) where
open Precedence-graph g
-- Operators with a given precedence and associativity.
Op : Precedence → Associativity → Set
Op p assoc = ∃ λ op → op ∈ ops p assoc
mutual
-- Expressions.
data Expr : Set where
var : Identifier → Expr
app : ∀ {p} → ∃ (App p) → Expr
-- Binary operator applications where the operator has a given
-- precedence and associativity.
App : Precedence → Associativity → Set
App p assoc = Expr × Op p assoc × Expr
-- The following function can be convenient to use when constructing
-- examples.
_⟨_⟩_ :
∀ {assoc} → Expr → (op : Operator assoc) →
{member : True (Fin.any? λ p →
Any.any? (_≟O_ op) (ops p assoc))} →
Expr → Expr
_⟨_⟩_ e₁ op {member} e₂ =
app (_ , e₁ , (op , proj₂ (toWitness member)) , e₂)
module _ where
open Grammar
mutual
-- Expression grammar.
expr : Grammar Expr
expr = whitespace ⋆ ⊛> precs all-precedences <⊛ whitespace ⋆
-- Grammar for a given list of precedence levels.
precs : List Precedence → Grammar Expr
precs ps = string′ "(" ⊛> ♯ expr <⊛ string′ ")"
∣ var <$> identifier
∣ precs′ ps
precs′ : List Precedence → Grammar Expr
precs′ [] = fail
precs′ (p ∷ ps) = app <$> ♯ prec p
∣ precs′ ps
-- Grammar for a given precedence level.
prec : (p : Precedence) → Grammar (∃ (App p))
prec p = -,_ <$> non-assoc p
∣ -,_ <$> right⁺ p
∣ -,_ <$> left⁺ p
-- Grammar for higher precedence levels.
higher : Precedence → Grammar Expr
higher p = precs (↑ p)
-- Non-associative operators.
non-assoc : (p : Precedence) → Grammar (App p -)
non-assoc p = (λ e₁ op e₂ → e₁ , op , e₂) <$>
higher p ⊛ operators (ops p -) ⊛ higher p
-- Right-associative operators.
right⁺ : (p : Precedence) → Grammar (App p ⇾)
right⁺ p = (λ e₁ op e₂ → e₁ , op , e₂) <$>
higher p ⊛ operators (ops p ⇾) ⊛ right⁺↑ p
right⁺↑ : Precedence → Grammar Expr
right⁺↑ p = (app ∘ -,_) <$> ♯ right⁺ p
∣ higher p
-- Left-associative operators.
left⁺ : (p : Precedence) → Grammar (App p ⇽)
left⁺ p = (λ e₁ op e₂ → e₁ , op , e₂) <$>
left⁺↑ p ⊛ operators (ops p ⇽) ⊛ higher p
left⁺↑ : Precedence → Grammar Expr
left⁺↑ p = (app ∘ -,_) <$> ♯ left⁺ p
∣ higher p
-- An operator from a given list of operators.
operators : ∀ {assoc} (os : List (Operator assoc)) →
Grammar (∃ λ op → op ∈ os)
operators [] = fail
operators (op ∷ ops) = whitespace ⋆
⊛> (Prod.map id here <$> operator op)
<⊛ whitespace ⋆
∣ Prod.map id there <$> operators ops
open Pretty
mutual
-- Pretty-printer. The produced layout could probably be improved,
-- I have not tried very hard to make it pretty.
expr-printer : Pretty-printer expr
expr-printer e = nil-⋆ ⊛> precs-printer e <⊛ nil-⋆
precs-printer : ∀ {ps} → Pretty-printer (precs ps)
precs-printer e = group (precs-printer′ e)
where
precs-printer′ : ∀ {ps} → Pretty-printer (precs ps)
precs-printer′ (var x) = left (right (<$> identifier-printer x))
precs-printer′ {ps} (app {p = p} e)
with p ∈? ps
... | yes p∈ps = right (precs′-printer p∈ps e)
... | no _ =
-- Incorrect precedence level: insert parentheses.
left (left (text ⊛> nest 1 d <⊛ text))
where
d = nil-⋆ ⊛>
right (precs′-printer ∈-all-precedences e) <⊛
nil-⋆
precs′-printer :
∀ {p ps} → p ∈ ps → (e : ∃ (App p)) → Doc (precs′ ps) (app e)
precs′-printer (here P.refl) e = left (<$> prec-printer e)
precs′-printer (there p∈ps) e = right (precs′-printer p∈ps e)
prec-printer : ∀ {p} → Pretty-printer (prec p)
prec-printer (- , e) = left (left (<$> non-assoc-printer e))
prec-printer (⇾ , e) = left (right (<$> right⁺-printer e))
prec-printer (⇽ , e) = right (<$> left⁺-printer e)
non-assoc-printer : ∀ {p} → Pretty-printer (non-assoc p)
non-assoc-printer (e₁ , op , e₂) =
<$> higher-printer e₁ ⊛ operators-printer op ⊛ higher-printer e₂
right⁺-printer : ∀ {p} → Pretty-printer (right⁺ p)
right⁺-printer (e₁ , op , e₂) =
<$> higher-printer e₁ ⊛ operators-printer op ⊛ right⁺↑-printer e₂
right⁺↑-printer : ∀ {p} → Pretty-printer (right⁺↑ p)
right⁺↑-printer {p₁} (app {p = p₂} (⇾ , e))
with p₁ ≟F p₂ | higher-printer (app (⇾ , e))
right⁺↑-printer (app (⇾ , e)) | yes P.refl | _ =
-- Matching precedence and associativity.
left (<$> right⁺-printer e)
right⁺↑-printer (app (⇾ , e)) | no _ | d = right d
right⁺↑-printer e = right (higher-printer e)
left⁺-printer : ∀ {p} → Pretty-printer (left⁺ p)
left⁺-printer (e₁ , op , e₂) =
<$> left⁺↑-printer e₁ ⊛ operators-printer op ⊛ higher-printer e₂
left⁺↑-printer : ∀ {p} → Pretty-printer (left⁺↑ p)
left⁺↑-printer {p₁} (app {p = p₂} (⇽ , e))
with p₁ ≟F p₂ | higher-printer (app (⇽ , e))
left⁺↑-printer (app (⇽ , e)) | yes P.refl | _ =
-- Matching precedence and associativity.
left (<$> left⁺-printer e)
left⁺↑-printer (app (⇽ , e)) | no _ | d = right d
left⁺↑-printer e = right (higher-printer e)
higher-printer : ∀ {p} → Pretty-printer (higher p)
higher-printer e = nest 2 (precs-printer e)
operators-printer : ∀ {assoc} {os : List (Operator assoc)} →
Pretty-printer (operators os)
operators-printer {os = []} (_ , ())
operators-printer {os = ._ ∷ _} (op , here P.refl) =
left (line⋆ tt-⊛> <$> operator-printer op <⊛ space)
operators-printer {os = _ ∷ _} (_ , there op∈os) =
right (<$> operators-printer (_ , op∈os))
------------------------------------------------------------------------
-- An example
-- Some operators.
add : Operator ⇽
add = ⟪ str⁺ "+" ⟫
sub : Operator ⇽
sub = ⟪ str⁺ "-" ⟫
mul : Operator ⇽
mul = ⟪ str⁺ "*" ⟫
div : Operator ⇽
div = ⟪ str⁺ "/" ⟫
cons : Operator ⇾
cons = ⟪ str⁺ "<:" ⟫
snoc : Operator ⇽
snoc = ⟪ str⁺ ":>" ⟫
-- A precedence graph.
g : Precedence-graph
g = record { ops = ops; ↑ = ↑ }
where
ops : Fin 3 → (assoc : Associativity) → List (Operator assoc)
ops zero ⇽ = snoc ∷ []
ops zero ⇾ = cons ∷ []
ops (suc zero) ⇽ = add ∷ sub ∷ []
ops (suc (suc zero)) ⇽ = mul ∷ div ∷ []
ops _ _ = []
↑ : Fin 3 → List (Fin 3)
↑ zero = # 1 ∷ # 2 ∷ []
↑ (suc zero) = # 2 ∷ []
↑ (suc (suc p)) = []
open Precedence-graph g
open Expr g
-- An expression.
example : Expr
example =
(((var (str⁺ "y") ⟨ add ⟩ var (str⁺ "k"))
⟨ cons ⟩
(((var (str⁺ "i") ⟨ add ⟩ var (str⁺ "foo"))
⟨ add ⟩
((var (str⁺ "a")
⟨ div ⟩
(var (str⁺ "b") ⟨ sub ⟩ var (str⁺ "c")))
⟨ mul ⟩
var (str⁺ "c")))
⟨ cons ⟩
(var (str⁺ "xs"))))
⟨ snoc ⟩
(var (str⁺ "x")))
⟨ snoc ⟩
(var (str⁺ "z") ⟨ mul ⟩ var (str⁺ "z"))
-- Some unit tests.
test₁ : render 80 (expr-printer example) ≡
"(y + k <: i + foo + a / (b - c) * c <: xs) :> x :> z * z"
test₁ = P.refl
test₂ : render 50 (expr-printer example) ≡
"(y + k <: i + foo + a / (b - c) * c <: xs)\n:> x\n:> z * z"
test₂ = P.refl
test₃ : render 40 (expr-printer example) ≡
"(y + k\n <: i + foo + a / (b - c) * c\n <: xs)\n:> x\n:> z * z"
test₃ = P.refl
test₄ : render 30 (expr-printer example) ≡
"(y + k\n <: i\n + foo\n + a / (b - c) * c\n <: xs)\n:> x\n:> z * z"
test₄ = P.refl
test₅ : render 20 (expr-printer example) ≡
"(y + k\n <: i\n + foo\n + a\n / (b - c)\n * c\n <: xs)\n:> x\n:> z * z"
test₅ = P.refl
test₆ : render 6 (expr-printer example) ≡
"(y + k\n <: i\n + foo\n + a\n / (b\n - c)\n * c\n <: xs)\n:> x\n:> z\n * z"
test₆ = P.refl
-- The rendering of "y + k" in the following test may seem strange: if
-- no newline had been inserted before +, then the total width of this
-- subexpression would have been smaller.
--
-- Wadler's pretty-printing algorithm is not always optimal for texts
-- that do not fit in the allotted width, if by "optimal" we mean
-- "with as little overflow as possible". To see what I mean, try
-- running the following Haskell code, where the functions are
-- implemented as in Wadler's paper:
--
-- pretty 1 (group (nest 20 (line <> text "x")))
--
-- The result is "\n x", which can be seen as much
-- worse than the alternative result " x". However, note that Wadler
-- uses a lexicographic definition of "better", in which
-- "\n x" is better than " x", because the first
-- line of "\n x" fits, but the first line of " x"
-- doesn't.
test₇ : render 5 (expr-printer example) ≡
"(y\n + k\n <: i\n + foo\n + a\n / (b\n - c)\n * c\n <: xs)\n:> x\n:> z\n * z"
test₇ = P.refl
|
random_ideas/alloy/pm4.als | asimihsan/asim_ihsan_io | 0 | 535 | <reponame>asimihsan/asim_ihsan_io
sig Package {
name : one Name,
version : one Version,
requires : set Package,
}
sig Name {}
sig Version {}
fact "only one package version in dependency graph for package" {
all p1 : Package, disj p2, p3 : p1.*requires | p2.name != p3.name
}
fact "package doesn't require itself at any version" {
all p : Package | p.name not in (p.requires).name
}
run example {
// At least 3 Packages
#(Package.name) >= 3
// At least two requirements
#(Package.requires) >= 2
} for 5
|
wc.asm | bhavesh01shukla/Modified-XV-6 | 0 | 25686 |
_wc: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "%d %d %d %s\n", l, w, c, name);
}
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: be 01 00 00 00 mov $0x1,%esi
14: 53 push %ebx
15: 51 push %ecx
16: 83 ec 18 sub $0x18,%esp
19: 8b 01 mov (%ecx),%eax
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 89 45 e4 mov %eax,-0x1c(%ebp)
21: 83 c3 04 add $0x4,%ebx
int fd, i;
if(argc <= 1){
24: 83 f8 01 cmp $0x1,%eax
27: 7e 56 jle 7f <main+0x7f>
29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
30: 83 ec 08 sub $0x8,%esp
33: 6a 00 push $0x0
35: ff 33 pushl (%ebx)
37: e8 d5 03 00 00 call 411 <open>
3c: 83 c4 10 add $0x10,%esp
3f: 89 c7 mov %eax,%edi
41: 85 c0 test %eax,%eax
43: 78 26 js 6b <main+0x6b>
printf(1, "wc: cannot open %s\n", argv[i]);
exit();
}
wc(fd, argv[i]);
45: 83 ec 08 sub $0x8,%esp
48: ff 33 pushl (%ebx)
for(i = 1; i < argc; i++){
4a: 83 c6 01 add $0x1,%esi
4d: 83 c3 04 add $0x4,%ebx
wc(fd, argv[i]);
50: 50 push %eax
51: e8 4a 00 00 00 call a0 <wc>
close(fd);
56: 89 3c 24 mov %edi,(%esp)
59: e8 9b 03 00 00 call 3f9 <close>
for(i = 1; i < argc; i++){
5e: 83 c4 10 add $0x10,%esp
61: 39 75 e4 cmp %esi,-0x1c(%ebp)
64: 75 ca jne 30 <main+0x30>
}
exit();
66: e8 66 03 00 00 call 3d1 <exit>
printf(1, "wc: cannot open %s\n", argv[i]);
6b: 50 push %eax
6c: ff 33 pushl (%ebx)
6e: 68 eb 08 00 00 push $0x8eb
73: 6a 01 push $0x1
75: e8 e6 04 00 00 call 560 <printf>
exit();
7a: e8 52 03 00 00 call 3d1 <exit>
wc(0, "");
7f: 52 push %edx
80: 52 push %edx
81: 68 dd 08 00 00 push $0x8dd
86: 6a 00 push $0x0
88: e8 13 00 00 00 call a0 <wc>
exit();
8d: e8 3f 03 00 00 call 3d1 <exit>
92: 66 90 xchg %ax,%ax
94: 66 90 xchg %ax,%ax
96: 66 90 xchg %ax,%ax
98: 66 90 xchg %ax,%ax
9a: 66 90 xchg %ax,%ax
9c: 66 90 xchg %ax,%ax
9e: 66 90 xchg %ax,%ax
000000a0 <wc>:
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 57 push %edi
a4: 56 push %esi
a5: 53 push %ebx
l = w = c = 0;
a6: 31 db xor %ebx,%ebx
{
a8: 83 ec 1c sub $0x1c,%esp
inword = 0;
ab: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
l = w = c = 0;
b2: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
b9: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
while((n = read(fd, buf, sizeof(buf))) > 0){
c0: 83 ec 04 sub $0x4,%esp
c3: 68 00 02 00 00 push $0x200
c8: 68 20 0c 00 00 push $0xc20
cd: ff 75 08 pushl 0x8(%ebp)
d0: e8 14 03 00 00 call 3e9 <read>
d5: 83 c4 10 add $0x10,%esp
d8: 89 c6 mov %eax,%esi
da: 85 c0 test %eax,%eax
dc: 7e 62 jle 140 <wc+0xa0>
for(i=0; i<n; i++){
de: 31 ff xor %edi,%edi
e0: eb 14 jmp f6 <wc+0x56>
e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
inword = 0;
e8: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
for(i=0; i<n; i++){
ef: 83 c7 01 add $0x1,%edi
f2: 39 fe cmp %edi,%esi
f4: 74 42 je 138 <wc+0x98>
if(buf[i] == '\n')
f6: 0f be 87 20 0c 00 00 movsbl 0xc20(%edi),%eax
l++;
fd: 31 c9 xor %ecx,%ecx
ff: 3c 0a cmp $0xa,%al
101: 0f 94 c1 sete %cl
if(strchr(" \r\t\n\v", buf[i]))
104: 83 ec 08 sub $0x8,%esp
107: 50 push %eax
l++;
108: 01 cb add %ecx,%ebx
if(strchr(" \r\t\n\v", buf[i]))
10a: 68 c8 08 00 00 push $0x8c8
10f: e8 3c 01 00 00 call 250 <strchr>
114: 83 c4 10 add $0x10,%esp
117: 85 c0 test %eax,%eax
119: 75 cd jne e8 <wc+0x48>
else if(!inword){
11b: 8b 55 e4 mov -0x1c(%ebp),%edx
11e: 85 d2 test %edx,%edx
120: 75 cd jne ef <wc+0x4f>
for(i=0; i<n; i++){
122: 83 c7 01 add $0x1,%edi
w++;
125: 83 45 e0 01 addl $0x1,-0x20(%ebp)
inword = 1;
129: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
for(i=0; i<n; i++){
130: 39 fe cmp %edi,%esi
132: 75 c2 jne f6 <wc+0x56>
134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
138: 01 75 dc add %esi,-0x24(%ebp)
13b: eb 83 jmp c0 <wc+0x20>
13d: 8d 76 00 lea 0x0(%esi),%esi
if(n < 0){
140: 75 24 jne 166 <wc+0xc6>
printf(1, "%d %d %d %s\n", l, w, c, name);
142: 83 ec 08 sub $0x8,%esp
145: ff 75 0c pushl 0xc(%ebp)
148: ff 75 dc pushl -0x24(%ebp)
14b: ff 75 e0 pushl -0x20(%ebp)
14e: 53 push %ebx
14f: 68 de 08 00 00 push $0x8de
154: 6a 01 push $0x1
156: e8 05 04 00 00 call 560 <printf>
}
15b: 83 c4 20 add $0x20,%esp
15e: 8d 65 f4 lea -0xc(%ebp),%esp
161: 5b pop %ebx
162: 5e pop %esi
163: 5f pop %edi
164: 5d pop %ebp
165: c3 ret
printf(1, "wc: read error\n");
166: 50 push %eax
167: 50 push %eax
168: 68 ce 08 00 00 push $0x8ce
16d: 6a 01 push $0x1
16f: e8 ec 03 00 00 call 560 <printf>
exit();
174: e8 58 02 00 00 call 3d1 <exit>
179: 66 90 xchg %ax,%ax
17b: 66 90 xchg %ax,%ax
17d: 66 90 xchg %ax,%ax
17f: 90 nop
00000180 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
180: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
181: 31 d2 xor %edx,%edx
{
183: 89 e5 mov %esp,%ebp
185: 53 push %ebx
186: 8b 45 08 mov 0x8(%ebp),%eax
189: 8b 5d 0c mov 0xc(%ebp),%ebx
18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((*s++ = *t++) != 0)
190: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx
194: 88 0c 10 mov %cl,(%eax,%edx,1)
197: 83 c2 01 add $0x1,%edx
19a: 84 c9 test %cl,%cl
19c: 75 f2 jne 190 <strcpy+0x10>
;
return os;
}
19e: 5b pop %ebx
19f: 5d pop %ebp
1a0: c3 ret
1a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1af: 90 nop
000001b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 56 push %esi
1b4: 53 push %ebx
1b5: 8b 5d 08 mov 0x8(%ebp),%ebx
1b8: 8b 75 0c mov 0xc(%ebp),%esi
while(*p && *p == *q)
1bb: 0f b6 13 movzbl (%ebx),%edx
1be: 0f b6 0e movzbl (%esi),%ecx
1c1: 84 d2 test %dl,%dl
1c3: 74 1e je 1e3 <strcmp+0x33>
1c5: b8 01 00 00 00 mov $0x1,%eax
1ca: 38 ca cmp %cl,%dl
1cc: 74 09 je 1d7 <strcmp+0x27>
1ce: eb 20 jmp 1f0 <strcmp+0x40>
1d0: 83 c0 01 add $0x1,%eax
1d3: 38 ca cmp %cl,%dl
1d5: 75 19 jne 1f0 <strcmp+0x40>
1d7: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
1db: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx
1df: 84 d2 test %dl,%dl
1e1: 75 ed jne 1d0 <strcmp+0x20>
1e3: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
}
1e5: 5b pop %ebx
1e6: 5e pop %esi
return (uchar)*p - (uchar)*q;
1e7: 29 c8 sub %ecx,%eax
}
1e9: 5d pop %ebp
1ea: c3 ret
1eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1ef: 90 nop
1f0: 0f b6 c2 movzbl %dl,%eax
1f3: 5b pop %ebx
1f4: 5e pop %esi
return (uchar)*p - (uchar)*q;
1f5: 29 c8 sub %ecx,%eax
}
1f7: 5d pop %ebp
1f8: c3 ret
1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000200 <strlen>:
uint
strlen(const char *s)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
206: 80 39 00 cmpb $0x0,(%ecx)
209: 74 15 je 220 <strlen+0x20>
20b: 31 d2 xor %edx,%edx
20d: 8d 76 00 lea 0x0(%esi),%esi
210: 83 c2 01 add $0x1,%edx
213: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
217: 89 d0 mov %edx,%eax
219: 75 f5 jne 210 <strlen+0x10>
;
return n;
}
21b: 5d pop %ebp
21c: c3 ret
21d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
220: 31 c0 xor %eax,%eax
}
222: 5d pop %ebp
223: c3 ret
224: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
22b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
22f: 90 nop
00000230 <memset>:
void*
memset(void *dst, int c, uint n)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 57 push %edi
234: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
237: 8b 4d 10 mov 0x10(%ebp),%ecx
23a: 8b 45 0c mov 0xc(%ebp),%eax
23d: 89 d7 mov %edx,%edi
23f: fc cld
240: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
242: 89 d0 mov %edx,%eax
244: 5f pop %edi
245: 5d pop %ebp
246: c3 ret
247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
24e: 66 90 xchg %ax,%ax
00000250 <strchr>:
char*
strchr(const char *s, char c)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 53 push %ebx
254: 8b 45 08 mov 0x8(%ebp),%eax
257: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
25a: 0f b6 18 movzbl (%eax),%ebx
25d: 84 db test %bl,%bl
25f: 74 1d je 27e <strchr+0x2e>
261: 89 d1 mov %edx,%ecx
if(*s == c)
263: 38 d3 cmp %dl,%bl
265: 75 0d jne 274 <strchr+0x24>
267: eb 17 jmp 280 <strchr+0x30>
269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
270: 38 ca cmp %cl,%dl
272: 74 0c je 280 <strchr+0x30>
for(; *s; s++)
274: 83 c0 01 add $0x1,%eax
277: 0f b6 10 movzbl (%eax),%edx
27a: 84 d2 test %dl,%dl
27c: 75 f2 jne 270 <strchr+0x20>
return (char*)s;
return 0;
27e: 31 c0 xor %eax,%eax
}
280: 5b pop %ebx
281: 5d pop %ebp
282: c3 ret
283: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
28a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000290 <gets>:
char*
gets(char *buf, int max)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 57 push %edi
294: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
295: 31 f6 xor %esi,%esi
{
297: 53 push %ebx
298: 89 f3 mov %esi,%ebx
29a: 83 ec 1c sub $0x1c,%esp
29d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
2a0: eb 2f jmp 2d1 <gets+0x41>
2a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
2a8: 83 ec 04 sub $0x4,%esp
2ab: 8d 45 e7 lea -0x19(%ebp),%eax
2ae: 6a 01 push $0x1
2b0: 50 push %eax
2b1: 6a 00 push $0x0
2b3: e8 31 01 00 00 call 3e9 <read>
if(cc < 1)
2b8: 83 c4 10 add $0x10,%esp
2bb: 85 c0 test %eax,%eax
2bd: 7e 1c jle 2db <gets+0x4b>
break;
buf[i++] = c;
2bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
2c3: 83 c7 01 add $0x1,%edi
2c6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
2c9: 3c 0a cmp $0xa,%al
2cb: 74 23 je 2f0 <gets+0x60>
2cd: 3c 0d cmp $0xd,%al
2cf: 74 1f je 2f0 <gets+0x60>
for(i=0; i+1 < max; ){
2d1: 83 c3 01 add $0x1,%ebx
2d4: 89 fe mov %edi,%esi
2d6: 3b 5d 0c cmp 0xc(%ebp),%ebx
2d9: 7c cd jl 2a8 <gets+0x18>
2db: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
2dd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2e0: c6 03 00 movb $0x0,(%ebx)
}
2e3: 8d 65 f4 lea -0xc(%ebp),%esp
2e6: 5b pop %ebx
2e7: 5e pop %esi
2e8: 5f pop %edi
2e9: 5d pop %ebp
2ea: c3 ret
2eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2ef: 90 nop
2f0: 8b 75 08 mov 0x8(%ebp),%esi
2f3: 8b 45 08 mov 0x8(%ebp),%eax
2f6: 01 de add %ebx,%esi
2f8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2fa: c6 03 00 movb $0x0,(%ebx)
}
2fd: 8d 65 f4 lea -0xc(%ebp),%esp
300: 5b pop %ebx
301: 5e pop %esi
302: 5f pop %edi
303: 5d pop %ebp
304: c3 ret
305: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
30c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000310 <stat>:
int
stat(const char *n, struct stat *st)
{
310: 55 push %ebp
311: 89 e5 mov %esp,%ebp
313: 56 push %esi
314: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
315: 83 ec 08 sub $0x8,%esp
318: 6a 00 push $0x0
31a: ff 75 08 pushl 0x8(%ebp)
31d: e8 ef 00 00 00 call 411 <open>
if(fd < 0)
322: 83 c4 10 add $0x10,%esp
325: 85 c0 test %eax,%eax
327: 78 27 js 350 <stat+0x40>
return -1;
r = fstat(fd, st);
329: 83 ec 08 sub $0x8,%esp
32c: ff 75 0c pushl 0xc(%ebp)
32f: 89 c3 mov %eax,%ebx
331: 50 push %eax
332: e8 f2 00 00 00 call 429 <fstat>
close(fd);
337: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
33a: 89 c6 mov %eax,%esi
close(fd);
33c: e8 b8 00 00 00 call 3f9 <close>
return r;
341: 83 c4 10 add $0x10,%esp
}
344: 8d 65 f8 lea -0x8(%ebp),%esp
347: 89 f0 mov %esi,%eax
349: 5b pop %ebx
34a: 5e pop %esi
34b: 5d pop %ebp
34c: c3 ret
34d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
350: be ff ff ff ff mov $0xffffffff,%esi
355: eb ed jmp 344 <stat+0x34>
357: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
35e: 66 90 xchg %ax,%ax
00000360 <atoi>:
int
atoi(const char *s)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 53 push %ebx
364: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
367: 0f be 11 movsbl (%ecx),%edx
36a: 8d 42 d0 lea -0x30(%edx),%eax
36d: 3c 09 cmp $0x9,%al
n = 0;
36f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
374: 77 1f ja 395 <atoi+0x35>
376: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
37d: 8d 76 00 lea 0x0(%esi),%esi
n = n*10 + *s++ - '0';
380: 83 c1 01 add $0x1,%ecx
383: 8d 04 80 lea (%eax,%eax,4),%eax
386: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
38a: 0f be 11 movsbl (%ecx),%edx
38d: 8d 5a d0 lea -0x30(%edx),%ebx
390: 80 fb 09 cmp $0x9,%bl
393: 76 eb jbe 380 <atoi+0x20>
return n;
}
395: 5b pop %ebx
396: 5d pop %ebp
397: c3 ret
398: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
39f: 90 nop
000003a0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 57 push %edi
3a4: 8b 55 10 mov 0x10(%ebp),%edx
3a7: 8b 45 08 mov 0x8(%ebp),%eax
3aa: 56 push %esi
3ab: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3ae: 85 d2 test %edx,%edx
3b0: 7e 13 jle 3c5 <memmove+0x25>
3b2: 01 c2 add %eax,%edx
dst = vdst;
3b4: 89 c7 mov %eax,%edi
3b6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3bd: 8d 76 00 lea 0x0(%esi),%esi
*dst++ = *src++;
3c0: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
3c1: 39 fa cmp %edi,%edx
3c3: 75 fb jne 3c0 <memmove+0x20>
return vdst;
}
3c5: 5e pop %esi
3c6: 5f pop %edi
3c7: 5d pop %ebp
3c8: c3 ret
000003c9 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3c9: b8 01 00 00 00 mov $0x1,%eax
3ce: cd 40 int $0x40
3d0: c3 ret
000003d1 <exit>:
SYSCALL(exit)
3d1: b8 02 00 00 00 mov $0x2,%eax
3d6: cd 40 int $0x40
3d8: c3 ret
000003d9 <wait>:
SYSCALL(wait)
3d9: b8 03 00 00 00 mov $0x3,%eax
3de: cd 40 int $0x40
3e0: c3 ret
000003e1 <pipe>:
SYSCALL(pipe)
3e1: b8 04 00 00 00 mov $0x4,%eax
3e6: cd 40 int $0x40
3e8: c3 ret
000003e9 <read>:
SYSCALL(read)
3e9: b8 05 00 00 00 mov $0x5,%eax
3ee: cd 40 int $0x40
3f0: c3 ret
000003f1 <write>:
SYSCALL(write)
3f1: b8 10 00 00 00 mov $0x10,%eax
3f6: cd 40 int $0x40
3f8: c3 ret
000003f9 <close>:
SYSCALL(close)
3f9: b8 15 00 00 00 mov $0x15,%eax
3fe: cd 40 int $0x40
400: c3 ret
00000401 <kill>:
SYSCALL(kill)
401: b8 06 00 00 00 mov $0x6,%eax
406: cd 40 int $0x40
408: c3 ret
00000409 <exec>:
SYSCALL(exec)
409: b8 07 00 00 00 mov $0x7,%eax
40e: cd 40 int $0x40
410: c3 ret
00000411 <open>:
SYSCALL(open)
411: b8 0f 00 00 00 mov $0xf,%eax
416: cd 40 int $0x40
418: c3 ret
00000419 <mknod>:
SYSCALL(mknod)
419: b8 11 00 00 00 mov $0x11,%eax
41e: cd 40 int $0x40
420: c3 ret
00000421 <unlink>:
SYSCALL(unlink)
421: b8 12 00 00 00 mov $0x12,%eax
426: cd 40 int $0x40
428: c3 ret
00000429 <fstat>:
SYSCALL(fstat)
429: b8 08 00 00 00 mov $0x8,%eax
42e: cd 40 int $0x40
430: c3 ret
00000431 <link>:
SYSCALL(link)
431: b8 13 00 00 00 mov $0x13,%eax
436: cd 40 int $0x40
438: c3 ret
00000439 <mkdir>:
SYSCALL(mkdir)
439: b8 14 00 00 00 mov $0x14,%eax
43e: cd 40 int $0x40
440: c3 ret
00000441 <chdir>:
SYSCALL(chdir)
441: b8 09 00 00 00 mov $0x9,%eax
446: cd 40 int $0x40
448: c3 ret
00000449 <dup>:
SYSCALL(dup)
449: b8 0a 00 00 00 mov $0xa,%eax
44e: cd 40 int $0x40
450: c3 ret
00000451 <getpid>:
SYSCALL(getpid)
451: b8 0b 00 00 00 mov $0xb,%eax
456: cd 40 int $0x40
458: c3 ret
00000459 <sbrk>:
SYSCALL(sbrk)
459: b8 0c 00 00 00 mov $0xc,%eax
45e: cd 40 int $0x40
460: c3 ret
00000461 <sleep>:
SYSCALL(sleep)
461: b8 0d 00 00 00 mov $0xd,%eax
466: cd 40 int $0x40
468: c3 ret
00000469 <uptime>:
SYSCALL(uptime)
469: b8 0e 00 00 00 mov $0xe,%eax
46e: cd 40 int $0x40
470: c3 ret
00000471 <waitx>:
SYSCALL(waitx)
471: b8 16 00 00 00 mov $0x16,%eax
476: cd 40 int $0x40
478: c3 ret
00000479 <cps>:
SYSCALL(cps)
479: b8 17 00 00 00 mov $0x17,%eax
47e: cd 40 int $0x40
480: c3 ret
00000481 <set_priority>:
SYSCALL(set_priority)
481: b8 18 00 00 00 mov $0x18,%eax
486: cd 40 int $0x40
488: c3 ret
00000489 <getpinfo>:
489: b8 19 00 00 00 mov $0x19,%eax
48e: cd 40 int $0x40
490: c3 ret
491: 66 90 xchg %ax,%ax
493: 66 90 xchg %ax,%ax
495: 66 90 xchg %ax,%ax
497: 66 90 xchg %ax,%ax
499: 66 90 xchg %ax,%ax
49b: 66 90 xchg %ax,%ax
49d: 66 90 xchg %ax,%ax
49f: 90 nop
000004a0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
4a0: 55 push %ebp
4a1: 89 e5 mov %esp,%ebp
4a3: 57 push %edi
4a4: 56 push %esi
4a5: 53 push %ebx
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
4a6: 89 d3 mov %edx,%ebx
{
4a8: 83 ec 3c sub $0x3c,%esp
4ab: 89 45 bc mov %eax,-0x44(%ebp)
if(sgn && xx < 0){
4ae: 85 d2 test %edx,%edx
4b0: 0f 89 92 00 00 00 jns 548 <printint+0xa8>
4b6: f6 45 08 01 testb $0x1,0x8(%ebp)
4ba: 0f 84 88 00 00 00 je 548 <printint+0xa8>
neg = 1;
4c0: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp)
x = -xx;
4c7: f7 db neg %ebx
} else {
x = xx;
}
i = 0;
4c9: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
4d0: 8d 75 d7 lea -0x29(%ebp),%esi
4d3: eb 08 jmp 4dd <printint+0x3d>
4d5: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
4d8: 89 7d c4 mov %edi,-0x3c(%ebp)
}while((x /= base) != 0);
4db: 89 c3 mov %eax,%ebx
buf[i++] = digits[x % base];
4dd: 89 d8 mov %ebx,%eax
4df: 31 d2 xor %edx,%edx
4e1: 8b 7d c4 mov -0x3c(%ebp),%edi
4e4: f7 f1 div %ecx
4e6: 83 c7 01 add $0x1,%edi
4e9: 0f b6 92 08 09 00 00 movzbl 0x908(%edx),%edx
4f0: 88 14 3e mov %dl,(%esi,%edi,1)
}while((x /= base) != 0);
4f3: 39 d9 cmp %ebx,%ecx
4f5: 76 e1 jbe 4d8 <printint+0x38>
if(neg)
4f7: 8b 45 c0 mov -0x40(%ebp),%eax
4fa: 85 c0 test %eax,%eax
4fc: 74 0d je 50b <printint+0x6b>
buf[i++] = '-';
4fe: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
503: ba 2d 00 00 00 mov $0x2d,%edx
buf[i++] = digits[x % base];
508: 89 7d c4 mov %edi,-0x3c(%ebp)
50b: 8b 45 c4 mov -0x3c(%ebp),%eax
50e: 8b 7d bc mov -0x44(%ebp),%edi
511: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
515: eb 0f jmp 526 <printint+0x86>
517: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
51e: 66 90 xchg %ax,%ax
520: 0f b6 13 movzbl (%ebx),%edx
523: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
526: 83 ec 04 sub $0x4,%esp
529: 88 55 d7 mov %dl,-0x29(%ebp)
52c: 6a 01 push $0x1
52e: 56 push %esi
52f: 57 push %edi
530: e8 bc fe ff ff call 3f1 <write>
while(--i >= 0)
535: 83 c4 10 add $0x10,%esp
538: 39 de cmp %ebx,%esi
53a: 75 e4 jne 520 <printint+0x80>
putc(fd, buf[i]);
}
53c: 8d 65 f4 lea -0xc(%ebp),%esp
53f: 5b pop %ebx
540: 5e pop %esi
541: 5f pop %edi
542: 5d pop %ebp
543: c3 ret
544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
548: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp)
54f: e9 75 ff ff ff jmp 4c9 <printint+0x29>
554: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
55b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
55f: 90 nop
00000560 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
560: 55 push %ebp
561: 89 e5 mov %esp,%ebp
563: 57 push %edi
564: 56 push %esi
565: 53 push %ebx
566: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
569: 8b 75 0c mov 0xc(%ebp),%esi
56c: 0f b6 1e movzbl (%esi),%ebx
56f: 84 db test %bl,%bl
571: 0f 84 b9 00 00 00 je 630 <printf+0xd0>
ap = (uint*)(void*)&fmt + 1;
577: 8d 45 10 lea 0x10(%ebp),%eax
57a: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
57d: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
580: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
582: 89 45 d0 mov %eax,-0x30(%ebp)
585: eb 38 jmp 5bf <printf+0x5f>
587: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
58e: 66 90 xchg %ax,%ax
590: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
593: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
598: 83 f8 25 cmp $0x25,%eax
59b: 74 17 je 5b4 <printf+0x54>
write(fd, &c, 1);
59d: 83 ec 04 sub $0x4,%esp
5a0: 88 5d e7 mov %bl,-0x19(%ebp)
5a3: 6a 01 push $0x1
5a5: 57 push %edi
5a6: ff 75 08 pushl 0x8(%ebp)
5a9: e8 43 fe ff ff call 3f1 <write>
5ae: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
5b1: 83 c4 10 add $0x10,%esp
5b4: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
5b7: 0f b6 5e ff movzbl -0x1(%esi),%ebx
5bb: 84 db test %bl,%bl
5bd: 74 71 je 630 <printf+0xd0>
c = fmt[i] & 0xff;
5bf: 0f be cb movsbl %bl,%ecx
5c2: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
5c5: 85 d2 test %edx,%edx
5c7: 74 c7 je 590 <printf+0x30>
}
} else if(state == '%'){
5c9: 83 fa 25 cmp $0x25,%edx
5cc: 75 e6 jne 5b4 <printf+0x54>
if(c == 'd'){
5ce: 83 f8 64 cmp $0x64,%eax
5d1: 0f 84 99 00 00 00 je 670 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
5d7: 81 e1 f7 00 00 00 and $0xf7,%ecx
5dd: 83 f9 70 cmp $0x70,%ecx
5e0: 74 5e je 640 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
5e2: 83 f8 73 cmp $0x73,%eax
5e5: 0f 84 d5 00 00 00 je 6c0 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
5eb: 83 f8 63 cmp $0x63,%eax
5ee: 0f 84 8c 00 00 00 je 680 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
5f4: 83 f8 25 cmp $0x25,%eax
5f7: 0f 84 b3 00 00 00 je 6b0 <printf+0x150>
write(fd, &c, 1);
5fd: 83 ec 04 sub $0x4,%esp
600: c6 45 e7 25 movb $0x25,-0x19(%ebp)
604: 6a 01 push $0x1
606: 57 push %edi
607: ff 75 08 pushl 0x8(%ebp)
60a: e8 e2 fd ff ff call 3f1 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
60f: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
612: 83 c4 0c add $0xc,%esp
615: 6a 01 push $0x1
617: 83 c6 01 add $0x1,%esi
61a: 57 push %edi
61b: ff 75 08 pushl 0x8(%ebp)
61e: e8 ce fd ff ff call 3f1 <write>
for(i = 0; fmt[i]; i++){
623: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
627: 83 c4 10 add $0x10,%esp
}
state = 0;
62a: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
62c: 84 db test %bl,%bl
62e: 75 8f jne 5bf <printf+0x5f>
}
}
}
630: 8d 65 f4 lea -0xc(%ebp),%esp
633: 5b pop %ebx
634: 5e pop %esi
635: 5f pop %edi
636: 5d pop %ebp
637: c3 ret
638: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
63f: 90 nop
printint(fd, *ap, 16, 0);
640: 83 ec 0c sub $0xc,%esp
643: b9 10 00 00 00 mov $0x10,%ecx
648: 6a 00 push $0x0
64a: 8b 5d d0 mov -0x30(%ebp),%ebx
64d: 8b 45 08 mov 0x8(%ebp),%eax
650: 8b 13 mov (%ebx),%edx
652: e8 49 fe ff ff call 4a0 <printint>
ap++;
657: 89 d8 mov %ebx,%eax
659: 83 c4 10 add $0x10,%esp
state = 0;
65c: 31 d2 xor %edx,%edx
ap++;
65e: 83 c0 04 add $0x4,%eax
661: 89 45 d0 mov %eax,-0x30(%ebp)
664: e9 4b ff ff ff jmp 5b4 <printf+0x54>
669: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
670: 83 ec 0c sub $0xc,%esp
673: b9 0a 00 00 00 mov $0xa,%ecx
678: 6a 01 push $0x1
67a: eb ce jmp 64a <printf+0xea>
67c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
680: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
683: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
686: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
688: 6a 01 push $0x1
ap++;
68a: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
68d: 57 push %edi
68e: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
691: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
694: e8 58 fd ff ff call 3f1 <write>
ap++;
699: 89 5d d0 mov %ebx,-0x30(%ebp)
69c: 83 c4 10 add $0x10,%esp
state = 0;
69f: 31 d2 xor %edx,%edx
6a1: e9 0e ff ff ff jmp 5b4 <printf+0x54>
6a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6ad: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
6b0: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
6b3: 83 ec 04 sub $0x4,%esp
6b6: e9 5a ff ff ff jmp 615 <printf+0xb5>
6bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
6bf: 90 nop
s = (char*)*ap;
6c0: 8b 45 d0 mov -0x30(%ebp),%eax
6c3: 8b 18 mov (%eax),%ebx
ap++;
6c5: 83 c0 04 add $0x4,%eax
6c8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
6cb: 85 db test %ebx,%ebx
6cd: 74 17 je 6e6 <printf+0x186>
while(*s != 0){
6cf: 0f b6 03 movzbl (%ebx),%eax
state = 0;
6d2: 31 d2 xor %edx,%edx
while(*s != 0){
6d4: 84 c0 test %al,%al
6d6: 0f 84 d8 fe ff ff je 5b4 <printf+0x54>
6dc: 89 75 d4 mov %esi,-0x2c(%ebp)
6df: 89 de mov %ebx,%esi
6e1: 8b 5d 08 mov 0x8(%ebp),%ebx
6e4: eb 1a jmp 700 <printf+0x1a0>
s = "(null)";
6e6: bb ff 08 00 00 mov $0x8ff,%ebx
while(*s != 0){
6eb: 89 75 d4 mov %esi,-0x2c(%ebp)
6ee: b8 28 00 00 00 mov $0x28,%eax
6f3: 89 de mov %ebx,%esi
6f5: 8b 5d 08 mov 0x8(%ebp),%ebx
6f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6ff: 90 nop
write(fd, &c, 1);
700: 83 ec 04 sub $0x4,%esp
s++;
703: 83 c6 01 add $0x1,%esi
706: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
709: 6a 01 push $0x1
70b: 57 push %edi
70c: 53 push %ebx
70d: e8 df fc ff ff call 3f1 <write>
while(*s != 0){
712: 0f b6 06 movzbl (%esi),%eax
715: 83 c4 10 add $0x10,%esp
718: 84 c0 test %al,%al
71a: 75 e4 jne 700 <printf+0x1a0>
71c: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
71f: 31 d2 xor %edx,%edx
721: e9 8e fe ff ff jmp 5b4 <printf+0x54>
726: 66 90 xchg %ax,%ax
728: 66 90 xchg %ax,%ax
72a: 66 90 xchg %ax,%ax
72c: 66 90 xchg %ax,%ax
72e: 66 90 xchg %ax,%ax
00000730 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
730: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
731: a1 00 0c 00 00 mov 0xc00,%eax
{
736: 89 e5 mov %esp,%ebp
738: 57 push %edi
739: 56 push %esi
73a: 53 push %ebx
73b: 8b 5d 08 mov 0x8(%ebp),%ebx
73e: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
740: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
743: 39 c8 cmp %ecx,%eax
745: 73 19 jae 760 <free+0x30>
747: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
74e: 66 90 xchg %ax,%ax
750: 39 d1 cmp %edx,%ecx
752: 72 14 jb 768 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
754: 39 d0 cmp %edx,%eax
756: 73 10 jae 768 <free+0x38>
{
758: 89 d0 mov %edx,%eax
75a: 8b 10 mov (%eax),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
75c: 39 c8 cmp %ecx,%eax
75e: 72 f0 jb 750 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
760: 39 d0 cmp %edx,%eax
762: 72 f4 jb 758 <free+0x28>
764: 39 d1 cmp %edx,%ecx
766: 73 f0 jae 758 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
768: 8b 73 fc mov -0x4(%ebx),%esi
76b: 8d 3c f1 lea (%ecx,%esi,8),%edi
76e: 39 fa cmp %edi,%edx
770: 74 1e je 790 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
772: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
775: 8b 50 04 mov 0x4(%eax),%edx
778: 8d 34 d0 lea (%eax,%edx,8),%esi
77b: 39 f1 cmp %esi,%ecx
77d: 74 28 je 7a7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
77f: 89 08 mov %ecx,(%eax)
freep = p;
}
781: 5b pop %ebx
freep = p;
782: a3 00 0c 00 00 mov %eax,0xc00
}
787: 5e pop %esi
788: 5f pop %edi
789: 5d pop %ebp
78a: c3 ret
78b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
78f: 90 nop
bp->s.size += p->s.ptr->s.size;
790: 03 72 04 add 0x4(%edx),%esi
793: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
796: 8b 10 mov (%eax),%edx
798: 8b 12 mov (%edx),%edx
79a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
79d: 8b 50 04 mov 0x4(%eax),%edx
7a0: 8d 34 d0 lea (%eax,%edx,8),%esi
7a3: 39 f1 cmp %esi,%ecx
7a5: 75 d8 jne 77f <free+0x4f>
p->s.size += bp->s.size;
7a7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
7aa: a3 00 0c 00 00 mov %eax,0xc00
p->s.size += bp->s.size;
7af: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7b2: 8b 53 f8 mov -0x8(%ebx),%edx
7b5: 89 10 mov %edx,(%eax)
}
7b7: 5b pop %ebx
7b8: 5e pop %esi
7b9: 5f pop %edi
7ba: 5d pop %ebp
7bb: c3 ret
7bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000007c0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
7c0: 55 push %ebp
7c1: 89 e5 mov %esp,%ebp
7c3: 57 push %edi
7c4: 56 push %esi
7c5: 53 push %ebx
7c6: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7c9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
7cc: 8b 3d 00 0c 00 00 mov 0xc00,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7d2: 8d 70 07 lea 0x7(%eax),%esi
7d5: c1 ee 03 shr $0x3,%esi
7d8: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
7db: 85 ff test %edi,%edi
7dd: 0f 84 ad 00 00 00 je 890 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7e3: 8b 17 mov (%edi),%edx
if(p->s.size >= nunits){
7e5: 8b 4a 04 mov 0x4(%edx),%ecx
7e8: 39 f1 cmp %esi,%ecx
7ea: 73 72 jae 85e <malloc+0x9e>
7ec: 81 fe 00 10 00 00 cmp $0x1000,%esi
7f2: bb 00 10 00 00 mov $0x1000,%ebx
7f7: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
7fa: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
801: 89 45 e4 mov %eax,-0x1c(%ebp)
804: eb 1b jmp 821 <malloc+0x61>
806: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
80d: 8d 76 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
810: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
812: 8b 48 04 mov 0x4(%eax),%ecx
815: 39 f1 cmp %esi,%ecx
817: 73 4f jae 868 <malloc+0xa8>
819: 8b 3d 00 0c 00 00 mov 0xc00,%edi
81f: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
821: 39 d7 cmp %edx,%edi
823: 75 eb jne 810 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
825: 83 ec 0c sub $0xc,%esp
828: ff 75 e4 pushl -0x1c(%ebp)
82b: e8 29 fc ff ff call 459 <sbrk>
if(p == (char*)-1)
830: 83 c4 10 add $0x10,%esp
833: 83 f8 ff cmp $0xffffffff,%eax
836: 74 1c je 854 <malloc+0x94>
hp->s.size = nu;
838: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
83b: 83 ec 0c sub $0xc,%esp
83e: 83 c0 08 add $0x8,%eax
841: 50 push %eax
842: e8 e9 fe ff ff call 730 <free>
return freep;
847: 8b 15 00 0c 00 00 mov 0xc00,%edx
if((p = morecore(nunits)) == 0)
84d: 83 c4 10 add $0x10,%esp
850: 85 d2 test %edx,%edx
852: 75 bc jne 810 <malloc+0x50>
return 0;
}
}
854: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
857: 31 c0 xor %eax,%eax
}
859: 5b pop %ebx
85a: 5e pop %esi
85b: 5f pop %edi
85c: 5d pop %ebp
85d: c3 ret
if(p->s.size >= nunits){
85e: 89 d0 mov %edx,%eax
860: 89 fa mov %edi,%edx
862: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
868: 39 ce cmp %ecx,%esi
86a: 74 54 je 8c0 <malloc+0x100>
p->s.size -= nunits;
86c: 29 f1 sub %esi,%ecx
86e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
871: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
874: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
877: 89 15 00 0c 00 00 mov %edx,0xc00
}
87d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
880: 83 c0 08 add $0x8,%eax
}
883: 5b pop %ebx
884: 5e pop %esi
885: 5f pop %edi
886: 5d pop %ebp
887: c3 ret
888: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
88f: 90 nop
base.s.ptr = freep = prevp = &base;
890: c7 05 00 0c 00 00 04 movl $0xc04,0xc00
897: 0c 00 00
base.s.size = 0;
89a: bf 04 0c 00 00 mov $0xc04,%edi
base.s.ptr = freep = prevp = &base;
89f: c7 05 04 0c 00 00 04 movl $0xc04,0xc04
8a6: 0c 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
8a9: 89 fa mov %edi,%edx
base.s.size = 0;
8ab: c7 05 08 0c 00 00 00 movl $0x0,0xc08
8b2: 00 00 00
if(p->s.size >= nunits){
8b5: e9 32 ff ff ff jmp 7ec <malloc+0x2c>
8ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
8c0: 8b 08 mov (%eax),%ecx
8c2: 89 0a mov %ecx,(%edx)
8c4: eb b1 jmp 877 <malloc+0xb7>
|
y2s2/csa/practicals/prac-9-strings/1-demo.asm | ouldevloper/university | 8 | 95560 | ; 1-demo.asm
; copy a string into an array and display it
.MODEL SMALL
.STACK 100
.DATA
PROMPT DB "ENTER A FRUIT: $"
STR LABEL BYTE
MAXN DB 20
ACTN DB ?
ACTSTR DB 20 DUP("$")
NL DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
MOV AH, 09H
LEA DX, PROMPT
INT 21H
MOV AH, 0AH
LEA DX, STR
INT 21H
CALL NEWL
MOV AH, 09H
LEA DX, ACTSTR
INT 21H
MOV AX,4C00H
INT 21H
MAIN ENDP
NEWL PROC
MOV AH, 09H
LEA DX, NL
INT 21H
RET
NEWL ENDP
END MAIN |
loaders_patches_etc/init_basil.asm | alexanderbazhenoff/zx-spectrum-various | 0 | 12956 | <filename>loaders_patches_etc/init_basil.asm
ORG 26000
DI
LD HL,TABL
LD DE,#5B00
LD BC,#FF
LDIR
LD SP,26000
LD HL,#FF10
LD E,#11
LD BC,#7FFD
OUT (C),L
LD (HL),L
OUT (C),E
LD (HL),E
OUT (C),L
LD A,(HL)
CP E
JP Z,MODE48
LD HL,#5B00
LD B,4
LOADM PUSH BC
PUSH HL
LD A,(HL)
INC L
LD B,(HL)
INC L
LD C,(HL)
INC L
PUSH AF
PUSH HL
LD H,C
CALL LOAD128
POP HL
POP AF
LD A,(HL)
INC L
LD B,(HL)
INC L
LD C,(HL)
LD H,C
CALL LOAD128
POP HL
LD DE,#10
ADD HL,DE
POP BC
DJNZ LOADM
LD BC,#7FFD
LD A,#10
OUT (C),A
LD HL,LEV128
LD DE,#AE10
LD BC,#99
LDIR
CALL FADE
DI
CALL #C000
XOR A
CALL LEV128_
START XOR A
LD B,A
BRDM PUSH BC
LD A,B
LD (PAUPAR+1),A
LD L,#40
LD A,R
AND #3F
LD H,A
BRD LD A,R
XOR (HL)
OUT (#FE),A
XOR A
OUT (#FE),A
LD A,R
XOR (HL)
PAUPAR AND 0
LD B,A
INC B
PAUSB DJNZ PAUSB
DEC L
JR NZ,BRD
POP BC
INC B
INC B
INC B
JR NZ,BRDM
LD HL,54784
PUSH HL
LD DE,#FC00
LD BC,#400
PUSH BC
LDIR
POP BC
POP HL
PUSH HL
POP DE
INC DE
LD (HL),C
LDIR
LD A,200
LD (23607),A
LD SP,27000
JP #8000
MODE48 LD IX,#5B00
LD B,4
LD DE,(#5CF4)
LOAD48L PUSH BC
LD B,(IX+1)
LD (IX),E
LD (IX+2),D
CALL ADDSEC
LD B,(IX+4)
CALL ADDSEC
LD BC,#10
ADD IX,BC
POP BC
DJNZ LOAD48L
LD HL,LOAD48
LD DE,#AE10
LD BC,#99
LDIR
EI
CALL FADE
CALL #C000
DI
XOR A
CALL LOADL4_
LD HL,LEVEL
LD (#5B47),HL
LD HL,FINAL
LD (#5B44),HL
LD HL,#8D22
LD (#AEFF),HL
JP START
ADDSEC INC E
BIT 4,E
JR Z,NONTRK
LD E,0
INC D
NONTRK DJNZ ADDSEC
RET
LOAD48
DISP #AE10
LOADL48 LD A,(#8069)
LOADL4_ CALL DAT128L
LD E,(HL)
INC L
LD B,(HL)
INC L
LD D,(HL)
INC L
INC L
PUSH HL
LADR1 LD H,#B0
CALL LOAD
POP HL
LD B,(HL)
LADR2 LD H,#E4
CALL LOAD
CALL CLS11
CALL CLS11
CALL CLS111
CALL CLS_S
RET
LEVEL LD A,#B0
LD (LADR1+1),A
LD A,#E4
JR LLEV48
FINAL LD A,#D0
LD (LADR1+1),A
LD A,#B0
LLEV48 LD (LADR2+1),A
PUSH HL
PUSH BC
PUSH DE
EXX
EX AF,AF'
PUSH HL
PUSH DE
PUSH BC
PUSH AF
PUSH IY
LD A,I
PUSH AF
LD A,#3F
IM 1
LD IY,#5C3A
LD HL,#2758
EXX
PPLOAD CALL LOADL48
EXX
POP AF
LD I,A
IM 2
POP IY
POP AF
POP BC
POP DE
POP HL
EX AF,AF'
EXX
POP DE
POP BC
POP HL
RET
ENT
FADE
INCLUDE "$FADE0"
RET
LOAD128 DI
PUSH BC
LD BC,#7FFD
OUT (C),A
POP BC
LD C,5
LD L,0
LD DE,(#5CF4)
LOAD12_ PUSH BC
PUSH DE
PUSH HL
CALL LL_3D13
DI
POP HL
POP DE
POP BC
LD A,(23823)
OR A
JR NZ,LOAD12_
RET
LL_3D13 LD (REG_A+1),A
PUSH HL
LD HL,(23613)
LD (ERR+1),HL
LD HL,DRIA
LD (#5CC3),HL
LD HL,ERR
EX (SP),HL
LD (23613),SP
EX AF,AF'
LD A,#C3
LD (#5CC2),A
XOR A
LD (23823),A
LD (23824),A
LD (SP2),SP
REG_A LD A,#C3
JP #3D13
D_ERR LD SP,#3131
SP2 EQU $-2
LD (23823),A
ERR LD HL,#2121
LD (23613),A
LD A,#C9
LD (#5CC2),A
RET
DRIA EX (SP),HL
PUSH AF
LD A,H
CP 13
JR Z,RIA
XOR A
OR H
JR Z,NO_ERR
NO_ERR POP AF
EX (SP),HL
RET
RIA POP HL
POP HL
POP HL
XOR A
LD (23560),A
LD A,2
OUT (#FE),A
LD A,"R"
LD HL,#3F7E
EX (SP),HL
JP #3D2F
TABL
DISP #5B00
DEFB #11,#0B,#C1,#11,#12,#CC
INCBIN "LEVEL10"
DEFB #11,#0D,#DF,#11,#11,#ED
INCBIN "LEVEL20"
DEFB #13,#0C,#C1,#13,#12,#CD
INCBIN "LEVEL30"
DEFB #13,#08,#DF,#13,#08,#E7
INCBIN "LEVEL40"
HEAD JP LEV128H
LOADLEV JP #AE3B
LOADFC JP #AE10
DAT128L ADD A,A
ADD A,A
ADD A,A
ADD A,A
LD HL,#5B00
LD E,A
LD D,L
ADD HL,DE
RET
LEV128H CALL DAT128L
INC HL
INC HL
INC HL
INC HL
INC HL
INC HL
INC HL
LD DE,#FFE0
LD BC,#0A
LDIR
RET
LL3D13 LD (REG_A+1),A
PUSH HL
LD HL,(23613)
LD (ERR1+1),HL
LD HL,DRIA1
LD (#5CC3),HL
LD HL,ERR1
EX (SP),HL
LD (23613),SP
EX AF,AF'
LD A,#C3
LD (#5CC2),A
XOR A
LD (23823),A
LD (23824),A
LD (SP21),SP
REG_A1 LD A,#C3
JP #3D13
D_ERR1 LD SP,#3131
SP21 EQU $-2
LD (23823),A
ERR1 LD HL,#2121
LD (23613),A
LD A,#C9
LD (#5CC2),A
RET
DRIA1 EX (SP),HL
PUSH AF
LD A,H
CP 13
JR Z,RIA1
XOR A
OR H
JR Z,NO_ERR1
NO_ERR1 POP AF
EX (SP),HL
RET
RIA1 POP HL
POP HL
POP HL
XOR A
LD (23560),A
LD A,2
OUT (#FE),A
LD A,"R"
LD HL,#3F7E
EX (SP),HL
JP #3D2F
CLS11 LD HL,#5800
CLS111 LD A,L
CLS_L1 LD (HL),A
INC L
JR NZ,CLS_L1
INC H
RET
CLS_S XOR A
LD HL,#4FFF
CLS_SL DEC HL
LD (HL),A
OR (HL)
JR Z,CLS_SL
RET
LOAD DI
LD C,5
LD L,0
PUSH HL
LD DE,(#5CF4)
LOAD_ PUSH BC
PUSH DE
PUSH HL
CALL LL3D13
DI
POP HL
POP DE
POP BC
LD A,(23823)
OR A
JR NZ,LOAD_
RET
ENT
LEV128
DISP #AE10
LEV128_
PUSH AF
CALL CLS
POP AF
LD IX,#B000
CALL DAT128L
LD A,(HL)
INC L
LD B,(HL)
INC L
LD C,(HL)
INC L
PUSH HL
LD H,C
CALL MOVLEV
POP HL
LD A,(HL)
INC L
LD B,(HL)
INC L
LD H,(HL)
LD IX,#E400
CALL MOVLEV
LD HL,#5900
CALL CLS1
RET
LEV128F
PUSH AF
CALL CLS
POP AF
LD IX,#D000
CALL DAT128L
LD A,(HL)
INC L
LD B,(HL)
INC L
LD C,(HL)
INC L
PUSH HL
LD H,C
CALL MOVLEV
POP HL
LD A,(HL)
INC L
LD B,(HL)
INC L
LD H,(HL)
LD IX,#B000
CALL MOVLEV
RET
MOVLEV PUSH IX
LD C,0
LD L,C
LD E,A
LD D,#10
MOVL_L PUSH BC
LD BC,#7FFD
OUT (C),E
LD A,(HL)
OUT (C),D
LD (IX),A
POP BC
INC HL
INC IX
DEC BC
LD A,B
OR C
JR NZ,MOVL_L
RET
CLS LD HL,#5800
CLS1 LD A,L
CLS_L LD (HL),A
INC L
JR NZ,CLS_L
RET
|
gcc-gcc-7_3_0-release/gcc/ada/spark_xrefs.adb | best08618/asylo | 7 | 5501 | <filename>gcc-gcc-7_3_0-release/gcc/ada/spark_xrefs.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S P A R K _ X R E F S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2011-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. 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 COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Output; use Output;
with Put_SPARK_Xrefs;
package body SPARK_Xrefs is
------------
-- dspark --
------------
procedure dspark is
begin
-- Dump SPARK cross-reference file table
Write_Line ("SPARK Xrefs File Table");
Write_Line ("----------------------");
for Index in 1 .. SPARK_File_Table.Last loop
declare
AFR : SPARK_File_Record renames SPARK_File_Table.Table (Index);
begin
Write_Str (" ");
Write_Int (Int (Index));
Write_Str (". File_Num = ");
Write_Int (Int (AFR.File_Num));
Write_Str (" File_Name = """);
if AFR.File_Name /= null then
Write_Str (AFR.File_Name.all);
end if;
Write_Char ('"');
Write_Str (" From = ");
Write_Int (Int (AFR.From_Scope));
Write_Str (" To = ");
Write_Int (Int (AFR.To_Scope));
Write_Eol;
end;
end loop;
-- Dump SPARK cross-reference scope table
Write_Eol;
Write_Line ("SPARK Xrefs Scope Table");
Write_Line ("-----------------------");
for Index in 1 .. SPARK_Scope_Table.Last loop
declare
ASR : SPARK_Scope_Record renames SPARK_Scope_Table.Table (Index);
begin
Write_Str (" ");
Write_Int (Int (Index));
Write_Str (". File_Num = ");
Write_Int (Int (ASR.File_Num));
Write_Str (" Scope_Num = ");
Write_Int (Int (ASR.Scope_Num));
Write_Str (" Scope_Name = """);
if ASR.Scope_Name /= null then
Write_Str (ASR.Scope_Name.all);
end if;
Write_Char ('"');
Write_Str (" Line = ");
Write_Int (Int (ASR.Line));
Write_Str (" Col = ");
Write_Int (Int (ASR.Col));
Write_Str (" Type = ");
Write_Char (ASR.Stype);
Write_Str (" From = ");
Write_Int (Int (ASR.From_Xref));
Write_Str (" To = ");
Write_Int (Int (ASR.To_Xref));
Write_Str (" Scope_Entity = ");
Write_Int (Int (ASR.Scope_Entity));
Write_Eol;
end;
end loop;
-- Dump SPARK cross-reference table
Write_Eol;
Write_Line ("SPARK Xref Table");
Write_Line ("----------------");
for Index in 1 .. SPARK_Xref_Table.Last loop
declare
AXR : SPARK_Xref_Record renames SPARK_Xref_Table.Table (Index);
begin
Write_Str (" ");
Write_Int (Int (Index));
Write_Str (". Entity_Name = """);
if AXR.Entity_Name /= null then
Write_Str (AXR.Entity_Name.all);
end if;
Write_Char ('"');
Write_Str (" Entity_Line = ");
Write_Int (Int (AXR.Entity_Line));
Write_Str (" Entity_Col = ");
Write_Int (Int (AXR.Entity_Col));
Write_Str (" File_Num = ");
Write_Int (Int (AXR.File_Num));
Write_Str (" Scope_Num = ");
Write_Int (Int (AXR.Scope_Num));
Write_Str (" Line = ");
Write_Int (Int (AXR.Line));
Write_Str (" Col = ");
Write_Int (Int (AXR.Col));
Write_Str (" Type = ");
Write_Char (AXR.Rtype);
Write_Eol;
end;
end loop;
end dspark;
----------------
-- Initialize --
----------------
procedure Initialize_SPARK_Tables is
begin
SPARK_File_Table.Init;
SPARK_Scope_Table.Init;
SPARK_Xref_Table.Init;
end Initialize_SPARK_Tables;
------------
-- pspark --
------------
procedure pspark is
procedure Write_Info_Char (C : Character) renames Write_Char;
-- Write one character
procedure Write_Info_Str (Val : String) renames Write_Str;
-- Write string
function Write_Info_Col return Positive;
-- Return next column for writing
procedure Write_Info_Initiate (Key : Character) renames Write_Char;
-- Start new one and write one character;
procedure Write_Info_Nat (N : Nat);
-- Write value of N
procedure Write_Info_Terminate renames Write_Eol;
-- Terminate current line
--------------------
-- Write_Info_Col --
--------------------
function Write_Info_Col return Positive is
begin
return Positive (Column);
end Write_Info_Col;
--------------------
-- Write_Info_Nat --
--------------------
procedure Write_Info_Nat (N : Nat) is
begin
Write_Int (N);
end Write_Info_Nat;
procedure Debug_Put_SPARK_Xrefs is new Put_SPARK_Xrefs;
-- Start of processing for pspark
begin
Debug_Put_SPARK_Xrefs;
end pspark;
end SPARK_Xrefs;
|
test1.asm | joncampbell123/minx86dec | 19 | 1707 | <filename>test1.asm<gh_stars>10-100
; 8086 test code
org 0
_start:
lea bx,[si+3]
lea cx,[bx+di+33h]
lea eax,[ebx+0x1234]
lea ebx,[esi*4+ecx+0x22]
; test implied SS register
mov [si],ax
mov [di],bx
mov [bp],dx
mov [bx],si
; test explicit segment override
mov [cs:si],ax
mov [ds:di],bx
mov [es:bp],dx
mov [ss:bx],si
; 486 decoder crash test
db 0xFF,0xE5,0x00,0x00
nop
nop
nop
add bl,[esp]
add bl,[a32 12345678h]
add bl,[a32 12345678h+edx+eax]
add bl,[ebp]
add bl,[ebp+42h]
add [esp],bl
add [a32 12345678h],bl
add [a32 12345678h+edx+eax],bl
add [ebp],bl
add [ebp+42h],bl
add bx,[esp]
add bx,[a32 12345678h]
add bx,[a32 12345678h+edx+eax]
add bx,[ebp]
add bx,[ebp+42h]
add [esp],bx
add [a32 12345678h],bx
add [a32 12345678h+edx+eax],bx
add [ebp],bx
add [ebp+42h],bx
add ebx,[esp]
add ebx,[a32 12345678h]
add ebx,[a32 12345678h+edx+eax]
add ebx,[ebp]
add ebx,[ebp+42h]
add [esp],ebx
add [a32 12345678h],ebx
add [a32 12345678h+edx+eax],ebx
add [ebp],ebx
add [ebp+42h],ebx
cmp bl,[esp]
cmp bl,[a32 12345678h]
cmp bl,[a32 12345678h+edx+eax]
cmp bl,[ebp]
cmp bl,[ebp+42h]
cmp [esp],bl
cmp [a32 12345678h],bl
cmp [a32 12345678h+edx+eax],bl
cmp [ebp],bl
cmp [ebp+42h],bl
cmp bx,[esp]
cmp bx,[a32 12345678h]
cmp bx,[a32 12345678h+edx+eax]
cmp bx,[ebp]
cmp bx,[ebp+42h]
cmp [esp],bx
cmp [a32 12345678h],bx
cmp [a32 12345678h+edx+eax],bx
cmp [ebp],bx
cmp [ebp+42h],bx
cmp ebx,[esp]
cmp ebx,[a32 12345678h]
cmp ebx,[a32 12345678h+edx+eax]
cmp ebx,[ebp]
cmp ebx,[ebp+42h]
cmp [esp],ebx
cmp [a32 12345678h],ebx
cmp [a32 12345678h+edx+eax],ebx
cmp [ebp],ebx
cmp [ebp+42h],ebx
idiv al
idiv ah
idiv ax
idiv bx
idiv eax
idiv ebx
idiv ecx
idiv edx
idiv esi
idiv edi
idiv word [eax]
idiv word [ebx]
idiv word [ecx]
idiv word [edx]
idiv word [esi]
idiv word [edi]
imul al
imul ah
imul ax
imul bx
imul eax
imul ebx
imul ecx
imul edx
imul esi
imul edi
imul word [eax]
imul word [ebx]
imul word [ecx]
imul word [edx]
imul word [esi]
imul word [edi]
nop
lea bx,[si+3]
lea cx,[bx+di+33h]
lea eax,[ebx+0x1234]
lea ebx,[esi*4+ecx+0x22]
mov ax,es
mov ds,ax
mov bx,cs
mov cs,bx
mov cx,ds
mov dx,ss
mov [di],es
mov [si],ds
test ax,bx
test si,cx
test cl,bh
test [di],bx
test [si+bx+43],cx
test bx,[di]
test cx,[si+bx+43]
xchg bl,dl
xchg [si],cl
xchg [di],si
cmp bl,44h
cmp bx,2446h
cmp cx,7Eh
cmp cx,0xFF99
cmp byte [bx+3],35h
cmp word [bp-3],2244h
cmp word [di],62h
mov ah,dh
mov bl,[si+bx+3]
mov si,[di+bx+34h]
inc ax
inc bx
inc cx
inc dx
inc si
inc di
inc bp
inc sp
dec sp
dec bp
dec di
dec si
dec dx
dec cx
dec bx
dec ax
push ax
push bx
push cx
push dx
pop dx
pop cx
pop bx
pop ax
jo j2
j2: jno j2
ja j2
jz j2
xchg ax,bx
xchg ax,cx
xchg ax,dx
xchg ax,si
mov al,13h
mov bl,44h
mov dh,11h
mov si,2456h
mov bp,2222h
daa
das
aaa
aas
add al,ah
add cl,bh
add bl,byte [345h]
add byte [123h],dh
adc bh,byte [bx+si]
sub si,word [si]
sub di,word [bp+di+0x1234]
add al,12h
add ax,1245h
mov al,[1234h]
mov ax,[5050h]
mov [1111h],al
mov [5421h],ax
mov ax,[cs:3]
mov [ss:4444h],ax
push cs
push es
pop cs
nop
nop
nop
nop
pop ds
mov cr0,eax
mov cr0,ebx
mov eax,cr0
mov cr2,eax
mov eax,cr2
mov dr0,eax
mov eax,dr0
mov dr3,eax
mov eax,dr3
mov tr0,eax
mov eax,tr0
mov tr3,eax
mov eax,tr3
salc
icebp
; 386/486 only
umov eax,ebx
umov [edi],ebx
umov esi,[edi]
umov al,cl
umov ah,[esi]
nop
nop
nop
db 0x0F,0x05 ; 286 loadall
nop
nop
nop
db 0x0F,0x07 ; 386 loadall
nop
nop
nop
movupd xmm0,xmm3
movupd [di],xmm3
movupd [edi],xmm3
movupd xmm3,[edi]
movupd xmm3,[di]
movups [edi],xmm6
movups xmm6,[edi]
movups xmm1,xmm4
movlpd [edi],xmm6
movlpd xmm6,[edi]
movlps [esi],xmm4
movlps xmm4,[esi]
nop
nop
; IMUL 69/6B
imul ax,bx,word 0x1234
imul ax,bx,byte 0x12
imul ax,[si],word 0x1234
imul ax,[si],byte 0x12
imul ax,[si]
|
test/Fail/WrongNumberOfConstructorArguments.agda | shlevy/agda | 1,989 | 11559 | <reponame>shlevy/agda<filename>test/Fail/WrongNumberOfConstructorArguments.agda
module WrongNumberOfConstructorArguments where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
f : Nat -> Nat
f (zero n) = n
f suc = zero
|
.emacs.d/elpa/ada-ref-man-2012.5/progs/arm_frm.adb | caqg/linux-home | 0 | 1504 | <reponame>caqg/linux-home
with -- ARM_Output, -- redudant with spec
-- ARM_Input,
ARM_File,
ARM_String,
-- ARM_Contents,
-- ARM_Database,
ARM_Syntax,
ARM_Index,
-- ARM_Subindex,
ARM_Format.Data,
Ada.Text_IO,
Ada.Characters.Handling,
Ada.Strings.Fixed;
package body ARM_Format is
--
-- Ada reference manual formatter (ARM_Form).
--
-- This package contains the routines to parse the input files, and
-- determine what to output.
--
-- ---------------------------------------
-- Copyright 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-- 2010, 2011, 2012, 2013, 2016, 2018
-- AXE Consultants. All rights reserved.
-- P.O. Box 1512, Madison WI 53701
-- E-Mail: <EMAIL>
--
-- ARM_Form is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License version 3
-- as published by the Free Software Foundation.
--
-- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN "AS IS"
-- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY,
-- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL.
-- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL,
-- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES,
-- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-- DAMAGES.
--
-- A copy of the GNU General Public License is available in the file
-- gpl-3-0.txt in the standard distribution of the ARM_Form tool.
-- Otherwise, see <http://www.gnu.org/licenses/>.
--
-- If the GPLv3 license is not satisfactory for your needs, a commercial
-- use license is available for this tool. Contact Randy at AXE Consultants
-- for more information.
--
-- ---------------------------------------
--
-- Edit History:
--
-- 4/14/00 - RLB - Created base package.
-- 4/17/00 - RLB - Starting implementation of commands.
-- 4/19/00 - RLB - Implemented contents package and section references.
-- 4/21/00 - RLB - Added hard_space and line_break output routines.
-- 4/24/00 - RLB - Added Change_Kind and Display_Index_Entries.
-- - RLB - Added Change and ChgRef.
-- 4/26/00 - RLB - Added paragraph commands and formats.
-- 4/29/00 - RLB - Loose ends: "Part", fixes for the example format,
-- "DescribeCode" and "Itemize".
-- 5/10/00 - RLB - Added missing "MetricsName" and "MetricsTitle".
-- Added additional paragraph format kinds.
-- 5/11/00 - RLB - Implemented numbers on enumerated paragraphs.
-- 5/12/00 - RLB - Added NoPrefix.
-- - RLB - Added attribute commands.
-- 5/13/00 - RLB - Added various character macros.
-- 5/15/00 - RLB - Split input from parsing/formatting.
-- 5/16/00 - RLB - Added database objects and Destroy.
-- - RLB - Implemented pragma commands.
-- 5/17/00 - RLB - Implemented syntax commands.
-- 5/19/00 - RLB - Added hinge analysis.
-- 5/23/00 - RLB - Added column commands.
-- - RLB - Added tab commands.
-- 5/24/00 - RLB - Implemented subscript/superscript commands.
-- 5/25/00 - RLB - Added more formatting commands and styles.
-- 5/26/00 - RLB - Removed hinge analysis, other junk.
-- 5/28/00 - RLB - Implemented index operations.
-- 6/ 2/00 - RLB - Implemented @|.
-- - RLB - Added AdaDefn and AdaSubDefn commands, and unit saving.
-- 8/ 2/00 - RLB - Implemented @! (as @| doesn't work); implemented
-- lquote, etc.
-- 8/ 4/00 - RLB - Added additional styles.
-- 8/ 8/00 - RLB - Added Attribute_Leading.
-- 8/11/00 - RLB - Fixed glossary report.
-- - RLB - Added Hanging_in_Bulleted low-level style.
-- 8/15/00 - RLB - Replaced "LangDefType" with "AdaTypeDefn" (much smaller).
-- 8/16/00 - RLB - Added double nesting support for InnerItemize.
-- - RLB - Added "noparanum" command; removed no paranum formats.
-- 8/17/00 - RLB - Changed Leading flag to Space_After, added Trailing command.
-- - RLB - Added Nested_Enumerated styles.
-- 8/18/00 - RLB - Fixed a variety of errors in the AARM paragraph numbering.
-- - RLB - Fixed Display_Index_Entry so it would work right when
-- given in an insertion or deletion.
-- 8/21/00 - RLB - Fixed so send and later references in a ChgReg command
-- don't accidentally include all preceding ones.
-- 8/22/00 - RLB - Added Labeled_Revised_Clause and
-- Labeled_Revised_Subclause commands.
-- 8/23/00 - RLB - Fixed Syntax_Rules to allow @Chg commands in the
-- LHS.
-- - RLB - Fixed error in display of Defn2 index entries.
-- 8/28/00 - RLB - Added implementation-defined changes command.
-- 8/30/00 - RLB - Adjusted code in index entries to match old AARM.
-- - RLB - Made the deleted paragraph text appear in all new
-- versions.
-- - RLB - Added AddedSubheading.
-- 8/31/00 - RLB - Added the New_Changes change kind.
-- - RLB - Added RM_New_Page command.
-- 9/ 1/00 - RLB - Fixed bugs that prevented "deleted paragraph" messages
-- from appearing and caused junk headers to appear for
-- sections not appearing in the old document.
-- 9/ 8/00 - RLB - Added information about the language-defined
-- subprograms to the index introduction.
-- 9/26/00 - RLB - Added Syntax_Display format.
-- 9/28/00 - RLB - Added RefSecbyNum command.
-- 10/30/00 - RLB - Added ISOOnly paragraph grouping.
-- - RLB - Fixed inserted paragraph numbers to support more than 9.
-- 6/17/02 - RLB - Added Ada95 changes sections.
-- 7/18/02 - RLB - Moved document type here.
-- - RLB - Added ARef= parameter to ChgRef.
-- - RLB - Added Changes_Only and versioning for individual changes.
-- 4/10/03 - RLB - Fixed Index_Pragma to include "<name> pragma".
-- 4/11/03 - RLB - Fixed order of removal for formatting for Heading and
-- Subheading, so that the nesting is right (it needs to
-- be exactly like the order of application).
-- - RLB - Fixed code so that parameter version numbers aren't
-- displayed higher than the item we're generating.
-- - RLB - Fixed ChgRef and others not to generate anything if
-- we're not generating the version that the reference is
-- for. Similarly, avoid changing the paragraph kind if
-- we're not going to use the changes.
-- - RLB - Fixed font for changing non-terminals in @Syn.
-- 9/09/04 - RLB - Removed unused junk noticed by <NAME>.
-- 9/10/04 - RLB - Added Version to many Text_Format commands.
-- - RLB - Fixed Get_NT to allow the Version parameter in @Chg.
-- - RLB - Updated to allow @Chg nesting.
-- 9/14/04 - RLB - Moved Change_Version_Type to ARM_Contents.
-- - RLB - Added version number parameters to revised header
-- commands; added additional header commands.
-- - RLB - Added code so that section references in Annex L and M
-- are links.
-- 9/15/04 - RLB - Fixed incorrect name for LabeledAddedSubClause command.
-- - RLB - Fixed to lift limit on number of inserted paragraphs.
-- 10/28/04 - RLB - Replaced double single quotes with double quotes,
-- as directed by the ARG.
-- - RLB - Added "AddedNormal" ChgRef kind.
-- 10/29/04 - RLB - Added code so that section references in Annex K are
-- links.
-- 11/02/04 - RLB - Added "DeletedAdded" ChgRef kind.
-- 11/03/04 - RLB - Fixed @Chg nesting glitch.
-- - RLB - Added InnerInnerItemize == Nested_X2_Bulleted.
-- 11/04/04 - RLB - Fixed a problem that reset the insertion number for
-- paragraphs have a normal AARM para. was encountered.
-- 11/15/04 - RLB - Added Indented_Nested_Bulleted style.
-- 12/06/04 - RLB - Added "RevisedAdded" ChgRef kind.
-- - RLB - Delayed generation of references until the start of
-- the paragraph. That avoids "pinning" problems,
-- especially for multiple changes in a single paragraph.
-- - RLB - Allow multiple Ref and ARef params in ChgAttribute.
-- - RLB - Added ChgAdded and ChgDeleted for entire paragraph
-- operations.
-- 12/11/04 - RLB - Fixed brackets in Added_Pragma_Syntax to allow {} in
-- text.
-- - RLB - Implemented attribute adding in Change_Attribute.
-- 12/13/04 - RLB - Fixed problems in the new change commands.
-- 12/15/04 - RLB - Fixed so a change is not left open across
-- an End_Hang_Item.
-- - RLB - Fixed glitches with deleted paragraphs.
-- 1/19/05 - RLB - Added LabeledRevisedInformativeAnnex.
-- - RLB - Fixed AARM paragraph numbers to allow more than 52,
-- and to put out an error message if we exceed the maximum.
-- - RLB - Added ChgDocReq and ChgImplAdvice.
-- - RLB - Added AddedDocReqList and AddedImplAdviceList.
-- 1/20/05 - RLB - Added debugging for stack overflows.
-- 1/24/05 - RLB - Added Inner_Indented.
-- 1/25/05 - RLB - Added AddedSyn and DeleteSyn commands.
-- 2/ 1/05 - RLB - Added Turkish Is.
-- 2/ 2/05 - RLB - Corrected so normal AARM numbers don't reset the
-- RM insertion number.
-- 3/15/05 - RLB - Corrected spelling.
-- 5/27/05 - RLB - Added @Unicode command for examples.
-- 8/ 9/05 - RLB - Changed the capitalization of some AARM note headers.
-- 10/17/05 - RLB - Added Glossary change commands.
-- 10/28/05 - RLB - Made index changes for Ada 200Y.
-- - RLB - Added added Annex headers.
-- - RLB - Added Language-Defined Entity indexes.
-- 10/31/05 - RLB - Fixed the "this paragraph was deleted" code to
-- not change the version; it's not necessarily
-- initialized, and the Kind isn't set anyway if the
-- version is too new.
-- 1/ 5/06 - RLB - Corrected a comment.
-- 1/12/06 - RLB - Replaced "Document" with a number of new more general
-- properties.
-- 1/13/06 - RLB - Added various link commands.
-- 1/16/06 - RLB - Added missing initializations.
-- - RLB - Added IndexList command.
-- - RLB - Added Unnumbered_Section counter to ensure that
-- such sections are uniquely named.
-- 1/18/06 - RLB - Added "Example_Font".
-- - RLB - Redid formatting command nesting so that closing
-- restores to the initial state for the command, not the
-- default state.
-- 1/20/06 - RLB - Added AILink command.
-- 2/ 8/06 - RLB - Added command checking at the end of each table row.
-- 2/ 9/06 - RLB - Implemented enhanced Table command.
-- 2/10/06 - RLB - Split scanning phase into a separate file.
-- - RLB - Added additional features to the Table command.
-- - RLB - Added the picture command.
-- 2/15/06 - RLB - Added code to prevent the generation of note numbers
-- for deleted notes in final documents.
-- 2/17/06 - RLB - Tracked down issues with @ChgImplDef.
-- - RLB - Added code so that index entries don't display soft
-- hyphens.
-- - RLB - Fixed glossary entries to not display insertions if
-- the mode would prevent that.
-- 6/22/06 - RLB - Added non-terminal linking.
-- 8/ 4/06 - RLB - Added checking for bad unit indexing.
-- 9/22/06 - RLB - Added "Use_ISO_2004_Note_Format", and implemented that
-- format.
-- - RLB - Revised to use Clause_Number_Type, and to support
-- Subsubclauses.
-- 9/25/06 - RLB - Added "Use_ISO_2004_Contents_Format".
-- - RLB - Added LastColWidth to @Table.
-- - RLB - Fixed Enumerated in Notes styles.
-- 9/29/06 - RLB - Added Element_Ref and Child_Ref for ASIS.
-- 10/04/06 - RLB - Added and implemented "Use_ISO_2004_List_Format".
-- - RLB - Added "InnerEnumerate" text block.
-- 10/13/06 - RLB - Added the @ntf command to handle cases where the
-- text needs to look like a non-terminal but it isn't
-- a real non-terminal.
-- - RLB - Added code to handle simple embedded commands in
-- @nt{} to generate links.
-- 10/16/06 - RLB - Added code to register deleted non-terminals (so
-- that they can be linked).
-- 10/18/06 - RLB - Fixed so that deleted glossary items still get
-- deleted paragraph numbers.
-- 2/ 5/07 - RLB - Added a paragraph kind, and changed ones that
-- appear in ASIS. Also renamed "Wide" to "Wide_Above"
-- so the purpose is more obvious.
-- 2/ 9/07 - RLB - Moved AI interpretation and folding to the HTML
-- driver, as constructing the link should be its
-- responsibility. This also allows new kinds of AI here.
-- 2/13/07 - RLB - Redid output formating to use an explict indent;
-- added ChildExample.
-- 2/16/07 - RLB - Added Indent format.
-- 2/19/07 - RLB - Added Title format.
-- 12/18/07 - RLB - Initialized Version in some cases.
-- - RLB - Added check for open formatting commands
-- in Check_End_Paragraph.
-- - RLB - Added Plain_Annex and associated commands.
-- 12/19/07 - RLB - Added color commands.
-- 6/12/08 - RLB - Corrected handling of the ChgGlossary command.
-- 3/ 4/09 - RLB - Added code to suppress bullets and the like when
-- displaying a deleted paragraph in New-Only mode
-- and no paragraph numbers are shown.
-- 5/ 6/09 - RLB - Added Labeled_Deleted_xxx.
-- 5/15/09 - RLB - Fixed missing code for note numbers in revised/added clauses.
-- 4/23/10 - RLB - Added Ada 2005 clause headers for Ada 2012 edition.
-- 8/ 8/11 - RLB - Split various data items to reduce the size of this
-- package.
-- 10/18/11 - RLB - Changed to GPLv3 license.
-- 10/19/11 - RLB - Added AspectDefn command.
-- 10/20/11 - RLB - Added optional initial version parameter to ChgImplDef
-- and related commands.
-- - RLB - Added DeletedPragmaSyn command.
-- 10/25/11 - RLB - Added optional initial version parameter to
-- LabeledRevisedSomething commands.
-- 10/26/11 - RLB - Added versioned break commands.
-- 3/19/12 - RLB - Fixed bug that occurred only when paragraph numbers
-- are off (ISO versions). Fixed sort order of attributes.
-- 3/27/12 - RLB - Added more versioned break commands.
-- 4/ 3/12 - RLB - Removed dead variables.
-- 8/31/12 - RLB - Put glossary components into a subrecord to prevent
-- inappropriate usage.
-- 10/18/12 - RLB - Put impdef components into a subrecord to prevent
-- inappropriate usage. Fixed problem caused by putting
-- newer items than the generated version into the DB.
-- - RLB - Added four specific indent hanging formats and
-- "small" format.
-- 11/ 5/12 - RLB - Added stupidly missing compare for "small" format.
-- 11/26/12 - RLB - Added subdivision names.
-- 7/ 5/13 - RLB - Added a nasty hack so added aspect names are marked
-- as such in Show_Changes versions.
-- 12/13/13 - RLB - Added InitialVersion parameter to ChgAttrib.
-- 3/17/16 - RLB - Removed Changes_Only, added Base_Change_Version.
type Command_Kind_Type is (Normal, Begin_Word, Parameter);
use ARM_Format.Data; -- use all type ARM_Format.Data.Command_Type;
-- Make the enumeration literals visible.
Free_References : Reference_Ptr := null; -- Unused reference objects.
-- We don't expect there ever to be many of these, so we don't try
-- to deallocate them.
Allocated_Reference_Count : Natural := 0;
function Allocate_Reference return Reference_Ptr is
-- Allocate a reference object from either the free list, or allocate
-- it.
T : Reference_Ptr;
begin
if Free_References /= null then
T := Free_References;
Free_References := Free_References.Next;
return T;
else
Allocated_Reference_Count := Allocated_Reference_Count + 1;
if Allocated_Reference_Count > 20 then -- Never more than this on one paragraph.
Ada.Text_IO.Put_Line (" ** Too many references allocated");
end if;
return new Reference;
end if;
end Allocate_Reference;
procedure Free_Reference (Reference : in out Reference_Ptr) is
-- Put a reference object on the free list; setting Reference to null.
begin
Reference.Next := Free_References;
Free_References := Reference;
Reference.Ref_Len := 0; -- Clear length, so we don't reuse by accident.
Reference := null;
end Free_Reference;
procedure Create (Format_Object : in out Format_Type;
Changes : in ARM_Format.Change_Kind;
Change_Version : in ARM_Contents.Change_Version_Type;
Base_Change_Version : in ARM_Contents.Change_Version_Type;
Display_Index_Entries : in Boolean;
Include_Annotations : in Boolean;
Include_ISO : in Boolean;
Link_Non_Terminals : in Boolean;
Number_Paragraphs : in Boolean;
Examples_Font : in ARM_Output.Font_Family_Type;
Use_ISO_2004_Note_Format : in Boolean;
Use_ISO_2004_Contents_Format : in Boolean;
Use_ISO_2004_List_Format : in Boolean;
Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind) is
-- Initialize an input object. Changes, Change_Version,
-- and Base_Change_Version determine
-- which changes should be displayed. If Display_Index_Entries is True,
-- index entries will be printed in the document; otherwise, they
-- will not generate any visible text (although they might generate
-- a link anchor). If Include_Annotations is True, annotations (AARM
-- text) will be included in the output; otherwise it will not be.
-- If Include_ISO is True, ISOOnly text will be included in the output
-- (and NotISO text will not); otherwise the reverse is true.
-- If Link_Non_Terminals is True, links will be generated for
-- each Non_Terminal, linking it to its definition.
-- If Number_Paragraphs is true, paragraphs will be numbered (per
-- subclause); otherwise they will not be.
-- Example_Font specifies the font that examples will be set in.
-- If Use_ISO_2004_Note_Format is true, that format will be used;
-- else the Ada95 standard's format will be used for notes.
-- If Use_ISO_2004_Contents_Format is true, that format will be used;
-- else the Ada95 standard's format will be used for the table of contents.
-- If Use_ISO_2004_List_Format is true, then lists will be lettered;
-- else the Ada95 standard's numbering format will be used for
-- enumerated lists.
-- The top-level (and other) subdivision names are as specified
-- in Top_Level_Subdivision_Name.
begin
Format_Object.Changes := Changes;
Format_Object.Change_Version := Change_Version;
Format_Object.Base_Change_Version := Base_Change_Version;
Format_Object.Display_Index_Entries := Display_Index_Entries;
Format_Object.Include_Annotations := Include_Annotations;
Format_Object.Include_ISO := Include_ISO;
Format_Object.Link_Non_Terminals := Link_Non_Terminals;
Format_Object.Number_Paragraphs := Number_Paragraphs;
Format_Object.Examples_Font := Examples_Font;
Format_Object.Use_ISO_2004_Note_Format := Use_ISO_2004_Note_Format;
Format_Object.Use_ISO_2004_Contents_Format := Use_ISO_2004_Contents_Format;
Format_Object.Use_ISO_2004_List_Format := Use_ISO_2004_List_Format;
Format_Object.Top_Level_Subdivision_Name := Top_Level_Subdivision_Name;
Format_Object.Clause_Number := (Section => 0, Clause => 0,
Subclause => 0, Subsubclause => 0);
Format_Object.Unnumbered_Section := 0;
Format_Object.Next_Note := 1;
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
Format_Object.Next_AARM_Insert_Para := 1;
Format_Object.Next_Enumerated_Num := 1;
Format_Object.Enumerated_Level := 0;
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
ARM_Database.Create (Format_Object.Aspect_DB);
ARM_Database.Create (Format_Object.Attr_DB);
ARM_Database.Create (Format_Object.Pragma_DB);
ARM_Database.Create (Format_Object.Glossary_DB);
ARM_Database.Create (Format_Object.Impdef_DB);
ARM_Database.Create (Format_Object.Impladv_DB);
ARM_Database.Create (Format_Object.Docreq_DB);
ARM_Syntax.Create;
ARM_Index.Create;
ARM_Subindex.Create (Format_Object.Package_Index);
ARM_Subindex.Create (Format_Object.Type_Index);
ARM_Subindex.Create (Format_Object.Subprogram_Index);
ARM_Subindex.Create (Format_Object.Exception_Index);
ARM_Subindex.Create (Format_Object.Object_Index);
end Create;
procedure Destroy (Format_Object : in out Format_Type) is
-- Destroy a format object, releasing any resources.
begin
ARM_Database.Destroy (Format_Object.Aspect_DB);
ARM_Database.Destroy (Format_Object.Attr_DB);
ARM_Database.Destroy (Format_Object.Pragma_DB);
ARM_Database.Destroy (Format_Object.Glossary_DB);
ARM_Database.Destroy (Format_Object.Impdef_DB);
ARM_Database.Destroy (Format_Object.Impladv_DB);
ARM_Database.Destroy (Format_Object.Docreq_DB);
ARM_Syntax.Destroy;
ARM_Index.Destroy;
ARM_Subindex.Destroy (Format_Object.Package_Index);
ARM_Subindex.Destroy (Format_Object.Type_Index);
ARM_Subindex.Destroy (Format_Object.Subprogram_Index);
ARM_Subindex.Destroy (Format_Object.Exception_Index);
ARM_Subindex.Destroy (Format_Object.Object_Index);
end Destroy;
function Clause_String (Format_Object : in Format_Type) return String is
-- Returns a string for a clause reference.
use type ARM_Contents.Section_Number_Type;
begin
if Format_Object.Clause_Number.Subsubclause /= 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.SubSubClause,
Format_Object.Clause_Number);
elsif Format_Object.Clause_Number.Subclause /= 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.SubClause,
Format_Object.Clause_Number);
elsif Format_Object.Clause_Number.Clause /= 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.Clause,
Format_Object.Clause_Number);
else
if Format_Object.Clause_Number.Section = 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.Unnumbered_Section,
Format_Object.Clause_Number);
elsif Format_Object.Clause_Number.Section < ARM_Contents.ANNEX_START then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.Section,
Format_Object.Clause_Number);
else
return ARM_Contents.Make_Clause_Number (
ARM_Contents.Plain_Annex, -- Same for all kinds of annex.
Format_Object.Clause_Number);
end if;
end if;
end Clause_String;
Do_Not_Display_Text : constant ARM_Output.Change_Type := ARM_Output.Both;
-- Special meaning for Calc_Change_Disposition, below.
procedure Calc_Change_Disposition
(Format_Object : in Format_Type;
Version : in ARM_Contents.Change_Version_Type;
Operation : in ARM_Output.Change_Type;
Text_Kind : out ARM_Output.Change_Type) is
-- Determine the appropriate disposition for text.
-- The text is to be inserted if Operation is Insertion;
-- and deleted if Operation is Deletion.
-- The appropriate Change_Type to use is returned in Text_Kind.
-- If Text_Kind is None, the text should be displayed normally.
-- If Text_Kind is Insertion, the text should be displayed as inserted.
-- If Text_Kind is Deletion, the text should be displayed as deletion.
-- If Text_Kind is Do_Not_Display_Text (same as Both), the
-- text should not be shown at all.
-- Program_Error is raised if Operation is None or Both.
-- This routine assumes that we are not nested
-- in some other change item.
use type ARM_Output.Change_Type;
begin
if Operation = ARM_Output.None or else
Operation = ARM_Output.Both then
raise Program_Error;
end if;
-- We can't check for nesting, because in some cases it happens
-- harmlessly (i.e. Added_Pragma_Syn).
case Format_Object.Changes is
when ARM_Format.Old_Only =>
-- Display only the original version ('0').
if Operation = ARM_Output.Insertion then
if Version > '0' then
Text_Kind := Do_Not_Display_Text; -- Newer than original.
else
Text_Kind := ARM_Output.None; -- Display normally.
end if;
else -- Deletion
if Version > '0' then
Text_Kind := ARM_Output.None; -- Display normally, not deleted in original code.
else
Text_Kind := Do_Not_Display_Text; -- Deleted in original.
end if;
end if;
when ARM_Format.New_Only =>
-- Display only the version
-- Format_Object.Change_Version, no insertions or deletions.
if Operation = ARM_Output.Insertion then
if Version > Format_Object.Change_Version then
-- Change version newer than we're displaying;
-- ignore the item.
Text_Kind := Do_Not_Display_Text;
else
-- Display the change normally.
Text_Kind := ARM_Output.None;
end if;
else -- Deletion
if Version > Format_Object.Change_Version then
-- Change version newer than we're displaying;
-- leave the item in and display normally.
Text_Kind := ARM_Output.None;
else
-- Delete the item.
Text_Kind := Do_Not_Display_Text;
end if;
end if;
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
-- Display only the the changes for versions
-- Format_Object.Base_Change_Version ..
-- Format_Object.Change_Version, older changes
-- are applied and newer changes are ignored.
-- (New_Changes shows deletions as a single
-- character for older versions of Word, but otherwise
-- is the same.)
if Operation = ARM_Output.Insertion then
if Version > Format_Object.Change_Version then
-- Change version is newer than we're displaying;
-- ignore the item.
Text_Kind := Do_Not_Display_Text;
elsif Version < Format_Object.Base_Change_Version then
-- Change version is older than we're displaying;
-- display the change normally.
Text_Kind := ARM_Output.None;
else
-- This version or older, display the change
-- as an insertion.
Text_Kind := ARM_Output.Insertion;
end if;
else -- Deletion.
if Version > Format_Object.Change_Version then
-- Change version is newer than we're displaying;
-- the item isn't deleted yet, display the change
-- normally.
Text_Kind := ARM_Output.None;
elsif Version < Format_Object.Base_Change_Version then
-- Change version is older than we're displaying;
-- the item is deleted, so ignore the item.
Text_Kind := Do_Not_Display_Text;
else
-- The correct version, display the change
-- as a deletion.
Text_Kind := ARM_Output.Deletion;
end if;
end if;
end case;
end Calc_Change_Disposition;
function Get_Current_Item (Format_Object : in Format_Type;
Input_Object : in ARM_Input.Input_Type'Class;
Item : in String) return String is
-- Return the "current" item from Item. This is Item itself,
-- unless Item includes an @Chg.
New_Pos : Natural;
Close_Ch : Character;
Open_Cnt : Natural;
My_Item : constant String (1 .. Item'Length) := Item;
-- Just to slide the bounds.
Version : ARM_Contents.Change_Version_Type := '0';
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
if My_Item'Length < 11 or else
My_Item (1) /= '@' or else
Ada.Characters.Handling.To_Lower (My_Item (2 .. 4)) /= "chg" then
-- No @Chg command here.
return My_Item;
end if;
if Ada.Characters.Handling.To_Lower (My_Item (6 .. 9)) = "new=" then
-- No version parameter:
New_Pos := 6;
Version := '1';
elsif My_Item'Length > 22 and then
Ada.Characters.Handling.To_Lower (My_Item (6 .. 14)) = "version=[" and then
Ada.Characters.Handling.To_Lower (My_Item (16 .. 21)) = "],new=" then
New_Pos := 18;
Version := My_Item(15);
else
Ada.Text_IO.Put_Line ("%% Oops, can't find either Version or New in item chg command, line " & ARM_Input.Line_String (Input_Object));
return My_Item;
end if;
Calc_Change_Disposition (Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- Find the end of the "New" parameter, and return the "Old"
-- parameter.
Close_Ch := ARM_Input.Get_Close_Char (
My_Item(New_Pos+4));
Open_Cnt := 1;
for I in New_Pos+5 .. My_Item'Last loop
if My_Item(I) = My_Item(New_Pos+4) then
Open_Cnt := Open_Cnt + 1;
elsif My_Item(I) = Close_Ch then
if Open_Cnt <= 1 then
-- OK, the end of the "New" parameter is at 'I'.
if My_Item'Last < I+7 or else
My_Item (I+1) /= ',' or else
Ada.Characters.Handling.To_Lower (My_Item (I+2 .. I+4)) /= "old" or else
My_Item (I+5) /= '=' then
exit; -- Heck if I know.
end if;
Close_Ch := ARM_Input.Get_Close_Char (
My_Item(I+6));
Open_Cnt := 1;
for J in I+7 .. My_Item'Last loop
if My_Item(J) = My_Item(I+6) then
Open_Cnt := Open_Cnt + 1;
elsif My_Item(J) = Close_Ch then
if Open_Cnt <= 1 then
return My_Item (I + 7 .. J - 1);
else
Open_Cnt := Open_Cnt - 1;
end if;
-- else continue looking.
end if;
end loop;
Ada.Text_IO.Put_Line ("%% Oops, can't find end of item chg old command, line " & ARM_Input.Line_String (Input_Object));
return My_Item (I + 7 .. My_Item'Last);
else
Open_Cnt := Open_Cnt - 1;
end if;
-- else continue looking.
end if;
end loop;
Ada.Text_IO.Put_Line ("%% Oops, can't find end of item chg new command, line " & ARM_Input.Line_String (Input_Object));
return My_Item (New_Pos+5 .. My_Item'Length);
else -- Some new format, use the new name.
-- Find the end of the "New" parameter, and
-- return it.
Close_Ch := ARM_Input.Get_Close_Char (My_Item(New_Pos+4));
Open_Cnt := 1;
for I in New_Pos+5 .. My_Item'Last loop
if My_Item(I) = My_Item(New_Pos+4) then
Open_Cnt := Open_Cnt + 1;
elsif My_Item(I) = Close_Ch then
if Open_Cnt <= 1 then
return My_Item (New_Pos+5 .. I - 1);
else
Open_Cnt := Open_Cnt - 1;
end if;
-- else continue looking.
end if;
end loop;
-- Weird if we get here, can't find end of parameter.
Ada.Text_IO.Put_Line ("%% Oops, can't find end of NT chg new command, line " & ARM_Input.Line_String (Input_Object));
return My_Item (New_Pos+5 .. My_Item'Last);
end if;
end Get_Current_Item;
function Get_Old_Item (Format_Object : in Format_Type;
Input_Object : in ARM_Input.Input_Type'Class;
Item : in String) return String is
-- Return the "old" item from Item, or nothing if there is no
-- old item. This is nothing unless Item includes an @Chg,
-- *and* the new item in the @Chg is displayed.
New_Pos : Natural;
Close_Ch : Character;
Open_Cnt : Natural;
My_Item : constant String (1 .. Item'Length) := Item;
-- Just to slide the bounds.
Version : ARM_Contents.Change_Version_Type := '0';
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
if My_Item'Length < 11 or else
My_Item (1) /= '@' or else
Ada.Characters.Handling.To_Lower (My_Item (2 .. 4)) /= "chg" then
-- No @Chg command here.
return "";
end if;
if Ada.Characters.Handling.To_Lower (My_Item (6 .. 9)) = "new=" then
-- No version parameter:
New_Pos := 6;
Version := '1';
elsif My_Item'Length > 22 and then
Ada.Characters.Handling.To_Lower (My_Item (6 .. 14)) = "version=[" and then
Ada.Characters.Handling.To_Lower (My_Item (16 .. 21)) = "],new=" then
New_Pos := 18;
Version := My_Item(15);
else
Ada.Text_IO.Put_Line ("%% Oops, can't find either Version or New in item chg command, line " & ARM_Input.Line_String (Input_Object));
return "";
end if;
Calc_Change_Disposition (Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition /= Do_Not_Display_Text then
-- Some new item was shown.
-- Find the end of the "New" parameter, and return the "Old"
-- parameter.
Close_Ch := ARM_Input.Get_Close_Char (
My_Item(New_Pos+4));
Open_Cnt := 1;
for I in New_Pos+5 .. My_Item'Last loop
if My_Item(I) = My_Item(New_Pos+4) then
Open_Cnt := Open_Cnt + 1;
elsif My_Item(I) = Close_Ch then
if Open_Cnt <= 1 then
-- OK, the end of the "New" parameter is at 'I'.
if My_Item'Last < I+7 or else
My_Item (I+1) /= ',' or else
Ada.Characters.Handling.To_Lower (My_Item (I+2 .. I+4)) /= "old" or else
My_Item (I+5) /= '=' then
exit; -- Heck if I know.
end if;
Close_Ch := ARM_Input.Get_Close_Char (
My_Item(I+6));
Open_Cnt := 1;
for J in I+7 .. My_Item'Last loop
if My_Item(J) = My_Item(I+6) then
Open_Cnt := Open_Cnt + 1;
elsif My_Item(J) = Close_Ch then
if Open_Cnt <= 1 then
return My_Item (I + 7 .. J - 1);
else
Open_Cnt := Open_Cnt - 1;
end if;
-- else continue looking.
end if;
end loop;
Ada.Text_IO.Put_Line ("%% Oops, can't find end of item chg old command, line " & ARM_Input.Line_String (Input_Object));
return My_Item (I + 7 .. My_Item'Last);
else
Open_Cnt := Open_Cnt - 1;
end if;
-- else continue looking.
end if;
end loop;
Ada.Text_IO.Put_Line ("%% Oops, can't find end of item chg new command, line " & ARM_Input.Line_String (Input_Object));
return "";
else -- The new item wasn't displayed, so we already have used the
-- old item.
return "";
end if;
end Get_Old_Item;
procedure Scan (Format_Object : in out Format_Type;
File_Name : in String;
Section_Number : in ARM_Contents.Section_Number_Type;
Starts_New_Section : in Boolean) is separate;
-- Scans the contents for File_Name, determining the table of contents
-- for the section. The results are written to the contents package.
-- Starts_New_Section is True if the file starts a new section.
-- Section_Number is the number (or letter) of the section.
-- See ARM_FRMS.ADB.
procedure Write_Table_of_Contents (
Format_Object : in out Format_Type;
Output_Object : in out ARM_Output.Output_Type'Class) is
-- Writes the table of contents for the document. (It will have
-- a section name of "TOC"). This should be done after all calls to
-- Scan and before any calls to Process.
In_Paragraph : Boolean := False;
procedure Write_It (Title : in ARM_Contents.Title_Type;
Level : in ARM_Contents.Level_Type;
Clause_Number : in ARM_Contents.Clause_Number_Type;
Version : in ARM_Contents.Change_Version_Type;
Quit : out Boolean) is
Clause_Text : constant String :=
ARM_Contents.Make_Clause_Number (Level, Clause_Number);
Old_Title : ARM_Contents.Title_Type :=
ARM_Contents.Lookup_Old_Title (
Level, Clause_Number);
begin
Quit := False;
if Old_Title = ARM_Contents.Title_Type'(others => ' ') and then
(Format_Object.Change_Version < Version or else
ARM_Format."=" (Format_Object.Changes, ARM_Format.Old_Only)) then
-- This is an added item, and we're generating a version
-- that does not include it. Skip it completely.
return;
end if;
if ARM_Contents."=" (Level, ARM_Contents.Clause) then
ARM_Output.Line_Break (Output_Object);
ARM_Output.Ordinary_Text (Output_Object, " ");
ARM_Output.Ordinary_Text (Output_Object, Clause_Text);
ARM_Output.Hard_Space (Output_Object);
elsif ARM_Contents."=" (Level, ARM_Contents.Subclause) then
ARM_Output.Line_Break (Output_Object);
ARM_Output.Ordinary_Text (Output_Object, " ");
ARM_Output.Ordinary_Text (Output_Object, Clause_Text);
ARM_Output.Hard_Space (Output_Object);
elsif ARM_Contents."=" (Level, ARM_Contents.Subsubclause) then
ARM_Output.Line_Break (Output_Object);
ARM_Output.Ordinary_Text (Output_Object, " ");
ARM_Output.Ordinary_Text (Output_Object, Clause_Text);
ARM_Output.Hard_Space (Output_Object);
elsif ARM_Contents."=" (Level, ARM_Contents.Unnumbered_Section) then
if In_Paragraph then
ARM_Output.End_Paragraph (Output_Object);
end if;
ARM_Output.Start_Paragraph (Output_Object,
ARM_Output.Normal,
Indent => 0, Number => "",
Justification => ARM_Output.Left);
In_Paragraph := True;
else
if In_Paragraph then
ARM_Output.End_Paragraph (Output_Object);
end if;
ARM_Output.Start_Paragraph (Output_Object,
ARM_Output.Normal,
Indent => 0, Number => "",
Justification => ARM_Output.Left);
In_Paragraph := True;
if ARM_Contents."=" (Level, ARM_Contents.Section) then
ARM_Output.Ordinary_Text (Output_Object, Clause_Text);
ARM_Output.Ordinary_Text (Output_Object, ". ");
else -- Annexes.
ARM_Output.Ordinary_Character (Output_Object, Clause_Text(Clause_Text'Last)); -- We don't want the "Annex" part.
ARM_Output.Ordinary_Text (Output_Object, ". ");
end if;
end if;
if Format_Object.Change_Version < Version then
-- Ignore the change:
ARM_Output.Clause_Reference (Output_Object,
Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Old_Title (
Level, Clause_Number), Ada.Strings.Right),
Clause_Text);
else
case Format_Object.Changes is
when ARM_Format.Old_Only =>
ARM_Output.Clause_Reference (Output_Object,
Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Old_Title (
Level, Clause_Number), Ada.Strings.Right),
Clause_Text);
when ARM_Format.New_Only |
ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
ARM_Output.Clause_Reference (Output_Object,
Ada.Strings.Fixed.Trim (Title, Ada.Strings.Right),
Clause_Text);
end case;
end if;
end Write_It;
procedure Write_Contents is new ARM_Contents.For_Each (Write_It);
begin
-- Note: For .RTF version, the result of this call will not be used,
-- preferring to let Word make the TOC (it can include page numbers).
if Format_Object.Use_ISO_2004_Contents_Format then
ARM_Output.Section (Output_Object,
Section_Title => "Contents",
Section_Name => "TOC");
ARM_Output.Clause_Header (Output_Object,
Header_Text => "Contents",
Level => ARM_Contents.Section,
Clause_Number => "",
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
else
ARM_Output.Section (Output_Object,
Section_Title => "Table of Contents",
Section_Name => "TOC");
ARM_Output.Clause_Header (Output_Object,
Header_Text => "Table of Contents",
Level => ARM_Contents.Section,
Clause_Number => "",
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end if;
ARM_Output.TOC_Marker (Output_Object, For_Start => True);
Write_Contents;
if In_Paragraph then
ARM_Output.End_Paragraph (Output_Object);
end if;
ARM_Output.TOC_Marker (Output_Object, For_Start => False);
end Write_Table_of_Contents;
procedure Make_References (List : in out Reference_Ptr;
Format_Object : in out Format_Type;
Output_Object : in out ARM_Output.Output_Type'Class) is
-- Write the references to the Output_Object, using the format
-- of Format_Object.
-- Deallocate the references on List; List will be null afterwards.
Temp : Reference_Ptr;
Our_Text_Format : ARM_Output.Format_Type;
begin
-- We assume these are only stored here if we want to see them
-- on *this* paragraph. Thus, we just output them if they exist
-- here.
Our_Text_Format := Format_Object.Text_Format;
Our_Text_Format.Change := ARM_Output.None; -- No changes should be reflected in references.
while List /= null loop
-- Output a reference. These are *never* marked as
-- inserted or deleted, so set the style properly.
ARM_Output.Text_Format (Output_Object,
Format => Our_Text_Format);
ARM_Output.Ordinary_Character (Output_Object, '{');
Our_Text_Format.Italic := True;
ARM_Output.Text_Format (Output_Object,
Format => Our_Text_Format);
if List.Is_DR_Ref then
-- Output a DR reference.
ARM_Output.DR_Reference (Output_Object,
Text => List.Ref_Name(1..List.Ref_Len),
DR_Number => List.Ref_Name(1..List.Ref_Len));
else
-- Output an AI reference.
ARM_Output.AI_Reference (Output_Object,
Text => List.Ref_Name(1..List.Ref_Len),
AI_Number => List.Ref_Name(1..List.Ref_Len));
end if;
Our_Text_Format.Italic := Format_Object.Text_Format.Italic;
ARM_Output.Text_Format (Output_Object,
Format => Our_Text_Format);
ARM_Output.Ordinary_Character (Output_Object, '}');
ARM_Output.Ordinary_Character (Output_Object, ' ');
-- Reset to the current format.
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
Format_Object.Last_Non_Space := False;
Temp := List;
List := List.Next;
Free_Reference (Temp);
end loop;
end Make_References;
procedure Dump_References (List : in out Reference_Ptr) is
-- Destroy any references in List; List will be null afterwards.
Temp : Reference_Ptr;
begin
while List /= null loop
Temp := List;
List := List.Next;
Free_Reference (Temp);
end loop;
end Dump_References;
type Items is record
Kind : Command_Kind_Type;
Name : ARM_Input.Command_Name_Type;
Command : Data.Command_Type;
Close_Char : Character; -- Ought to be }, ], >, or ).
Text_Format : ARM_Output.Format_Type;
-- Format at the start of the command.
-- The next four are only used if Kind=Begin_Word, or for
-- Command=Implementation_Defined, Glossary_Text_Param, or
-- Syntax_Rule_RHS.
Old_Last_Subhead_Paragraph : Paragraph_Type;
Old_Next_Subhead_Paragraph : Paragraph_Type;
Old_Next_Paragraph_Format : Paragraph_Type;
Old_Tab_Stops : ARM_Output.Tab_Info;
Old_Next_Enum_Num : Positive;
Is_Formatting : Boolean; -- Only used if Kind=Begin_Word.
-- The command changes the PARAGRAPH format.
-- Otherwise, it should be ignored when
-- when determining the format.
-- The following is only used if Command = Change, Change_Added,
-- Change_Deleted, Added_Subheading,
-- Added_Pragma_Syntax, Deleted_Pragma_Syntax,
-- Added_Syntax, Deleted_Syntax,
-- New_Page_for_Version, New_Column_for_Version,
-- RM_New_Page_for_Version, Not_ISO_RM_New_Page_for_Version, and
-- ISO_Only_RM_New_Page_for_Version.
Change_Version : ARM_Contents.Change_Version_Type;
-- The following are only used if Command = Change,
-- Added_Pragma_Syntax, and Deleted_Pragma_Syntax.
Prev_Change_Version : ARM_Contents.Change_Version_Type;
-- The following are only used if Command = Change.
Was_Text : Boolean; -- Did the current subcommand have text?
Prev_Change : ARM_Output.Change_Type;
Prev_Added_Change_Version : ARM_Contents.Change_Version_Type;
end record;
type Nesting_Stack_Type is array (1 .. 40) of Items;
type Format_State_Type is record
Nesting_Stack : Nesting_Stack_Type;
Nesting_Stack_Ptr : Natural := 0;
end record;
procedure Real_Process (Format_Object : in out Format_Type;
Format_State : in out Format_State_Type;
Input_Object : in out ARM_Input.Input_Type'Class;
Output_Object : in out ARM_Output.Output_Type'Class) is
-- Process the contents of Input_Object, writing the results to
-- Output_Object. (Output_Object uses dispatching calls to provide
-- the correct formatting). Format_Object holds information about
-- the state of the formatting.
procedure Set_Nesting_for_Command (Name : in ARM_Input.Command_Name_Type;
Kind : in Command_Kind_Type;
Param_Ch : in Character) is
-- Push the command onto the nesting stack.
begin
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr + 1;
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr) :=
(Name => Name,
Kind => Kind,
Command => Data.Command (Name),
Close_Char => ' ', -- Set below.
Text_Format => Format_Object.Text_Format, -- Save the current format.
-- Other things next necessarily used:
Old_Last_Subhead_Paragraph => Plain, -- Not used.
Old_Next_Subhead_Paragraph => Plain, -- Not used.
Old_Next_Paragraph_Format => Plain, -- Not used.
Old_Tab_Stops => ARM_Output.NO_TABS, -- Not used.
Old_Next_Enum_Num => 1, -- Not used.
Is_Formatting => False, -- Not used.
Change_Version => '0', -- Not used.
Was_Text => False, -- Not used.
Prev_Change => ARM_Output.None, -- Not used.
Prev_Change_Version => '0', -- Not used.
Prev_Added_Change_Version => '0'); -- Not used.
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char := ARM_Input.Get_Close_Char (Param_Ch);
--Ada.Text_IO.Put_Line (" &Stack (" & Name & "); Close-Char=" &
-- Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char);
end Set_Nesting_for_Command;
procedure Set_Nesting_for_Parameter (Command : in Data.Command_Type;
Close_Ch : in Character) is
-- Push the parameter onto the nesting stack.
begin
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr + 1;
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr) :=
(Name => (others => ' '),
Kind => Parameter,
Command => Command,
Close_Char => Close_Ch,
Text_Format => Format_Object.Text_Format, -- Save the current
-- format (not really used here).
Old_Last_Subhead_Paragraph => Plain, -- Not used.
Old_Next_Subhead_Paragraph => Plain, -- Not used.
Old_Next_Paragraph_Format => Plain, -- Not used.
Old_Tab_Stops => ARM_Output.NO_TABS, -- Not used.
Old_Next_Enum_Num => 1, -- Not used.
Is_Formatting => False, -- Not used.
Change_Version => '0', -- Not used.
Was_Text => False, -- Not used.
Prev_Change => ARM_Output.None, -- Not used.
Prev_Change_Version => '0', -- Not used.
Prev_Added_Change_Version => '0'); -- Not used.
--Ada.Text_IO.Put_Line (" &Stack (Parameter)");
end Set_Nesting_for_Parameter;
function Is_AARM_Paragraph (Kind : in Paragraph_Type) return Boolean is
begin
case Kind is
when Plain | Introduction | Syntax | Resolution | Legality |
Static_Semantics | Link_Time |
Run_Time | Bounded_Errors |
Erroneous | Requirements | Documentation |
Metrics | Permissions | Advice | Notes | Single_Note |
Examples =>
return False;
when Language_Design | Ada83_Inconsistencies |
Ada83_Incompatibilities | Ada83_Extensions |
Ada83_Wording | Ada95_Inconsistencies |
Ada95_Incompatibilities | Ada95_Extensions |
Ada95_Wording | Ada2005_Inconsistencies |
Ada2005_Incompatibilities | Ada2005_Extensions |
Ada2005_Wording | Ada2012_Inconsistencies |
Ada2012_Incompatibilities | Ada2012_Extensions |
Ada2012_Wording | Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker | Bare_Annotation |
Element_Ref | Child_Ref | Usage_Note =>
return True;
when In_Table =>
return False; -- Tables are never considered part of the
-- AARM for formatting purposes, even when they are.
when Wide_Above | Example_Text | Indented_Example_Text |
Child_Example_Text | Code_Indented | Indent |
Bulleted |
Nested_Bulleted | Nested_X2_Bulleted |
Display | Syntax_Display |
Syntax_Indented | Syntax_Production |
Enumerated | Nested_Enumerated |
Hanging_Indented_1 | Hanging_Indented_2 |
Hanging_Indented_3 | Hanging_Indented_4 |
Small | Title =>
-- This depends on the containing paragraph kind;
-- Last_Paragraph_Subhead_Type should contain that.
if Format_Object.Last_Paragraph_Subhead_Type = Wide_Above or else
Format_Object.Last_Paragraph_Subhead_Type = Example_Text or else
Format_Object.Last_Paragraph_Subhead_Type = Child_Example_Text or else
Format_Object.Last_Paragraph_Subhead_Type = Indented_Example_Text or else
Format_Object.Last_Paragraph_Subhead_Type = Bulleted or else
Format_Object.Last_Paragraph_Subhead_Type = Code_Indented or else
Format_Object.Last_Paragraph_Subhead_Type = Indent or else
Format_Object.Last_Paragraph_Subhead_Type = Nested_Bulleted or else
Format_Object.Last_Paragraph_Subhead_Type = Nested_X2_Bulleted or else
Format_Object.Last_Paragraph_Subhead_Type = Display or else
Format_Object.Last_Paragraph_Subhead_Type = Syntax_Display or else
Format_Object.Last_Paragraph_Subhead_Type = Syntax_Indented or else
Format_Object.Last_Paragraph_Subhead_Type = Syntax_Production or else
Format_Object.Last_Paragraph_Subhead_Type = Enumerated or else
Format_Object.Last_Paragraph_Subhead_Type = Nested_Enumerated or else
Format_Object.Last_Paragraph_Subhead_Type = Hanging_Indented_1 or else
Format_Object.Last_Paragraph_Subhead_Type = Hanging_Indented_2 or else
Format_Object.Last_Paragraph_Subhead_Type = Hanging_Indented_3 or else
Format_Object.Last_Paragraph_Subhead_Type = Hanging_Indented_4 or else
Format_Object.Last_Paragraph_Subhead_Type = Title or else
Format_Object.Last_Paragraph_Subhead_Type = In_Table then
Ada.Text_IO.Put_Line ("%% Oops, can't find out if AARM paragraph, line " & ARM_Input.Line_String (Input_Object));
return False; -- Oops, can't tell (double nesting).
-- We make this check to avoid infinite recursion.
else
return Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type);
end if;
end case;
end Is_AARM_Paragraph;
procedure Paragraph_Number_String (Update_Numbers : in Boolean) is
-- Generate the current (next) paragraph number string into
-- Format_Object.Current_Paragraph_String. Update the paragraph
-- numbers if Update_Numbers is True.
PNum : constant String := Integer'Image(Format_Object.Next_Paragraph);
PNum_Pred : constant String := Integer'Image(Format_Object.Next_Paragraph-1);
use type Arm_Database.Paragraph_Change_Kind_Type;
procedure AARM_Sub_Num (Sub_Letter : in Character) is
-- Adds a properly formatted AARM sub letter, with leading '.'.
-- Sets the length appropriately.
begin
Format_Object.Current_Paragraph_String(PNum_Pred'Last) :=
'.';
if Sub_Letter <= 'z' then
Format_Object.Current_Paragraph_String(PNum_Pred'Last+1) :=
Sub_Letter;
Format_Object.Current_Paragraph_Len :=
PNum_Pred'Last + 1;
elsif Character'Val(Character'Pos(Sub_Letter) - 26) <= 'z' then
-- Double letter.
Format_Object.Current_Paragraph_String(PNum_Pred'Last+1) :=
Character'Val(Character'Pos(Sub_Letter) - 26);
Format_Object.Current_Paragraph_String(PNum_Pred'Last+2) :=
Character'Val(Character'Pos(Sub_Letter) - 26);
Format_Object.Current_Paragraph_Len :=
PNum_Pred'Last + 2;
elsif Character'Val(Character'Pos(Sub_Letter) - 52) <= 'z' then
-- Triple letter.
Format_Object.Current_Paragraph_String(PNum_Pred'Last+1) :=
Character'Val(Character'Pos(Sub_Letter) - 52);
Format_Object.Current_Paragraph_String(PNum_Pred'Last+2) :=
Character'Val(Character'Pos(Sub_Letter) - 52);
Format_Object.Current_Paragraph_String(PNum_Pred'Last+3) :=
Character'Val(Character'Pos(Sub_Letter) - 52);
Format_Object.Current_Paragraph_Len :=
PNum_Pred'Last + 3;
else -- Doesn't fit!
Ada.Text_IO.Put_Line ("** AARM paragraph number out of range, line " & ARM_Input.Line_String (Input_Object));
Format_Object.Current_Paragraph_String(PNum_Pred'Last+1) := '$';
Format_Object.Current_Paragraph_String(PNum_Pred'Last+2) := '$';
Format_Object.Current_Paragraph_String(PNum_Pred'Last+3) := '$';
Format_Object.Current_Paragraph_Len :=
PNum_Pred'Last + 3;
end if;
end AARM_Sub_Num;
begin
-- The full paragraph number is:
-- Num.AARM.Ins/Vers
-- where Num is a paragraph number in the RM; AARM is the
-- paragraph subletter for AARM text; Ins is the number of
-- inserted paragraph; and Vers is the version number ('1'
-- for Technical Corrigendum 1; '0' for original RM.;
-- '2' for Amendment 1). Note that we don't include change
-- versions greater than the one we're currently processing.
-- Unused parts are omitted.
-- %%%% Buglet: If a paragraph was changed by multiple versions,
-- we only know the last one. So we guess. If there was a change
-- visible here, there must be a revision number, so we use the
-- one we're generating. That could be wrong if we have three
-- or more versions. I hope we don't need to regenerate old
-- versions that far back.
if Format_Object.Next_Paragraph_Change_Kind = ARM_Database.None or else
Format_Object.Changes = Old_Only then
-- Either there is no change, or we are only producing
-- the original document (which means we ignore all
-- marked changes).
if Is_AARM_Paragraph (Format_Object.Next_Paragraph_Subhead_Type) then
Format_Object.Current_Paragraph_String(1 .. PNum_Pred'Last-1) :=
PNum_Pred(2..PNum_Pred'Last);
AARM_Sub_Num (Format_Object.Next_AARM_Sub);
if Update_Numbers then
Format_Object.Next_AARM_Sub := Character'Succ(Format_Object.Next_AARM_Sub);
Format_Object.Next_AARM_Insert_Para := 1;
end if;
else
Format_Object.Current_Paragraph_String(1 .. PNum'Last-1) :=
PNum(2..PNum'Last);
Format_Object.Current_Paragraph_Len := PNum'Last - 1;
if Update_Numbers then
Format_Object.Next_Paragraph := Format_Object.Next_Paragraph + 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
Format_Object.Next_AARM_Insert_Para := 1;
end if;
end if;
elsif Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Inserted or else
Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Revised_Inserted_Number or else
Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Deleted_Inserted_Number or else
Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Deleted_Inserted_Number_No_Delete_Message then
-- We'll assume that there are no more than 99 inserted
-- paragraphs in a row.
Format_Object.Current_Paragraph_String(1 .. PNum_Pred'Last-1) :=
PNum_Pred(2..PNum_Pred'Last);
if Is_AARM_Paragraph (Format_Object.Next_Paragraph_Subhead_Type) then
if Format_Object.Next_AARM_Sub = 'a' then
AARM_Sub_Num ('a'); -- No paras before the insertion.
else
AARM_Sub_Num (Character'Pred(Format_Object.Next_AARM_Sub));
-- Insertions use the preceeding paragraph letter.
end if;
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 1) :=
'.';
if Format_Object.Next_AARM_Insert_Para >= 10 then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Character'Val((Format_Object.Next_AARM_Insert_Para/10) + Character'Pos('0'));
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 3) :=
Character'Val((Format_Object.Next_AARM_Insert_Para mod 10) + Character'Pos('0'));
Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len + 1;
-- Make this consistent with the other cases.
else
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Character'Val(Format_Object.Next_AARM_Insert_Para + Character'Pos('0'));
end if;
if Update_Numbers then
Format_Object.Next_AARM_Insert_Para :=
Format_Object.Next_AARM_Insert_Para + 1;
end if;
else -- None inserted paragraphs.
Format_Object.Current_Paragraph_Len := PNum_Pred'Last - 1;
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 1) :=
'.';
if Format_Object.Next_Insert_Para >= 10 then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Character'Val((Format_Object.Next_Insert_Para/10) + Character'Pos('0'));
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 3) :=
Character'Val((Format_Object.Next_Insert_Para mod 10) + Character'Pos('0'));
Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len + 1;
-- Make this consistent with the other cases.
else
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Character'Val(Format_Object.Next_Insert_Para + Character'Pos('0'));
end if;
if Update_Numbers then
Format_Object.Next_Insert_Para := Format_Object.Next_Insert_Para + 1;
-- Note: We don't update the AARM numbers for
-- inserted paragraphs, as the insertion number is
-- not included in them.
end if;
end if;
if Format_Object.Next_Paragraph_Version /= '0' then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 3) :=
'/';
if Format_Object.Next_Paragraph_Version <= Format_Object.Change_Version then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 4) :=
Format_Object.Next_Paragraph_Version;
else -- Use the number we're generating.
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 4) :=
Format_Object.Change_Version;
end if;
Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len + 4;
else
Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len + 2;
end if;
else --if Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Revised or else
-- Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Deleted or else
-- Format_Object.Next_Paragraph_Change_Kind = ARM_Database.Inserted_Normal_Number then
if Is_AARM_Paragraph (Format_Object.Next_Paragraph_Subhead_Type) then
Format_Object.Current_Paragraph_String(1 .. PNum_Pred'Last-1) :=
PNum_Pred(2..PNum_Pred'Last);
AARM_Sub_Num (Format_Object.Next_AARM_Sub);
-- Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len; -- useless assign
if Update_Numbers then
Format_Object.Next_AARM_Sub := Character'Succ(Format_Object.Next_AARM_Sub);
Format_Object.Next_AARM_Insert_Para := 1;
end if;
else
Format_Object.Current_Paragraph_String(1 .. PNum'Last-1) :=
PNum(2..PNum'Last);
Format_Object.Current_Paragraph_Len := PNum'Last - 1;
if Update_Numbers then
Format_Object.Next_Paragraph := Format_Object.Next_Paragraph + 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
Format_Object.Next_AARM_Insert_Para := 1;
end if;
end if;
if Format_Object.Next_Paragraph_Version /= '0' then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 1) :=
'/';
if Format_Object.Next_Paragraph_Version <= Format_Object.Change_Version then
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Format_Object.Next_Paragraph_Version;
else -- Use the number we're generating.
Format_Object.Current_Paragraph_String(Format_Object.Current_Paragraph_Len + 2) :=
Format_Object.Change_Version;
end if;
Format_Object.Current_Paragraph_Len := Format_Object.Current_Paragraph_Len + 2;
-- else no version to display.
end if;
end if;
end Paragraph_Number_String;
function Paragraph_String return String is
-- Returns a string for a paragraph reference, for use in an
-- index entry.
begin
if Format_Object.In_Paragraph then
null; -- It is already is stored.
else -- Generate the next paragraph number.
Paragraph_Number_String (Update_Numbers => False);
end if;
return Format_Object.Current_Paragraph_String (
1 .. Format_Object.Current_Paragraph_Len);
end Paragraph_String;
procedure Check_Paragraph is
-- Open a paragraph if needed before outputting any text that needs
-- one.
procedure Set_Format (For_Type : Paragraph_Type) is
use type ARM_Output.Paragraph_Indent_Type;
function Enclosing_Format return Paragraph_Type is
begin
for I in reverse 1 .. Format_State.Nesting_Stack_Ptr loop
if Format_State.Nesting_Stack(I).Command = Text_Begin and then
(Format_State.Nesting_Stack(I).Is_Formatting) then
return Format_State.Nesting_Stack(I).Old_Next_Paragraph_Format;
end if;
end loop;
return Plain; -- The default format.
end Enclosing_Format;
function Enclosing_Indent return ARM_Output.Paragraph_Indent_Type is
function Nested_Indent (Start_Nesting : in Natural) return ARM_Output.Paragraph_Indent_Type is
begin
for I in reverse 1 .. Start_Nesting loop
if Format_State.Nesting_Stack(I).Command = Text_Begin and then
(Format_State.Nesting_Stack(I).Is_Formatting) then
case Format_State.Nesting_Stack(I).Old_Next_Paragraph_Format is
when Plain | Introduction |
Resolution |
Legality |
Static_Semantics |
Link_Time |
Run_Time |
Bounded_Errors |
Erroneous |
Requirements | -- ImplReq
Documentation | -- DocReq
Metrics |
Permissions | -- ImplPerm
Advice | -- ImplAdvice
Examples =>
return 0; -- No indent.
when Wide_Above =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
return 2; -- Normal indent for annotations.
else
return 0; -- No indent.
end if;
when Syntax =>
return 1; -- One unit.
when Notes | Single_Note => -- Notes (only the numbering varies)
return 1; -- One unit.
when Element_Ref | Child_Ref | Usage_Note => -- Similar to an AARM note.
return 2; -- Normal indent for annotations.
when Language_Design | -- "MetaRules"
Ada83_Inconsistencies | -- Inconsistent83
Ada83_Incompatibilities | -- Incompatible83
Ada83_Extensions | -- Extend83
Ada83_Wording | -- DiffWord83
Ada95_Inconsistencies | -- Inconsistent95
Ada95_Incompatibilities | -- Incompatible95
Ada95_Extensions | -- Extend95
Ada95_Wording | -- DiffWord95
Ada2005_Inconsistencies | -- Inconsistent2005
Ada2005_Incompatibilities | -- Incompatible2005
Ada2005_Extensions | -- Extend2005
Ada2005_Wording | -- DiffWord2005
Ada2012_Inconsistencies | -- Inconsistent2012
Ada2012_Incompatibilities | -- Incompatible2012
Ada2012_Extensions | -- Extend2012
Ada2012_Wording => -- DiffWord2012
return 2; -- Normal indent for annotations.
when Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker | Bare_Annotation =>
return 2; -- Normal indent for annotations.
when Example_Text =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
return 3; -- Three units.
else
return 1; -- One unit.
end if;
when Child_Example_Text =>
return 1 + Nested_Indent(I-1); -- Depends on enclosing.
when Indented_Example_Text =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
return 6; -- Six units.
else
return 4; -- Four units.
end if;
when Code_Indented =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
return 4; -- Four units.
else
return 2; -- Two units.
end if;
when Indent =>
return 1 + Nested_Indent(I-1); -- Depends on enclosing.
when Bulleted | Nested_Bulleted | Nested_X2_Bulleted =>
return 1 + Nested_Indent(I-1); -- Depends on enclosing.
when Display =>
return 1 + Nested_Indent(I-1); -- Depends on enclosing.
when Syntax_Display =>
return 1; -- One unit.
when Enumerated | Nested_Enumerated =>
return 1 + Nested_Indent(I-1); -- Depends on enclosing.
when Syntax_Indented =>
return 1; -- One unit.
when Syntax_Production =>
return Nested_Indent(I-1); -- Depends on enclosing.
when Hanging_Indented_1 =>
return Nested_Indent(I-1) + 1; -- Depends on enclosing, at least 1.
when Hanging_Indented_2 =>
return Nested_Indent(I-1) + 2; -- Depends on enclosing, at least 2.
when Hanging_Indented_3 =>
return Nested_Indent(I-1) + 3; -- Depends on enclosing, at least 3.
when Hanging_Indented_4 =>
return Nested_Indent(I-1) + 4; -- Depends on enclosing, at least 4.
when Small =>
return Nested_Indent(I-1); -- Depends on enclosing, does not change.
when Title =>
return 0; -- No indent.
when In_Table =>
-- Shouldn't get here.
return 0; -- No indent.
end case;
end if;
end loop;
return 0; -- No indent.
end Nested_Indent;
begin
return Nested_Indent (Format_State.Nesting_Stack_Ptr);
end Enclosing_Indent;
function Is_Small_Format_Paragraph (Subhead_Kind : in Paragraph_Type) return Boolean is
-- AARM annotations are in the small font, as are user notes.
begin
if Is_AARM_Paragraph (Subhead_Kind) then
return True; -- AARM paragraphs are always small.
else -- Check the enclosing formatting for "small" or
-- other styles that imply that.
for I in reverse 1 .. Format_State.Nesting_Stack_Ptr loop
if Format_State.Nesting_Stack(I).Command = Text_Begin and then
(Format_State.Nesting_Stack(I).Is_Formatting) then
case Format_State.Nesting_Stack(I).Old_Next_Paragraph_Format is
when Introduction | Syntax | Resolution | Legality |
Static_Semantics | Link_Time |
Run_Time | Bounded_Errors |
Erroneous | Requirements | Documentation |
Metrics | Permissions | Advice | Examples =>
return False;
when Language_Design | Ada83_Inconsistencies |
Ada83_Incompatibilities | Ada83_Extensions |
Ada83_Wording | Ada95_Inconsistencies |
Ada95_Incompatibilities | Ada95_Extensions |
Ada95_Wording | Ada2005_Inconsistencies |
Ada2005_Incompatibilities | Ada2005_Extensions |
Ada2005_Wording | Ada2012_Inconsistencies |
Ada2012_Incompatibilities | Ada2012_Extensions |
Ada2012_Wording | Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker | Bare_Annotation |
Element_Ref | Child_Ref | Usage_Note |
Notes | Single_Note | Small =>
return True;
when Plain | Wide_Above | In_Table | Example_Text | Indented_Example_Text |
Child_Example_Text | Code_Indented | Indent |
Bulleted |
Nested_Bulleted | Nested_X2_Bulleted |
Display | Syntax_Display |
Syntax_Indented | Syntax_Production |
Enumerated | Nested_Enumerated |
Hanging_Indented_1 | Hanging_Indented_2 |
Hanging_Indented_3 | Hanging_Indented_4 |
Title =>
-- This depends on the containing paragraph kind,
-- keep looking.
null;
end case;
end if;
end loop;
return False; -- Don't know.
end if;
end Is_Small_Format_Paragraph;
begin
case For_Type is
when Plain | Introduction |
Resolution |
Legality |
Static_Semantics |
Link_Time |
Run_Time |
Bounded_Errors |
Erroneous |
Requirements | -- ImplReq
Documentation | -- DocReq
Metrics |
Permissions | -- ImplPerm
Advice | -- ImplAdvice
Examples =>
Format_Object.Style := ARM_Output.Normal;
Format_Object.Indent := 0; -- No indent.
Format_Object.No_Breaks := False;
when Wide_Above =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Wide_Above;
Format_Object.Indent := 2; -- Two units.
elsif Format_Object.Last_Paragraph_Subhead_Type = Notes or else
Format_Object.Last_Paragraph_Subhead_Type = Single_Note then
Format_Object.Style := ARM_Output.Small_Wide_Above;
Format_Object.Indent := 1; -- One unit.
else
Format_Object.Style := ARM_Output.Wide_Above;
Format_Object.Indent := 0; -- No indent.
end if;
Format_Object.No_Breaks := False;
when Syntax =>
Format_Object.Style := ARM_Output.Normal;
Format_Object.Indent := 1; -- One unit.
Format_Object.No_Breaks := True;
when Notes | Single_Note | Small => -- Notes (only the numbering varies)
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 1; -- One unit.
Format_Object.No_Breaks := False;
when Element_Ref | Child_Ref | Usage_Note => -- Similar to an AARM note.
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 2; -- Two units.
Format_Object.No_Breaks := False;
when Language_Design | -- "MetaRules"
Ada83_Inconsistencies | -- Inconsistent83
Ada83_Incompatibilities | -- Incompatible83
Ada83_Extensions | -- Extend83
Ada83_Wording | -- DiffWord83
Ada95_Inconsistencies | -- Inconsistent95
Ada95_Incompatibilities | -- Incompatible95
Ada95_Extensions | -- Extend95
Ada95_Wording | -- DiffWord95
Ada2005_Inconsistencies | -- Inconsistent2005
Ada2005_Incompatibilities | -- Incompatible2005
Ada2005_Extensions | -- Extend2005
Ada2005_Wording | -- DiffWord2005
Ada2012_Inconsistencies | -- Inconsistent2012
Ada2012_Incompatibilities | -- Incompatible2012
Ada2012_Extensions | -- Extend2012
Ada2012_Wording => -- DiffWord2012
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 2; -- Two units.
Format_Object.No_Breaks := False;
when Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker | Bare_Annotation =>
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 2; -- Two units.
Format_Object.No_Breaks := False;
when Example_Text | Child_Example_Text |
Indented_Example_Text =>
case Format_Object.Examples_Font is
when ARM_Output.Fixed | ARM_Output.Default =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
--if not Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) and then
-- Format_Object.Last_Paragraph_Subhead_Type /= Small then
-- Ada.Text_IO.Put_Line ("$$ Example in notes: size change, line " & ARM_Input.Line_String (Input_Object));
--end if;
Format_Object.Style := ARM_Output.Small_Examples;
else
Format_Object.Style := ARM_Output.Examples;
end if;
when ARM_Output.Roman =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small;
else
Format_Object.Style := ARM_Output.Normal;
end if;
when ARM_Output.Swiss =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Swiss_Examples;
else
Format_Object.Style := ARM_Output.Swiss_Examples;
end if;
end case;
Format_Object.No_Breaks := True;
if For_Type = Child_Example_Text then
Format_Object.Indent := 1 + Enclosing_Indent;
--Ada.Text_IO.Put_Line ("&& Child example paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
elsif For_Type = Indented_Example_Text then
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Indent := 6; -- Fixed indent.
elsif Format_Object.Last_Paragraph_Subhead_Type = Notes or else
Format_Object.Last_Paragraph_Subhead_Type = Single_Note then
Format_Object.Indent := 5; -- Fixed indent.
else
Format_Object.Indent := 4; -- Fixed indent.
end if;
else
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Indent := 3; -- Fixed indent.
elsif Format_Object.Last_Paragraph_Subhead_Type = Notes or else
Format_Object.Last_Paragraph_Subhead_Type = Single_Note then
Format_Object.Indent := 2; -- Fixed indent.
else
Format_Object.Indent := 1; -- Fixed indent.
end if;
end if;
when Code_Indented =>
if Is_AARM_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 4; -- Four units.
elsif Format_Object.Last_Paragraph_Subhead_Type = Notes or else
Format_Object.Last_Paragraph_Subhead_Type = Single_Note then
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 3; -- Three units.
elsif Format_Object.Last_Paragraph_Subhead_Type = Small then
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 2; -- Two units.
else
Format_Object.Style := ARM_Output.Normal;
Format_Object.Indent := 2; -- Two indent.
end if;
Format_Object.No_Breaks := False;
when Indent =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small;
else
Format_Object.Style := ARM_Output.Normal;
end if;
if Enclosing_Indent = Arm_Output.Paragraph_Indent_Type'Last then
raise Program_Error with
"Overindented (indent) text on line " & ARM_Input.Line_String (Input_Object);
else
Format_Object.Indent := 1 + Enclosing_Indent;
end if;
--Ada.Text_IO.Put_Line ("&& Child Indented paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.No_Breaks := False;
when Bulleted =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Bulleted;
else
Format_Object.Style := ARM_Output.Bulleted;
end if;
if Enclosing_Indent = Arm_Output.Paragraph_Indent_Type'Last then
raise Program_Error with
"Overindented (bullet) text on line " & ARM_Input.Line_String (Input_Object);
else
Format_Object.Indent := 1 + Enclosing_Indent;
end if;
--Ada.Text_IO.Put_Line ("&& Regular bulleted paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Nested_Bulleted =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Nested_Bulleted;
else
Format_Object.Style := ARM_Output.Nested_Bulleted;
end if;
if Enclosing_Indent = Arm_Output.Paragraph_Indent_Type'Last then
raise Program_Error with
"Overindented (nestbullet) text on line " & ARM_Input.Line_String (Input_Object);
else
Format_Object.Indent := 1 + Enclosing_Indent;
end if;
--Ada.Text_IO.Put_Line ("&& Nested bulleted paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Nested_X2_Bulleted =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Nested_Bulleted;
else
Format_Object.Style := ARM_Output.Nested_Bulleted;
end if;
Format_Object.Indent := 1 + Enclosing_Indent;
--Ada.Text_IO.Put_Line ("&& Nested X2 bulleted paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Display =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small;
else
Format_Object.Style := ARM_Output.Normal;
end if;
Format_Object.Indent := 1 + Enclosing_Indent;
--Ada.Text_IO.Put_Line ("&& Display paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.No_Breaks := True;
when Syntax_Display =>
Format_Object.Style := ARM_Output.Small;
Format_Object.Indent := 1;
Format_Object.No_Breaks := True;
when Enumerated =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Enumerated;
else
Format_Object.Style := ARM_Output.Enumerated;
end if;
Format_Object.Indent := 1 + Enclosing_Indent;
--Ada.Text_IO.Put_Line ("&& Regular enumerated paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Nested_Enumerated =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Enumerated;
else
Format_Object.Style := ARM_Output.Enumerated;
end if;
Format_Object.Indent := 1 + Enclosing_Indent;
--Ada.Text_IO.Put_Line ("&& Nested enumerated paragraph, line " & ARM_Input.Line_String (Input_Object) & " EF=" & Paragraph_Type'Image(Enclosing_Format) & " Indent=" &
-- ARM_Output.Paragraph_Indent_Type'Image(Format_Object.Indent));
-- Note: The difference here is the numbering, not the
-- layout.
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Syntax_Indented =>
Format_Object.Style := ARM_Output.Normal;
Format_Object.Indent := 1; -- One unit.
Format_Object.No_Breaks := False;
when Syntax_Production =>
null; -- Leave format alone (but line-breaks are preserved).
Format_Object.No_Breaks := True;
when Hanging_Indented_1 =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Narrow_Hanging;
else -- Normal:
Format_Object.Style := ARM_Output.Narrow_Hanging;
end if;
Format_Object.Indent := 1 + Enclosing_Indent;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Hanging_Indented_2 =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
if Enclosing_Format = Bulleted or else
Enclosing_Format = Enumerated then
Format_Object.Style := ARM_Output.Small_Hanging_in_Bulleted;
-- The right margin is also adjusted in this case.
-- This is a weird special case, used only in
-- RM 11.5.
else
Format_Object.Style := ARM_Output.Small_Medium_Hanging;
end if;
else -- Normal:
if Enclosing_Format = Bulleted or else
Enclosing_Format = Enumerated then
Format_Object.Style := ARM_Output.Hanging_in_Bulleted;
-- The right margin is also adjusted in this case.
else
Format_Object.Style := ARM_Output.Medium_Hanging;
end if;
end if;
Format_Object.Indent := 2 + Enclosing_Indent;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Hanging_Indented_3 =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Wide_Hanging;
else -- Normal:
Format_Object.Style := ARM_Output.Wide_Hanging;
end if;
Format_Object.Indent := 3 + Enclosing_Indent;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Hanging_Indented_4 =>
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small_Giant_Hanging;
else -- Normal:
Format_Object.Style := ARM_Output.Giant_Hanging;
end if;
Format_Object.Indent := 4 + Enclosing_Indent;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.No_Breaks := False;
when Title =>
Format_Object.Style := ARM_Output.Title;
Format_Object.Indent := 0; -- No indent.
Format_Object.No_Breaks := False;
when In_Table =>
-- Shouldn't get here.
if Is_Small_Format_Paragraph (Format_Object.Last_Paragraph_Subhead_Type) then
Format_Object.Style := ARM_Output.Small;
else
Format_Object.Style := ARM_Output.Normal;
end if;
Format_Object.Indent := 0; -- No indent.
Format_Object.No_Breaks := False;
end case;
end Set_Format;
procedure Make_Subhead (For_Type : Paragraph_Type) is
begin
case For_Type is
when Syntax |
Resolution |
Legality |
Static_Semantics |
Link_Time |
Run_Time |
Bounded_Errors |
Erroneous |
Requirements | -- ImplReq
Documentation | -- DocReq
Metrics |
Permissions | -- ImplPerm
Advice | -- ImplAdvice
Examples =>
ARM_Output.Category_Header (Output_Object, Data.Paragraph_Kind_Title(For_Type).Str(1..Data.Paragraph_Kind_Title(For_Type).Length));
Format_Object.Last_Paragraph_Subhead_Type := For_Type;
when Notes | Single_Note => -- Notes
if not Format_Object.Use_ISO_2004_Note_Format then
-- The Notes header looks different from the others.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Small_Header,
Indent => 1,
Number => "",
No_Breaks => True,
Keep_with_Next => True);
ARM_Output.Ordinary_Text (Output_Object, Data.Paragraph_Kind_Title(For_Type).Str(1..Data.Paragraph_Kind_Title(For_Type).Length));
ARM_Output.End_Paragraph (Output_Object);
Format_Object.Last_Paragraph_Subhead_Type := For_Type;
--!!Debug:
--Ada.Text_IO.Put_Line ("Write notes header");
else
null; -- No subheader. We don't change the last
-- subheader generated, either.
end if;
when Language_Design | -- "MetaRules"
Ada83_Inconsistencies | -- Inconsistent83
Ada83_Incompatibilities | -- Incompatible83
Ada83_Extensions | -- Extend83
Ada83_Wording | -- DiffWord83
Ada95_Inconsistencies | -- Inconsistent95
Ada95_Incompatibilities | -- Incompatible95
Ada95_Extensions | -- Extend95
Ada95_Wording | -- DiffWord95
Ada2005_Inconsistencies | -- Inconsistent2005
Ada2005_Incompatibilities | -- Incompatible2005
Ada2005_Extensions | -- Extend2005
Ada2005_Wording | -- DiffWord2005
Ada2012_Inconsistencies | -- Inconsistent2012
Ada2012_Incompatibilities | -- Incompatible2012
Ada2012_Extensions | -- Extend2012
Ada2012_Wording => -- DiffWord2012
ARM_Output.Category_Header (Output_Object, Paragraph_Kind_Title(For_Type).Str(1..Paragraph_Kind_Title(For_Type).Length));
Format_Object.Last_Paragraph_Subhead_Type := For_Type;
when Plain | Introduction | Element_Ref | Child_Ref | Usage_Note =>
null; -- No subheader. We don't change the last
-- subheader generated, either.
when Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker | Bare_Annotation |
Wide_Above | Example_Text | Child_Example_Text |
Indented_Example_Text | Code_Indented | Indent |
Bulleted | Nested_Bulleted | Nested_X2_Bulleted |
Display |
Syntax_Display | Syntax_Indented | Syntax_Production |
Hanging_Indented_1 | Hanging_Indented_2 |
Hanging_Indented_3 | Hanging_Indented_4 | Title |
Enumerated | Nested_Enumerated | Small |
In_Table =>
null; -- No subheader. We don't change the last
-- subheader generated, either.
end case;
end Make_Subhead;
procedure Make_Annotation_Preface (For_Type : Paragraph_Type) is
begin
case For_Type is
when Plain | Introduction |
Syntax |
Resolution |
Legality |
Static_Semantics |
Link_Time |
Run_Time |
Bounded_Errors |
Erroneous |
Requirements | -- ImplReq
Documentation | -- DocReq
Metrics |
Permissions | -- ImplPerm
Advice | -- ImplAdvice
Examples |
Notes | Single_Note |
Language_Design | -- "MetaRules"
Ada83_Inconsistencies | -- Inconsistent83
Ada83_Incompatibilities | -- Incompatible83
Ada83_Extensions | -- Extend83
Ada83_Wording | -- DiffWord83
Ada95_Inconsistencies | -- Inconsistent95
Ada95_Incompatibilities | -- Incompatible95
Ada95_Extensions | -- Extend95
Ada95_Wording | -- DiffWord95
Ada2005_Inconsistencies | -- Inconsistent2005
Ada2005_Incompatibilities | -- Incompatible2005
Ada2005_Extensions | -- Extend2005
Ada2005_Wording | -- DiffWord2005
Ada2012_Inconsistencies | -- Inconsistent2012
Ada2012_Incompatibilities | -- Incompatible2012
Ada2012_Extensions | -- Extend2012
Ada2012_Wording => -- DiffWord2012
null; -- Not an annotation.
when Reason | Ramification | Proof |
Imp_Note | Corr_Change | Discussion |
Honest | Glossary_Marker |
Element_Ref | Child_Ref | Usage_Note =>
declare
Format_Bold : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Format_Bold.Bold := True;
ARM_Output.Text_Format (Output_Object,
Format => Format_Bold);
end;
ARM_Output.Ordinary_Text (Output_Object,
Text => Paragraph_Kind_Title(For_Type).Str(
1..Paragraph_Kind_Title(For_Type).Length));
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
Format_Object.Last_Paragraph_Subhead_Type := For_Type;
when Bare_Annotation =>
null; -- Header (if any) is generated elsewhere.
when Wide_Above |
Example_Text | Child_Example_Text | Indented_Example_Text |
Code_Indented | Indent |
Bulleted | Nested_Bulleted | Nested_X2_Bulleted |
Display | Syntax_Display |
Syntax_Indented | Syntax_Production |
Hanging_Indented_1 | Hanging_Indented_2 |
Hanging_Indented_3 | Hanging_Indented_4 | Title |
Enumerated | Nested_Enumerated | Small |
In_Table =>
null; -- Just a format.
end case;
end Make_Annotation_Preface;
function Show_Leading_Text_for_Paragraph return Boolean is
-- Returns True if the leading text (note number,
-- annotation preface, etc.) should be shown for this paragraph.
-- We assume that the current paragraph has a version less than
-- or equal to the one that we're displaying.
-- ** Note: This is not quite right. If this
-- paragraph is deleted, but a following one needs the
-- leading item, this will still lead the item out.
-- We *do* have enough information for that, at least in the
-- case of annotations: they can be marked as deleted, in
-- which case we don't need them here. *But* that information
-- doesn't get here in the case that we're not showing deletions.
-- I can't think of a fix right now, and the note numbers need
-- fixing ASAP.
begin
--Ada.Text_IO.Put_Line ("Show_Leading_Text, para kind: " &
--ARM_Database.Paragraph_Change_Kind_Type'Image(Format_Object.Next_Paragraph_Change_Kind) &
--"; version=" & Format_Object.Next_Paragraph_Version & "; on line " & Arm_Input.Line_String(Input_Object));
if (ARM_Database."/=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted) and then
ARM_Database."/=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number) and then
ARM_Database."/=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_No_Delete_Message) and then
ARM_Database."/=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message)) then
-- Not a deleted paragraph.
--Ada.Text_IO.Put_Line ("%% True - Not deleted");
return True;
end if;
case Format_Object.Changes is
when ARM_Format.Old_Only =>
-- Display only the original version ('0').
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
--Ada.Text_IO.Put_Line ("%% True - Not original");
return False; -- Not in the original document.
else
--Ada.Text_IO.Put_Line ("%% True - Original");
return True; -- Probably in the original document.
-- (If the paragraph numbers were "new" in a
-- later version, we couldn't tell.)
end if;
when ARM_Format.New_Only =>
-- Display only the version
-- Format_Object.Change_Version, no insertions or deletions.
--Ada.Text_IO.Put_Line ("%% False - New only");
return False; -- This is always deleted.
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
-- Display only the the changes for versions
-- Format_Object.Base_Change_Version ..
-- Format_Object.Change_Version, older changes
-- are applied and newer changes are ignored.
-- (New_Changes shows deletions as a single
-- character for older versions of Word, but otherwise
-- is the same.)
if Format_Object.Next_Paragraph_Version <
Format_Object.Base_Change_Version then
-- Change version is older than we're displaying;
-- no text will be shown.
--Ada.Text_IO.Put_Line ("%% False - show changes, old version");
return False; -- This is always deleted.
else
-- The correct version.
--Ada.Text_IO.Put_Line ("%% True - show changes, new enough version");
return True; -- Show the item, as the old text
-- will be shown as deleted.
end if;
end case;
end Show_Leading_Text_for_Paragraph;
begin
if not Format_Object.In_Paragraph then
-- Output subheader, if needed.
if Format_Object.Next_Paragraph_Subhead_Type /=
Format_Object.Last_Paragraph_Subhead_Type then
if (ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- Nothing at all should be showm.
null;
if Format_Object.Next_Paragraph_Subhead_Type /= Plain or else
Format_Object.Next_Paragraph_Subhead_Type /= Introduction then
Ada.Text_IO.Put_Line(" -- No subhead (DelNoMsg); on line " & Arm_Input.Line_String(Input_Object));
end if;
elsif ((not Format_Object.Number_Paragraphs) or else
Format_Object.No_Para_Num) and then
(ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- Nothing at all should be showm.
null;
if Format_Object.Next_Paragraph_Subhead_Type /= Plain or else
Format_Object.Next_Paragraph_Subhead_Type /= Introduction then
Ada.Text_IO.Put_Line(" -- No subhead (Del-no paranum); on line " & Arm_Input.Line_String(Input_Object));
end if;
else
Make_Subhead (Format_Object.Next_Paragraph_Subhead_Type);
end if;
end if;
-- Set the paragraph format:
Set_Format (Format_Object.Next_Paragraph_Format_Type);
if Format_Object.Number_Paragraphs and then
not Format_Object.No_Para_Num then
-- Format the paragraph number:
Paragraph_Number_String (Update_Numbers => True);
--Ada.Text_IO.Put_Line ("Check_Paragraph, make number " &
--Format_Object.Current_Paragraph_String (1 .. Format_Object.Current_Paragraph_Len) &
--": format= " & Paragraph_Type'Image(Format_Object.Next_Paragraph_Format_Type));
-- ...and start the paragraph:
if (ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- Nothing at all should be showm.
-- ** Warning ** If we lie here, the program will crash!
Format_Object.No_Start_Paragraph := True;
Ada.Text_IO.Put_Line(" -- No Start Paragraph (DelNoMsg)");
else
ARM_Output.Start_Paragraph (Output_Object,
Style => Format_Object.Style,
Indent => Format_Object.Indent,
Number => Format_Object.Current_Paragraph_String (1 .. Format_Object.Current_Paragraph_Len),
No_Prefix => Format_Object.No_Prefix,
Tab_Stops => Format_Object.Paragraph_Tab_Stops,
No_Breaks => Format_Object.No_Breaks or Format_Object.In_Bundle,
Keep_with_Next => Format_Object.Keep_with_Next or Format_Object.In_Bundle,
Space_After => Format_Object.Space_After);
Format_Object.No_Start_Paragraph := False;
end if;
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number) then
-- If needed, make the "deleted text" message.
-- We trust that Next_Paragraph_Change_Kind is not
-- set to Deleted if the version number of the change
-- is beyond the document generation version.
-- (Note that Current_Change_Version may not be set,
-- so it is not safe to test here.)
case Format_Object.Changes is
when ARM_Format.New_Only |
ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
-- Note that we include this in the
-- "Show_Changes" version, even when the item
-- is older than the base change version,
-- so that complete paragraph deletions are obvious,
-- and also so that we can use revision bars rather than
-- displaying the changes in the RM version.
if ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) and then
(Format_Object.Next_Paragraph_Format_Type = Enumerated or else
Format_Object.Next_Paragraph_Format_Type = Nested_Enumerated or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_1 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_2 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_3 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_4) then
-- We're in a hanging style, we need to end hanging first.
-- Nothing else will be displayed; if we didn't end the hang this
-- would end up on the same line as the next paragraph.
-- It's possible that we could have a problem with
-- hanging in one of the other cases if no text will be
-- displayed, but there is no way to know that here.
ARM_Output.End_Hang_Item (Output_Object);
end if;
ARM_Output.Text_Format (Output_Object,
Format => (Bold => Format_Object.Text_Format.Bold,
Italic => True,
Font => Format_Object.Text_Format.Font,
Color => Format_Object.Text_Format.Color,
Change => ARM_Output.None, -- Never mark this as changed!!
Version => '0', Added_Version => '0', -- Not used.
Size => ARM_Output."-"(Format_Object.Text_Format.Size, 1),
Location => Format_Object.Text_Format.Location));
ARM_Output.Ordinary_Text (Output_Object,
Text => "This paragraph was deleted.");
ARM_Output.Text_Format (Output_Object, -- Restore the format.
Format => Format_Object.Text_Format);
when ARM_Format.Old_Only => null; -- Not deleted.
end case;
end if;
Format_Object.In_Paragraph := True;
Format_Object.Last_Non_Space := False;
else -- No paragraph numbers (or if the paragraph
-- number has been suppressed with @NoParaNum):
--Ada.Text_IO.Put_Line ("Check_Paragraph, no number: format= " & Paragraph_Type'Image(Format_Object.Next_Paragraph_Format_Type) &
-- " output style= " & ARM_Output.Paragraph_Style_Type'Image(Format_Object.Style));
-- Start the paragraph:
if (ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind, ARM_Database.Deleted_Inserted_Number)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- Nothing at all should be showm.
-- ** Warning ** If we lie here, the program will crash!
Format_Object.No_Start_Paragraph := True;
Ada.Text_IO.Put_Line(" -- No Start Paragraph (Del-NewOnly)");
else
ARM_Output.Start_Paragraph (Output_Object,
Style => Format_Object.Style,
Indent => Format_Object.Indent,
Number => "",
No_Prefix => Format_Object.No_Prefix,
Tab_Stops => Format_Object.Paragraph_Tab_Stops,
No_Breaks => Format_Object.No_Breaks or Format_Object.In_Bundle,
Keep_with_Next => Format_Object.Keep_with_Next or Format_Object.In_Bundle,
Space_After => Format_Object.Space_After);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
Format_Object.Current_Paragraph_Len := 0; -- Empty paragraph number.
Format_Object.No_Para_Num := False;
end if;
end if;
if not Format_Object.No_Prefix then
if Format_Object.Next_Paragraph_Format_Type = Notes and then
Show_Leading_Text_for_Paragraph then
if not Format_Object.Use_ISO_2004_Note_Format then
-- Output the note number (Ada95 format).
declare
NNum : constant String := Integer'Image(Format_Object.Next_Note);
begin
ARM_Output.Ordinary_Text (Output_Object,
NNum(2..NNum'Last));
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
Format_Object.Next_Note := Format_Object.Next_Note + 1;
end;
else
-- Output the note header (ISO 2004 format).
declare
NNum : constant String := Integer'Image(Format_Object.Next_Note);
begin
ARM_Output.Ordinary_Text (Output_Object,
"NOTE " & NNum(2..NNum'Last));
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
Format_Object.Next_Note := Format_Object.Next_Note + 1;
end;
end if;
elsif Format_Object.Next_Paragraph_Format_Type = Single_Note and then
Show_Leading_Text_for_Paragraph then
if not Format_Object.Use_ISO_2004_Note_Format then
-- No note number, and nothing else needed.
null;
else
-- Output the note header (ISO 2004 format)
-- without a number.
ARM_Output.Ordinary_Text (Output_Object,
"NOTE");
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
end if;
elsif (Format_Object.Next_Paragraph_Format_Type = Enumerated or else
Format_Object.Next_Paragraph_Format_Type = Nested_Enumerated) and then
Show_Leading_Text_for_Paragraph then
-- Output the item number.
if Format_Object.Use_ISO_2004_Note_Format then
if Format_Object.Enumerated_Level <= 1 then -- Outer list.
-- Lower case letters for list:
ARM_Output.Ordinary_Text (Output_Object,
Character'Val ((Format_Object.Next_Enumerated_Num - 1) +
Character'Pos ('a'))
& ')');
ARM_Output.End_Hang_Item (Output_Object);
Format_Object.Next_Enumerated_Num := Format_Object.Next_Enumerated_Num + 1;
else -- numbered.
declare
NNum : constant String := Integer'Image(Format_Object.Next_Enumerated_Num);
begin
ARM_Output.Ordinary_Text (Output_Object,
NNum(2..NNum'Last) & ')');
ARM_Output.End_Hang_Item (Output_Object);
Format_Object.Next_Enumerated_Num := Format_Object.Next_Enumerated_Num + 1;
end;
end if;
else -- Ada 95 lists.
declare
NNum : constant String := Integer'Image(Format_Object.Next_Enumerated_Num);
begin
ARM_Output.Ordinary_Text (Output_Object,
NNum(2..NNum'Last) & '.');
ARM_Output.End_Hang_Item (Output_Object);
Format_Object.Next_Enumerated_Num := Format_Object.Next_Enumerated_Num + 1;
end;
end if;
end if;
else -- No prefix marked, meaning no number.
Format_Object.No_Prefix := False; -- Reset.
end if;
Format_Object.Last_Non_Space := False;
Format_Object.Keep_with_Next := False; -- Reset for next paragraph.
Format_Object.Space_After := ARM_Output.Normal; -- Reset for next paragraph.
-- Output the annotation preface, if needed.
if Format_Object.Next_Paragraph_Subhead_Type /=
Format_Object.Last_Paragraph_Subhead_Type then
if Show_Leading_Text_for_Paragraph then
Make_Annotation_Preface (Format_Object.Next_Paragraph_Subhead_Type);
end if;
end if;
if Format_Object.References /= null then
-- We assume these are only stored here if we want to see
-- them on *this* paragraph. Thus, we just output them if
-- they exist here. Note: This deallocates the references
-- after writing them.
if Format_Object.No_Start_Paragraph then
-- Oh-oh! Can't generate references; there aren't
-- supposed to be any at this point.
Ada.Text_IO.Put_Line ("** References generated for no display paragraph; line " & ARM_Input.Line_String (Input_Object));
else
pragma Warnings (Off, "writable actual for ""List"" overlaps with actual for ""Format_Object""");
Make_References (Format_Object.References, Format_Object, Output_Object);
pragma Warnings (On);
end if;
end if;
-- Reset the "next" paragraph kind and version (we have to
-- wait, so that we can use this to determine whether
-- note numbers and things are output):
Format_Object.Next_Paragraph_Change_Kind := ARM_Database.None;
Format_Object.Next_Paragraph_Version := '0';
-- else already in a paragraph.
end if;
end Check_Paragraph;
procedure Check_End_Paragraph is
-- Check for the end of a paragraph; closing it if necessary.
-- We will never be in a paragraph after this routine.
begin
if Format_Object.In_Paragraph then
if not Format_Object.No_Start_Paragraph then
ARM_Output.End_Paragraph (Output_Object);
--else Ada.Text_IO.Put_Line("No Start Paragraph, so no End Paragraph");
end if;
Format_Object.In_Paragraph := False;
Format_Object.No_Start_Paragraph := False;
Format_Object.No_Para_Num := False;
-- Make sure any "leftover"
-- NoParaNums are cleared; we don't want this lasting into
-- the next paragraph.
if Format_Object.In_Change then
Ada.Text_IO.Put_Line ("** Paragraph end while in change; line " & ARM_Input.Line_String (Input_Object));
Format_Object.In_Change := False;
end if;
-- Check command stack for any open formatting commands,
-- and complain (these won't be closed properly and chaos
-- may result):
for I in reverse 1 .. Format_State.Nesting_Stack_Ptr loop
if Format_State.Nesting_Stack (I).Command in Bold .. Tab_Set then
-- There is a formatting command active.
-- (Note: not all of these can be on the stack.)
Ada.Text_IO.Put_Line ("** Paragraph end while in formatting command " &
Data.Command_Type'Image(Format_State.Nesting_Stack (I).Command) &
"; line " & ARM_Input.Line_String (Input_Object));
exit;
end if;
end loop;
end if;
end Check_End_Paragraph;
type DIE_Kind is (None, Is_Root, Is_Partial);
procedure Display_Index_Entry (Term_Text : in String;
Special : in DIE_Kind := None) is
-- If necessary, display the index entry for Term_Text.
Is_AARM : constant Boolean := Is_AARM_Paragraph (Format_Object.Next_Paragraph_Subhead_Type);
use type ARM_Output.Size_Type;
begin
if Format_Object.Display_Index_Entries then
Check_Paragraph;
if not Is_AARM then
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => False,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => -1,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
end if;
ARM_Output.Ordinary_Character (Output_Object, '{');
if not Is_AARM then
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => True,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => -1,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
else
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => True,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => 0,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
end if;
ARM_Output.Ordinary_Text (Output_Object, ARM_Index.Clean(Term_Text, Remove_Soft_Hyphens => True));
if not Is_AARM then
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => False,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => -1,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
else
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => False,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => 0,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
end if;
case Special is
when None => null;
when Is_Root => ARM_Output.Ordinary_Text (Output_Object, " [distributed]");
when Is_Partial => ARM_Output.Ordinary_Text (Output_Object, " [partial]");
end case;
ARM_Output.Ordinary_Character (Output_Object, '}');
if not Is_AARM then
ARM_Output.Text_Format (Output_Object,
Format => (Bold => False, Italic => False,
Font => ARM_Output.Default,
Color => ARM_Output.Default,
Size => 0,
Change => Format_Object.Text_Format.Change,
Version => Format_Object.Text_Format.Version,
Added_Version => Format_Object.Text_Format.Added_Version,
Location => ARM_Output.Normal));
end if;
ARM_Output.Ordinary_Character (Output_Object, ' ');
Format_Object.Last_Non_Space := False;
-- else not displayed.
end if;
end Display_Index_Entry;
procedure Parse_Tab_Stops (Stops : in String;
Tabs : in out ARM_Output.Tab_Info) is
-- Parse "Stops" as a tab string; store the result in Tabs.
Loc : Natural := Stops'First;
begin
-- Parse tab stops:
-- <tab_stop> ::= <modifier><pica_count_literal>
-- <modifier> ::= L | P
-- <tab_stops> ::= <tab_stop> {, <tab_stop>}
while Loc <= Stops'Length loop
Tabs.Number := Tabs.Number + 1;
if Stops(Loc) = 'l' or Stops(Loc) = 'L' then
Tabs.Stops(Tabs.Number).Kind :=
ARM_Output.Left_Fixed;
Loc := Loc + 1;
elsif Stops(Loc) = 'p' or Stops(Loc) = 'P' then
Tabs.Stops(Tabs.Number).Kind :=
ARM_Output.Left_Proportional;
Loc := Loc + 1;
else -- Default:
Tabs.Stops(Tabs.Number).Kind :=
ARM_Output.Left_Fixed;
end if;
while Loc <= Stops'Length loop
if Stops(Loc) in '0' .. '9' then
Tabs.Stops(Tabs.Number).Stop :=
Tabs.Stops(Tabs.Number).Stop * 10 +
Character'Pos(Stops(Loc)) - Character'Pos('0');
Loc := Loc + 1;
else
exit; -- Number ended.
end if;
end loop;
if Tabs.Stops(Tabs.Number).Stop = 0 then
Tabs.Number := Tabs.Number - 1;
Ada.Text_IO.Put_Line (" ** Bad tab stop format, position" & Natural'Image(Loc) &
" in [" & Stops & "] from line " &
ARM_Input.Line_String (Input_Object));
exit; -- Give up on this tabset.
elsif Tabs.Number < 1 and then
Tabs.Stops(Tabs.Number-1).Stop >=
Tabs.Stops(Tabs.Number).Stop then
Tabs.Number := Tabs.Number - 1;
Ada.Text_IO.Put_Line (" ** Bad tab stop, less than previous, at position" & Natural'Image(Loc) &
" in [" & Stops & "] from line " &
ARM_Input.Line_String (Input_Object));
exit; -- Give up on this tabset.
end if;
if Loc > Stops'Length then
exit; -- Finished.
elsif Stops(Loc) = ',' then
Loc := Loc + 1;
if Loc > Stops'Length then
Ada.Text_IO.Put_Line (" ** Bad tab stop set format, ends with comma in [" &
Stops & "] from line " &
ARM_Input.Line_String (Input_Object));
exit; -- Give up on this tabset.
end if;
end if;
-- Skip any blanks in between.
while Loc <= Stops'Length and then Stops(Loc) = ' ' loop
Loc := Loc + 1;
end loop;
end loop;
end Parse_Tab_Stops;
procedure Write_Subindex (
Subindex_Object : in out ARM_Subindex.Subindex_Type;
Format_Object : in out Format_Type;
Output_Object : in out ARM_Output.Output_Type'Class;
Minimize_Lines : in Boolean) is
-- Writes a subindex for the document.
begin
Check_End_Paragraph;
-- Insert a blank paragraph:
ARM_Output.Start_Paragraph (Output_Object, ARM_Output.Normal,
Indent => 0, Number => "");
ARM_Output.Hard_Space (Output_Object);
ARM_Output.End_Paragraph (Output_Object);
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 2);
ARM_Subindex.Write_Subindex (
Subindex_Object,
Output_Object,
Use_Paragraphs => Format_Object.Number_Paragraphs,
Minimize_Lines => Minimize_Lines);
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 1);
-- Not in a paragraph here, either.
end Write_Subindex;
procedure Simple_Subindex_Item (
Subindex_Object : in out ARM_Subindex.Subindex_Type;
Format_Object : in out Format_Type;
Output_Object : in out ARM_Output.Output_Type'Class;
Entity_Kind_Name : in String) is
-- Create a simple subindex item; the command has a single
-- parameter <defn>.
-- Create an "In_Unit" entry for the item;
-- Also create two regular index entries:
-- One for <defn> with a secondary entry of "@i{in} <Unit>"
-- (where Unit is the unit saved by a previous RootLibUnit or
-- ChildUnit.),
-- and a Second (only for version < 2 and if the entity name is
-- non-null) for
-- "Language-Defined <Entity>" with a
-- secondary entry of "<defn> @i{in} <Unit>".
-- Also outputs the <defn> parameter to the output file.
Entity : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key := ARM_Index.Get_Key;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Entity,
Len);
-- Determine what to do with the "Language-Defined" entry:
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => '2',
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
if Entity_Kind_Name'Length = 0 or else
Disposition = Do_Not_Display_Text then
null; -- Ignore this.
elsif Disposition = ARM_Output.None then
-- Normal reference:
ARM_Index.Add_Reusing_Key (
Term => "Language-Defined " & Entity_Kind_Name,
Subterm => Entity(1..Len) & " in " &
Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Index.SubDeclaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
-- Note that the Subdeclaration type changes the
-- "in" into italics.
elsif Disposition = ARM_Output.Deletion then
null; -- Ignore this (no change info in the index).
else -- Insertion.
raise Program_Error; -- An insertion inside of a deletion command!
end if;
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
if Format_Object.Unit_Len = 0 then
Ada.Text_IO.Put_Line ("** No unit defined for index entry expecting one on line " & ARM_Input.Line_String (Input_Object));
ARM_Index.Add_Reusing_Key (
Term => Entity(1..Len),
Subterm => "*unknown*",
Kind => ARM_Index.Declaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Subindex_Object,
Entity => Entity(1..Len),
From_Unit => "*unknown*",
Kind => ARM_Subindex.In_Unit,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
else
ARM_Index.Add_Reusing_Key (
Term => Entity(1..Len),
Subterm => Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Index.Declaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Subindex_Object,
Entity => Entity(1..Len),
From_Unit => Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Subindex.In_Unit,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
end if;
ARM_Output.Ordinary_Text (Output_Object, Entity(1..Len));
Format_Object.Last_Non_Space := True;
end Simple_Subindex_Item;
procedure Child_Unit (
Subindex_Object : in out ARM_Subindex.Subindex_Type;
Format_Object : in out Format_Type;
Output_Object : in out ARM_Output.Output_Type'Class) is
-- Generates three index entries: An index entry for <child>, with
-- a secondary of "@i{child of} <parent>", an index entry for
-- "Language-Defined Library Units" with a secondary entry of
-- <parent>.<child>, and an index entry for <parent>.<child>. The
-- Unit is set to <parent>.<child>. (For version 2 or later, the
-- Language-Defined entry is not generated.) The first entry is
-- added to the subindex list as well.
Close_Ch : Character;
Parent, Child : String(1..80);
PLen, CLen : Natural := 0;
Key : ARM_Index.Index_Key := ARM_Index.Get_Key;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Parent" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Parent,
PLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Child" & (6..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Child,
CLen);
-- else no parameter. Weird.
end if;
-- Set the current unit for future use:
Format_Object.Unit_Len := PLen + CLen + 1;
Format_Object.Unit (1..Format_Object.Unit_Len) :=
Parent(1..PLen) & '.' & Child(1..CLen);
ARM_Index.Add_Reusing_Key (
Term => Child(1..CLen),
Subterm => Parent(1..PLen),
Kind => ARM_Index.Child_Unit_Parent,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
-- Determine what to do with the "Language-Defined" entry:
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => '2',
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
null; -- Ignore this.
elsif Disposition = ARM_Output.None then
-- Make reference:
ARM_Index.Add_Reusing_Key (
Term => "Language-Defined Library Units",
Subterm => Parent(1..PLen) & '.' & Child(1..CLen),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
elsif Disposition = ARM_Output.Deletion then
null; -- Ignore this (no change info in the index).
else -- Insertion.
raise Program_Error; -- An insertion inside of a deletion command!
end if;
ARM_Index.Add_Reusing_Key (
Term => Parent(1..PLen) & '.' & Child(1..CLen),
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Subindex_Object,
Entity => Child(1..CLen),
From_Unit => Parent(1..PLen),
Kind => ARM_Subindex.Child_of_Parent,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end Child_Unit;
procedure Process_Begin is
-- Process a "begin". The "begin" has been stacked.
procedure Toss_for_RM (Paragraph_Kind_Name : in String) is
-- Call this for AARM-only sections.
-- It skips *everything* until the matching end. This includes
-- index references, section references, and the like. Anything
-- that ought to be in the RM should be moved outside of the
-- AARM specific code. Thus, we can use a fairly simple text
-- skip.
Ch : Character;
Close_Ch : Character;
Command_Name : ARM_Input.Command_Name_Type;
begin
-- Skip everything up to the next @end{<Paragraph_Kind_Name...
-- then pop the stack and return.
loop
ARM_Input.Get_Char (Input_Object, Ch);
while Ch /= '@' loop
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
Arm_Input.Get_Name (Input_Object, Command_Name, Null_Name_Allowed => True);
-- Get the command name.
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Command_Name, Ada.Strings.Right)) /= "end" then
-- Not an "end" command, keep going.
null;
else -- An End command, check if this is the one we want:
ARM_Input.Get_Char (Input_Object, Ch);
if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
Close_Ch := ARM_Input.Get_Close_Char (Ch);
Arm_Input.Get_Name (Input_Object, Command_Name); -- Get the end "type".
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Command_Name, Ada.Strings.Right)) /= Paragraph_Kind_Name then
null; -- Wrong end, keep going.
else -- Right end!
-- Skip to the close character:
while Ch /= Close_Ch loop
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
-- Unstack the "begin".
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (End AARM-Only)");
-- And we're done with this "begin".
return;
end if;
else -- No parameter, forget it.
null;
end if;
end if;
end loop;
end Toss_for_RM;
begin
Check_End_Paragraph; -- End any paragraph that we're in.
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "comment" then
Toss_for_RM ("comment");
-- Format only:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "wideabove" then
Format_Object.Next_Paragraph_Format_Type := Wide_Above;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "example" then
Format_Object.Next_Paragraph_Format_Type := Example_Text;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "childexample" then
Format_Object.Next_Paragraph_Format_Type := Child_Example_Text;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "descexample" then
Format_Object.Next_Paragraph_Format_Type := Indented_Example_Text;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "describecode" then
Format_Object.Next_Paragraph_Format_Type := Code_Indented;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "indent" then
Format_Object.Next_Paragraph_Format_Type := Indent;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "itemize" then
Format_Object.Next_Paragraph_Format_Type := Bulleted;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "inneritemize" then
Format_Object.Next_Paragraph_Format_Type := Nested_Bulleted;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "innerinneritemize" then
Format_Object.Next_Paragraph_Format_Type := Nested_X2_Bulleted;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "display" then
Format_Object.Next_Paragraph_Format_Type := Display;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "syntaxdisplay" then
Format_Object.Next_Paragraph_Format_Type := Syntax_Display;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "syntaxtext" then
Format_Object.Next_Paragraph_Format_Type := Syntax_Indented;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "description" then
Format_Object.Next_Paragraph_Format_Type := Hanging_Indented_3;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "small" then
Format_Object.Next_Paragraph_Format_Type := Small;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "enumerate" then
Format_Object.Next_Paragraph_Format_Type := Enumerated;
Format_Object.Next_Enumerated_Num := 1;
Format_Object.Enumerated_Level := Format_Object.Enumerated_Level + 1;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "innerenumerate" then
Format_Object.Next_Paragraph_Format_Type := Nested_Enumerated;
Format_Object.Next_Enumerated_Num := 1;
Format_Object.Enumerated_Level := Format_Object.Enumerated_Level + 1;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "hang1list" then
Format_Object.Next_Paragraph_Format_Type := Hanging_Indented_1;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "hang2list" then
Format_Object.Next_Paragraph_Format_Type := Hanging_Indented_2;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "hang3list" then
Format_Object.Next_Paragraph_Format_Type := Hanging_Indented_3;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "hang4list" then
Format_Object.Next_Paragraph_Format_Type := Hanging_Indented_4;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "title" then
Format_Object.Next_Paragraph_Format_Type := Title;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "bundle" then
-- Should prevent any page breaks until the "end". Not
-- implemented currently.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False; -- Leave the format alone.
Format_Object.In_Bundle := True; -- We don't need to stack this,
-- because once we're in it, we can't leave it until the @End.
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "twocol" then
-- Two column; no affect on format.
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 2);
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "fourcol" then
-- Four column; no affect on format.
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 4);
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False;
-- RM groupings:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "intro" then
Format_Object.Next_Paragraph_Format_Type := Introduction;
Format_Object.Next_Paragraph_Subhead_Type := Introduction;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "syntax" then
Format_Object.Next_Paragraph_Format_Type := Syntax;
Format_Object.Next_Paragraph_Subhead_Type := Syntax;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "resolution" then
Format_Object.Next_Paragraph_Format_Type := Resolution;
Format_Object.Next_Paragraph_Subhead_Type := Resolution;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "legality" then
Format_Object.Next_Paragraph_Format_Type := Legality;
Format_Object.Next_Paragraph_Subhead_Type := Legality;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "staticsem" then
Format_Object.Next_Paragraph_Format_Type := Static_Semantics;
Format_Object.Next_Paragraph_Subhead_Type := Static_Semantics;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "linktime" then
Format_Object.Next_Paragraph_Format_Type := Link_Time;
Format_Object.Next_Paragraph_Subhead_Type := Link_Time;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "runtime" then
Format_Object.Next_Paragraph_Format_Type := Run_Time;
Format_Object.Next_Paragraph_Subhead_Type := Run_Time;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "bounded" then
Format_Object.Next_Paragraph_Format_Type := Bounded_Errors;
Format_Object.Next_Paragraph_Subhead_Type := Bounded_Errors;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "erron" then
Format_Object.Next_Paragraph_Format_Type := Erroneous;
Format_Object.Next_Paragraph_Subhead_Type := Erroneous;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "implreq" then
Format_Object.Next_Paragraph_Format_Type := Requirements;
Format_Object.Next_Paragraph_Subhead_Type := Requirements;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "docreq" then
Format_Object.Next_Paragraph_Format_Type := Documentation;
Format_Object.Next_Paragraph_Subhead_Type := Documentation;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "metrics" then
Format_Object.Next_Paragraph_Format_Type := Metrics;
Format_Object.Next_Paragraph_Subhead_Type := Metrics;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "implperm" then
Format_Object.Next_Paragraph_Format_Type := Permissions;
Format_Object.Next_Paragraph_Subhead_Type := Permissions;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "impladvice" then
Format_Object.Next_Paragraph_Format_Type := Advice;
Format_Object.Next_Paragraph_Subhead_Type := Advice;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "examples" then
Format_Object.Next_Paragraph_Format_Type := Examples;
Format_Object.Next_Paragraph_Subhead_Type := Examples;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "notes" then
Format_Object.Next_Paragraph_Format_Type := Notes;
Format_Object.Next_Paragraph_Subhead_Type := Notes;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "singlenote" then
Format_Object.Next_Paragraph_Format_Type := Single_Note;
Format_Object.Next_Paragraph_Subhead_Type := Single_Note;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "rmonly" then
if Format_Object.Include_Annotations then -- AARM, but this is RM-only.
Toss_for_RM ("rmonly");
else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False; -- Leave the format alone.
end if;
-- NotISO text:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "notiso" then
if Format_Object.Include_ISO then
Toss_for_RM ("notiso"); -- This text does not appear in ISO documents.
else -- not ISO
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False; -- Leave the format alone.
end if;
--!!Debug:
---Ada.Text_IO.Put_Line ("Next=" & Paragraph_Type'Image(Format_Object.Next_Paragraph_Subhead_Type));
-- ISOOnly text:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "isoonly" then
if Format_Object.Include_ISO then
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Is_Formatting
:= False; -- Leave the format alone.
else -- Not ISO
Toss_for_RM ("isoonly"); -- This text does not appear in non-ISO documents.
end if;
-- AARM groupings:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "metarules" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Language_Design;
Format_Object.Next_Paragraph_Subhead_Type := Language_Design;
else -- Don't show annotations.
Toss_for_RM ("metarules");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "inconsistent83" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada83_Inconsistencies;
Format_Object.Next_Paragraph_Subhead_Type := Ada83_Inconsistencies;
else -- Don't show annotations.
Toss_for_RM ("inconsistent83");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "incompatible83" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada83_Incompatibilities;
Format_Object.Next_Paragraph_Subhead_Type := Ada83_Incompatibilities;
else -- Don't show annotations.
Toss_for_RM ("incompatible83");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "extend83" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada83_Extensions;
Format_Object.Next_Paragraph_Subhead_Type := Ada83_Extensions;
else -- Don't show annotations.
Toss_for_RM ("extend83");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "diffword83" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada83_Wording;
Format_Object.Next_Paragraph_Subhead_Type := Ada83_Wording;
else -- Don't show annotations.
Toss_for_RM ("diffword83");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "inconsistent95" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada95_Inconsistencies;
Format_Object.Next_Paragraph_Subhead_Type := Ada95_Inconsistencies;
else -- Don't show annotations.
Toss_for_RM ("inconsistent95");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "incompatible95" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada95_Incompatibilities;
Format_Object.Next_Paragraph_Subhead_Type := Ada95_Incompatibilities;
else -- Don't show annotations.
Toss_for_RM ("incompatible95");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "extend95" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada95_Extensions;
Format_Object.Next_Paragraph_Subhead_Type := Ada95_Extensions;
else -- Don't show annotations.
Toss_for_RM ("extend95");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "diffword95" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada95_Wording;
Format_Object.Next_Paragraph_Subhead_Type := Ada95_Wording;
else -- Don't show annotations.
Toss_for_RM ("diffword95");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "inconsistent2005" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2005_Inconsistencies;
Format_Object.Next_Paragraph_Subhead_Type := Ada2005_Inconsistencies;
else -- Don't show annotations.
Toss_for_RM ("inconsistent2005");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "incompatible2005" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2005_Incompatibilities;
Format_Object.Next_Paragraph_Subhead_Type := Ada2005_Incompatibilities;
else -- Don't show annotations.
Toss_for_RM ("incompatible2005");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "extend2005" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2005_Extensions;
Format_Object.Next_Paragraph_Subhead_Type := Ada2005_Extensions;
else -- Don't show annotations.
Toss_for_RM ("extend2005");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "diffword2005" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2005_Wording;
Format_Object.Next_Paragraph_Subhead_Type := Ada2005_Wording;
else -- Don't show annotations.
Toss_for_RM ("diffword2005");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "inconsistent2012" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2012_Inconsistencies;
Format_Object.Next_Paragraph_Subhead_Type := Ada2012_Inconsistencies;
else -- Don't show annotations.
Toss_for_RM ("inconsistent2012");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "incompatible2012" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2012_Incompatibilities;
Format_Object.Next_Paragraph_Subhead_Type := Ada2012_Incompatibilities;
else -- Don't show annotations.
Toss_for_RM ("incompatible2012");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "extend2012" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2012_Extensions;
Format_Object.Next_Paragraph_Subhead_Type := Ada2012_Extensions;
else -- Don't show annotations.
Toss_for_RM ("extend2012");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "diffword2012" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ada2012_Wording;
Format_Object.Next_Paragraph_Subhead_Type := Ada2012_Wording;
else -- Don't show annotations.
Toss_for_RM ("diffword2012");
end if;
-- ASIS groupings:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "elementref" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Element_Ref;
Format_Object.Next_Paragraph_Subhead_Type := Element_Ref;
else -- Don't show annotations.
Toss_for_RM ("elementref");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "childref" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Child_Ref;
Format_Object.Next_Paragraph_Subhead_Type := Child_Ref;
else -- Don't show annotations.
Toss_for_RM ("childref");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "usagenote" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Usage_Note;
Format_Object.Next_Paragraph_Subhead_Type := Usage_Note;
else -- Don't show annotations.
Toss_for_RM ("usagenote");
end if;
-- AARM annotations:
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "discussion" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Discussion;
Format_Object.Next_Paragraph_Subhead_Type := Discussion;
else -- Don't show annotations.
Toss_for_RM ("discussion");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "reason" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Reason;
Format_Object.Next_Paragraph_Subhead_Type := Reason;
else -- Don't show annotations.
Toss_for_RM ("reason");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "ramification" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Ramification;
Format_Object.Next_Paragraph_Subhead_Type := Ramification;
else -- Don't show annotations.
Toss_for_RM ("ramification");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "theproof" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Proof;
Format_Object.Next_Paragraph_Subhead_Type := Proof;
else -- Don't show annotations.
Toss_for_RM ("theproof");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "implnote" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Imp_Note;
Format_Object.Next_Paragraph_Subhead_Type := Imp_Note;
else -- Don't show annotations.
Toss_for_RM ("implnote");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "honest" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Honest;
Format_Object.Next_Paragraph_Subhead_Type := Honest;
else -- Don't show annotations.
Toss_for_RM ("honest");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "glossarymarker" then
if Format_Object.Include_Annotations then
Format_Object.Next_Paragraph_Format_Type := Glossary_Marker;
Format_Object.Next_Paragraph_Subhead_Type := Glossary_Marker;
else -- Don't show annotations.
Toss_for_RM ("glossarymarker");
end if;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right))
= "aarmonly" then
if Format_Object.Include_Annotations then
null; -- Leave the format alone.
else -- Don't show annotations.
Toss_for_RM ("aarmonly");
end if;
else
Ada.Text_IO.Put_Line (" -- Unknown 'begin' type - " &
Ada.Strings.Fixed.Trim (Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
end Process_Begin;
procedure Process_Command_with_Parameter is
-- Process the start of a command with a parameter.
-- The parameter character has been processed, and
-- a stack item pushed.
function Get_NT return String is
-- Local routine:
-- Return the "current" non-terminal from
-- the Syntax_NT string. Handles @Chg.
begin
return Get_Current_Item (Format_Object, Input_Object,
Format_Object.Syntax_NT (1 .. Format_Object.Syntax_NT_Len));
end Get_NT;
function Get_Old_NT return String is
-- Local routine:
-- Return the "current" non-terminal from
-- the Syntax_NT string. Handles @Chg.
begin
return Get_Old_Item (Format_Object, Input_Object,
Format_Object.Syntax_NT (1 .. Format_Object.Syntax_NT_Len));
end Get_Old_NT;
procedure Get_Change_Version (Is_First : in Boolean;
Version : out Character) is
-- Get a parameter named "Version",
-- containing a character representing the version number.
Ch, Close_Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Version" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => Is_First,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the version character:
ARM_Input.Get_Char (Input_Object, Version);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for change version on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
-- else no parameter. Weird.
end if;
end Get_Change_Version;
procedure Get_Change_Kind (Kind : out ARM_Database.Paragraph_Change_Kind_Type) is
-- Get a parameter named "Kind", containing a word representing
-- a change kind.
Kind_Name : ARM_Input.Command_Name_Type;
Ch, Close_Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Kind" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the kind word:
Arm_Input.Get_Name (Input_Object, Kind_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for change kind on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"revised" then
Kind := ARM_Database.Revised;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"revisedadded" then
Kind := ARM_Database.Revised_Inserted_Number;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"added" then
Kind := ARM_Database.Inserted;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"addednormal" then
Kind := ARM_Database.Inserted_Normal_Number;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"deleted" then
Kind := ARM_Database.Deleted;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"deletedadded" then
Kind := ARM_Database.Deleted_Inserted_Number;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"deletednodelmsg" then
Kind := ARM_Database.Deleted_No_Delete_Message;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right)) =
"deletedaddednodelmsg" then
Kind := ARM_Database.Deleted_Inserted_Number_No_Delete_Message;
else
Ada.Text_IO.Put_Line (" ** Bad kind for change kind: " &
Ada.Strings.Fixed.Trim (Kind_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
-- else no parameter. Weird.
end if;
end Get_Change_Kind;
procedure Get_Boolean (Param_Name : in ARM_Input.Command_Name_Type;
Result : out Boolean) is
-- Get a boolean value from a parameter named Param_Name.
Ch, Close_Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => Param_Name,
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the Boolean character:
ARM_Input.Get_Char (Input_Object, Ch);
case Ch is
when 'F' | 'f' | 'N' | 'n' =>
Result := False;
when 'T' | 't' | 'Y' | 'y' =>
Result := True;
when others =>
Ada.Text_IO.Put_Line (" ** Bad value for boolean parameter " &
Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end case;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for boolean parameter " &
Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
-- else no parameter. Weird.
end if;
end Get_Boolean;
procedure Gen_Ref_or_ARef_Parameter (Display_It : Boolean) is
-- Generate (and read) a "Ref" or "ARef" parameter, containing
-- a DR or AI reference. Generate it into the document only
-- if Display_It is True.
Ch, Close_Ch : Character;
Ref_Name : ARM_Input.Command_Name_Type;
Len : Natural;
Which_Param : ARM_Input.Param_Num;
New_Ref, Cursor : Reference_Ptr;
begin
ARM_Input.Check_One_of_Parameter_Names (Input_Object,
Param_Name_1 => "Ref" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_2 => "ARef" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Found => Which_Param,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the reference:
Len := 0;
loop
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Len := Len + 1;
if Len > Ref_Name'Last then
Ada.Text_IO.Put_Line (" ** Reference too long on line " & ARM_Input.Line_String (Input_Object));
else
Ref_Name(Len) := Ch;
end if;
else -- End of the reference.
if Len = 0 then
Ada.Text_IO.Put_Line (" ** Failed to find reference on line " & ARM_Input.Line_String (Input_Object));
end if;
exit;
end if;
end loop;
if Display_It then
-- Save a reference for outputting on the next
-- paragraph start.
New_Ref := Allocate_Reference;
New_Ref.all := (Ref_Name => Ref_Name,
Ref_Len => Len,
Is_DR_Ref => (Which_Param = 1),
-- DR reference if Param = 1;
-- AI reference otherwise.
Next => null);
-- Attach this to the *end* of the list.
if Format_Object.References = null then
Format_Object.References := New_Ref;
else
Cursor := Format_Object.References;
while Cursor.Next /= null loop
Cursor := Cursor.next;
end loop;
Cursor.Next := New_Ref;
end if;
-- else don't display it.
end if;
-- else no parameter. Weird.
end if;
end Gen_Ref_or_ARef_Parameter;
procedure Gen_Chg_xxxx (Param_Cmd : in Data.Command_Type;
AARM_Prefix : in String) is
-- Implement chgimpdef, chgimpladv, chgdocreq, and
-- chgaspectdesc commands.
-- The AARM prefix (if needed) is AARM_Prefix, and
-- the parameter command is Param_Cmd.
-- This command is of the form:
-- @chgxxxxx{Version=[<version>], Kind=(<kind>),
-- Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
Close_Ch : Character;
Kind : ARM_Database.Paragraph_Change_Kind_Type;
Version : ARM_Contents.Change_Version_Type;
Display_It : Boolean;
use type ARM_Database.Paragraph_Change_Kind_Type;
Local_Change : ARM_Output.Change_Type;
Skip_Header : Boolean := False;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
Get_Change_Kind (Kind);
-- Read a parameter named "Kind".
if Format_Object.Impdef_Info.Command /= None then
Ada.Text_IO.Put_Line (" ** Nested impdef entry on line " & ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
-- Setup impdef information for this command:
case Param_Cmd is
when Change_Impdef_Text_Param =>
Format_Object.Impdef_Info :=
(Command => Impdef,
Change_Kind => <>, -- Set below.
Version => <>, -- Set below.
Initial_Version =>
Version, -- Until we decide differently.
Add_to_DB => True, -- Until we decide differently.
Paragraph_String => <>, -- Set below.
Paragraph_Len => <>);-- Set below.
when Change_Docreq_Text_Param =>
Format_Object.Impdef_Info :=
(Command => Docreq,
Change_Kind => <>, -- Set below.
Version => <>, -- Set below.
Initial_Version =>
Version, -- Until we decide differently.
Add_to_DB => True, -- Until we decide differently.
Paragraph_String => <>, -- Set below.
Paragraph_Len => <>);-- Set below.
when Change_Impladv_Text_Param =>
Format_Object.Impdef_Info :=
(Command => Impladv,
Change_Kind => <>, -- Set below.
Version => <>, -- Set below.
Initial_Version =>
Version, -- Until we decide differently.
Add_to_DB => True, -- Until we decide differently.
Paragraph_String => <>, -- Set below.
Paragraph_Len => <>);-- Set below.
when Change_AspectDesc_Text_Param =>
Format_Object.Impdef_Info :=
(Command => Aspect,
Change_Kind => <>, -- Set below.
Version => <>, -- Set below.
Initial_Version =>
Version, -- Until we decide differently.
Add_to_DB => True, -- Until we decide differently.
Aspect_Name => <>, -- Set below.
Aspect_Name_Len => <>, -- Set below.
Paragraph_String => <>, -- Set below.
Paragraph_Len => <>);-- Set below.
when others =>
raise Program_Error; -- Wrong kind of command passed in.
end case;
-- Check for the optional "InitialVersion" parameter,
-- and the not optional, but only used for some commands
-- "Aspect" parameter, stopping when we reach Text:
-- Note: If there is no InitialVersion command, use the same
-- version of the rest of the command (which was set when the
-- Info was created).
declare
Which_Param : ARM_Input.Param_Num;
Ch : Character;
Saw_Aspect : Boolean := False;
begin
loop
ARM_Input.Check_One_of_Parameter_Names (Input_Object,
Param_Name_1 => "InitialVersion" & (15..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_2 => "Aspect" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_3 => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Found => Which_Param,
Param_Close_Bracket => Close_Ch);
if Which_Param = 1 and then Close_Ch /= ' ' then
-- Found InitialVersion
ARM_Input.Get_Char (Input_Object, Ch);
Format_Object.Impdef_Info.Initial_Version := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for InitialVersion parameter on line " &
ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
elsif Which_Param = 2 and then Close_Ch /= ' ' then
-- Found Aspect parameter.
Saw_Aspect := True;
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Impdef_Info.Aspect_Name,
Format_Object.Impdef_Info.Aspect_Name_Len);
else -- We found "Text" (or an error)
exit; -- Handling of Text is below.
end if;
end loop;
if Format_Object.Impdef_Info.Command = Aspect then
if not Saw_Aspect then
Ada.Text_IO.Put_Line (" ** Missing Aspect parameter on line " &
ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
else -- Not aspect.
if Saw_Aspect then
Ada.Text_IO.Put_Line (" ** Aspect parameter on non-aspect command on line " &
ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
end if;
end;
--Ada.Text_IO.Put_Line ("Gen_Chg_xxxx, Kind=" &
--ARM_Database.Paragraph_Change_Kind_Type'Image(Kind) &
--"; version=" & Version & "; InitVer=" & Format_Object.Impdef_Initial_Version);
if (Kind = ARM_Database.Inserted or else
Kind = ARM_Database.Inserted_Normal_Number) then
Calc_Change_Disposition
(Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Local_Change);
--Ada.Text_IO.Put_Line (" Insert, Local_Change=" &
--ARM_Output.Change_Type'Image(Local_Change));
case Local_Change is
when Do_Not_Display_Text =>
Display_It := False;
Local_Change := ARM_Output.None;
Format_Object.Impdef_Info.Add_to_DB := False;
-- Do not add to the database, or display anything.
when ARM_Output.None|ARM_Output.Insertion =>
Format_Object.Impdef_Info.Version := Version;
Format_Object.Impdef_Info.Change_Kind := Kind;
Display_It := Format_Object.Include_Annotations;
-- Show impdef notes only if we're showing annotations.
when ARM_Output.Deletion =>
raise Program_Error;
end case;
elsif Kind = ARM_Database.Deleted or else
Kind = ARM_Database.Deleted_Inserted_Number or else
Kind = ARM_Database.Deleted_No_Delete_Message or else
Kind = ARM_Database.Deleted_Inserted_Number_No_Delete_Message then
Calc_Change_Disposition
(Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Deletion,
Text_Kind => Local_Change);
--Ada.Text_IO.Put_Line (" Delete, Local_Change=" &
--ARM_Output.Change_Type'Image(Local_Change));
case Local_Change is
when Do_Not_Display_Text =>
--Display_It := False;
-- We need to show the paragraph, without its header,
-- so that we get a proper "this paragraph is deleted"
-- message (if one is needed). Nothing will actually
-- be output in this case.
Local_Change := ARM_Output.None;
Skip_Header := True;
Format_Object.Impdef_Info.Version := Version;
Format_Object.Impdef_Info.Change_Kind := Kind;
Display_It := Format_Object.Include_Annotations;
-- Show impdef notes only if we're showing annotations.
Format_Object.Impdef_Info.Add_to_DB := True;
-- This will add deleted text to the database,
-- but there isn't a sensible alternative option,
-- as we need to have the deleted paragraph numbers.
when ARM_Output.None | ARM_Output.Deletion =>
Format_Object.Impdef_Info.Version := Version;
Format_Object.Impdef_Info.Change_Kind := Kind;
Display_It := Format_Object.Include_Annotations;
-- Show impdef notes only if we're showing annotations.
Skip_Header := False;
when ARM_Output.Insertion =>
raise Program_Error;
end case;
else -- we always display it.
--Ada.Text_IO.Put_Line (" Other");
Format_Object.Impdef_Info.Version := Version;
Format_Object.Impdef_Info.Change_Kind := Kind;
Display_It := Format_Object.Include_Annotations;
-- Show impdef notes only if we're showing annotations.
Local_Change := ARM_Output.None;
end if;
--Ada.Text_IO.Put_Line (" Display_It=" & Boolean'Image(Display_It));
-- "Text" parameter name consumed above.
if Close_Ch /= ' ' then
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Param_Cmd,
Close_Ch => Close_Ch);
ARM_Input.Start_Recording (Input_Object);
if Format_Object.In_Paragraph then
-- Do this to preserve any inserted paragraph info.
Format_Object.Impdef_Info.Paragraph_String :=
Format_Object.Current_Paragraph_String;
Format_Object.Impdef_Info.Paragraph_Len :=
Format_Object.Current_Paragraph_Len;
else
declare
PNum : constant String := Positive'Image (
Format_Object.Next_Paragraph - 1);
begin
Format_Object.Impdef_Info.Paragraph_Len := PNum'Length - 1;
Format_Object.Impdef_Info.Paragraph_String (1 .. PNum'Last-1) :=
PNum (2 .. PNum'Last);
end;
end if;
if Display_It then
Check_End_Paragraph; -- End any paragraph that we're in.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Format_Object.Paragraph_Tab_Stops;
Format_Object.Next_Paragraph_Format_Type := Bare_Annotation;
Format_Object.Next_Paragraph_Subhead_Type := Bare_Annotation;
Format_Object.Next_Paragraph_Version := Format_Object.Impdef_Info.Version;
Format_Object.Next_Paragraph_Change_Kind := Format_Object.Impdef_Info.Change_Kind;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Check_Paragraph;
if not Skip_Header then
declare
Local_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Local_Format.Bold := True;
Local_Format.Version := Format_Object.Impdef_Info.Version;
if ARM_Output."/=" (Local_Change, ARM_Output.None) then
Local_Format.Change := Local_Change;
ARM_Output.Text_Format (Output_Object,
Local_Format);
else -- No change from us:
ARM_Output.Text_Format (Output_Object,
Local_Format);
end if;
ARM_Output.Ordinary_Text (Output_Object,
Text => AARM_Prefix);
Local_Format.Bold := Format_Object.Text_Format.Bold;
Local_Format.Change := Format_Object.Text_Format.Change;
ARM_Output.Text_Format (Output_Object,
Local_Format);
end;
-- else skip the header, do nothing.
end if;
Format_Object.Last_Paragraph_Subhead_Type := Bare_Annotation;
Format_Object.Last_Non_Space := False;
if Format_Object.Impdef_Info.Command = Aspect then
-- Output the aspect name:
declare
Local_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Local_Format.Bold := True;
Local_Format.Version := Format_Object.Impdef_Info.Version;
if ARM_Output."/=" (Local_Change, ARM_Output.None) then
Local_Format.Change := Local_Change;
ARM_Output.Text_Format (Output_Object,
Local_Format);
else -- No change from us:
ARM_Output.Text_Format (Output_Object,
Local_Format);
end if;
ARM_Output.Ordinary_Text (Output_Object,
Text => Format_Object.Impdef_Info.Aspect_Name(1..Format_Object.Impdef_Info.Aspect_Name_Len));
ARM_Output.Ordinary_Text (Output_Object,
Text => ": ");
Local_Format.Bold := Format_Object.Text_Format.Bold;
Local_Format.Change := Format_Object.Text_Format.Change;
ARM_Output.Text_Format (Output_Object,
Local_Format);
end;
-- else no additional text.
end if;
else -- Don't display, skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Close_Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
end if;
-- else no parameter. Weird.
end if;
end Gen_Chg_xxxx;
procedure Get_Syntax_Parameters (Has_Version : in Boolean;
RHS_Close_Ch : out Character) is
-- Get the parameters for a Syn, AddedSyn, or DeletedSyn
-- command. The command has a version parameter (it's not @Syn)
-- if Has_Version is True. The results are put into the usual
-- places. The RHS parameter's name is evaluated, and its
-- closing character is RHS_Close_Ch.
-- @Syn{[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
-- @AddedSyn{Version=[Version],[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
-- @DeletedSyn{Version=[Version],[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
Close_Ch, Ch : Character;
Was_Tabs : Boolean := False;
begin
if Has_Version then
Get_Change_Version (Is_First => True,
Version =>
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version);
end if;
-- Peek to see if Tabs parmeter is present:
ARM_Input.Get_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object);
if Ch = 'T' or else Ch = 't' then
Was_Tabs := True;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Tabs" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => (not Has_Version),
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Grab the tab string:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Syntax_Tab,
Format_Object.Syntax_Tab_Len);
-- else no parameter. Weird.
end if;
else
Format_Object.Syntax_Tab_Len := 0;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "LHS" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => (not Was_Tabs) and (not Has_Version),
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the non-terminal:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Syntax_NT,
Format_Object.Syntax_NT_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "RHS" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => RHS_Close_Ch);
end Get_Syntax_Parameters;
procedure Gen_Syntax_Rule (Disposition : in ARM_Output.Change_Type;
RHS_Close_Ch : in Character) is
-- Generate a syntax rule with the specified disposition
-- for explicitly generated text. All of the parameters have been
-- read in; the close character for the RHS parameter is
-- RHS_Close_Ch.
use type ARM_Output.Change_Type;
Org_Tabs : ARM_Output.Tab_Info;
Key : ARM_Index.Index_Key;
begin
if Disposition = Do_Not_Display_Text then
if RHS_Close_Ch /= ' ' then
-- Skip the RHS and put nothing in the DB.
ARM_Input.Skip_until_Close_Char (Input_Object, RHS_Close_Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
-- In a deleted paragraph, call Check_Paragraph
-- to trigger the "deleted paragraph" message.
-- (Otherwise, this may never happen.)
Check_Paragraph;
-- else null; -- Nothing special to do.
end if;
end if;
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Syntax_Rule_RHS,
Close_Ch => RHS_Close_Ch);
-- (We probably don't need to do the above, but consistency
-- is preferred.)
else
-- Set up the tabs:
Org_Tabs := Format_Object.Paragraph_Tab_Stops;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
if Format_Object.Syntax_Tab_Len /= 0 then
Parse_Tab_Stops (Format_Object.Syntax_Tab(1..Format_Object.Syntax_Tab_Len),
Format_Object.Paragraph_Tab_Stops);
end if;
Check_Paragraph;
ARM_Format.Format (Format_Object,
"@s{" & Format_Object.Syntax_NT(1..Format_Object.Syntax_NT_Len) & "}",
Output_Object,
Text_Name => "@Syn(LHS=",
No_Annotations => False);
-- We use Format here so we can support changes in
-- the non-terminal.
-- Index the non-terminal:
ARM_Index.Add (Term => Get_NT,
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
-- Make an anchor for the non-terminal:
if Format_Object.Link_Non_Terminals then
declare
Lower_NT : constant String :=
Ada.Characters.Handling.To_Lower (Get_NT);
Link_Target : ARM_Syntax.Target_Type :=
ARM_Syntax.Non_Terminal_Link_Target (Lower_NT);
Lower_Old_NT : constant String :=
Ada.Characters.Handling.To_Lower (Get_Old_NT);
Old_Link_Target : ARM_Syntax.Target_Type :=
ARM_Syntax.Non_Terminal_Link_Target (Lower_Old_NT);
begin
if Lower_NT /= "" then
if Clause_String (Format_Object) /=
ARM_Syntax.Non_Terminal_Clause (Lower_NT) then
Ada.Text_IO.Put_Line (" ** Clause mismatch for non-terminal: Is=" &
Clause_String (Format_Object) & "; Was=" & ARM_Syntax.Non_Terminal_Clause (Lower_NT) &
"; NT=" & Lower_NT & "; on line " & ARM_Input.Line_String (Input_Object));
end if;
ARM_Output.Local_Target (Output_Object,
Text => "",
Target => Link_Target);
-- else the Non-Terminal was deleted, no
-- anchor is needed.
end if;
if Lower_Old_NT /= "" then
if Clause_String (Format_Object) /=
ARM_Syntax.Non_Terminal_Clause (Lower_Old_NT) then
-- This can happen if an item is inserted
-- on one place and deleted in another.
-- We'll assume this isn't an error and just
-- do nothing here.
--Ada.Text_IO.Put_Line (" %% Clause mismatch for old non-terminal: Is=" &
-- Clause_String (Format_Object) & "; Was=" & ARM_Syntax.Non_Terminal_Clause (Lower_Old_NT) &
-- "; NT=" & Lower_Old_NT & "; on line " & ARM_Input.Line_String (Input_Object));
null;
else
ARM_Output.Local_Target (Output_Object,
Text => "",
Target => Old_Link_Target);
end if;
-- else there was no old Non-Terminal.
end if;
end;
end if;
-- Set the font for the "::=". Note that we use @s{}
-- above, so that any font changes in the Non-Terminal
-- (as in a @Chg command) are respected.
-- This command includes any needed insertion or deletion.
declare
Swiss_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Swiss_Format.Font := ARM_Output.Swiss;
if Disposition = ARM_Output.None then
null;
else
Swiss_Format.Change := Disposition;
Swiss_Format.Version := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version;
end if;
ARM_Output.Text_Format (Output_Object,
Swiss_Format);
end;
ARM_Output.Ordinary_Text (Output_Object, " ::= ");
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset format.
Format_Object.Last_Non_Space := False;
if RHS_Close_Ch /= ' ' then
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Syntax_Rule_RHS,
Close_Ch => RHS_Close_Ch);
ARM_Input.Start_Recording (Input_Object);
-- Set the format to preserve line breaks.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Org_Tabs;
Format_Object.Next_Paragraph_Format_Type := Syntax_Production;
-- Tab stops are already set.
-- else no parameter, weird.
end if;
end if;
end Gen_Syntax_Rule;
procedure Format_Text (Text : in String;
Text_Name : in String) is
-- Note: We use the state of the surrounding call.
Input_Object : Arm_String.String_Input_Type;
Real_Include_Annotations : Boolean := Format_Object.Include_Annotations;
begin
-- Don't show annotations here:
Format_Object.Include_Annotations := False;
Arm_String.Open (Input_Object, Text, Text_Name);
-- Open the input object using a string for input.
Real_Process (Format_Object, Format_State, Input_Object, Output_Object);
Arm_String.Close (Input_Object);
Format_Object.Include_Annotations := Real_Include_Annotations;
end Format_Text;
procedure DB_Report is new ARM_Database.Report (Format_Text);
begin
case Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command is
-- Basic text commands:
when Redundant =>
if Format_Object.Include_Annotations then
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '[');
Format_Object.Last_Non_Space := True;
-- else ignored.
end if;
when Comment | Part =>
-- Skip the contents of this command.
-- For Part, we don't use the information contained,
-- but it would help a human reader.
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "comment" or "part" record.
when Bold =>
Check_Paragraph;
Format_Object.Text_Format.Bold := True;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Italic =>
Check_Paragraph;
Format_Object.Text_Format.Italic := True;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Roman =>
Check_Paragraph;
Format_Object.Text_Format.Font := ARM_Output.Roman;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Swiss =>
Check_Paragraph;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Fixed =>
Check_Paragraph;
Format_Object.Text_Format.Font := ARM_Output.Fixed;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Roman_Italic =>
Check_Paragraph;
Format_Object.Text_Format.Italic := True;
Format_Object.Text_Format.Font := ARM_Output.Roman;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Shrink =>
declare
use type ARM_Output.Size_Type;
begin
Check_Paragraph;
Format_Object.Text_Format.Size :=
Format_Object.Text_Format.Size - 1;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
end;
when Grow =>
declare
use type ARM_Output.Size_Type;
begin
Check_Paragraph;
Format_Object.Text_Format.Size :=
Format_Object.Text_Format.Size + 1;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
end;
when Black =>
Check_Paragraph;
Format_Object.Text_Format.Color := ARM_Output.Black;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Red =>
Check_Paragraph;
Format_Object.Text_Format.Color := ARM_Output.Red;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Green =>
Check_Paragraph;
Format_Object.Text_Format.Color := ARM_Output.Green;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Blue =>
Check_Paragraph;
Format_Object.Text_Format.Color := ARM_Output.Blue;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Keyword =>
Check_Paragraph;
Format_Object.Text_Format.Bold := True;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Non_Terminal_Format =>
-- No linking here.
Check_Paragraph;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Example_Text =>
Check_Paragraph;
Format_Object.Text_Format.Font := Format_Object.Examples_Font;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Example_Comment =>
Check_Paragraph;
Format_Object.Text_Format.Font := ARM_Output.Roman;
Format_Object.Text_Format.Italic := True;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Tab_Clear =>
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
when Tab_Set =>
if Format_Object.Next_Paragraph_Format_Type = Bulleted or else
Format_Object.Next_Paragraph_Format_Type = Nested_Bulleted or else
Format_Object.Next_Paragraph_Format_Type = Nested_X2_Bulleted or else
Format_Object.Next_Paragraph_Format_Type = Enumerated or else
Format_Object.Next_Paragraph_Format_Type = Nested_Enumerated or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_1 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_2 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_3 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_4 then
Ada.Text_IO.Put_Line (" ** Tab set in hang or bulleted format: " &
Paragraph_Type'Image(Format_Object.Next_Paragraph_Format_Type) &
", line " & ARM_Input.Line_String (Input_Object));
elsif ARM_Output."/=" (Format_Object.Paragraph_Tab_Stops, ARM_Output.NO_TABS) then
Ada.Text_IO.Put_Line (" ** Setting tabs when they are not clear on line "
& ARM_Input.Line_String (Input_Object));
else
declare
My_Tabs : ARM_Output.Tab_Info := ARM_Output.NO_TABS;
Stops : String(1..80);
Len : Natural;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Stops, Len);
Parse_Tab_Stops (Stops(1..Len), My_Tabs);
Format_Object.Paragraph_Tab_Stops := My_Tabs;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Tabstop)");
end;
end if;
when Non_Terminal =>
-- @nt{text}
-- This *was* simple, until we added linking.
declare
Name : String(1..120);
Len : Natural;
Swiss_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Name, Len);
-- Set the appropriate style:
Check_Paragraph;
Swiss_Format.Font := ARM_Output.Swiss;
ARM_Output.Text_Format (Output_Object,
Format => Swiss_Format);
if Format_Object.Link_Non_Terminals then
if Ada.Strings.Fixed.Index (Name(1..Len), "@") /= 0 then
-- Embedded commands. We have to clean the
-- string of the commands (if we can) before
-- making a link.
declare
Lower_NT : String :=
Ada.Characters.Handling.To_Lower (Name(1..Len));
Lower_NT_Len : Natural := Lower_NT'Length;
Loc : Natural := Lower_NT'First;
begin
while Loc <= Lower_NT_Len loop
-- Check for simple commands and remove them:
if Lower_NT(Loc) = '@' then -- Start of a command.
if Loc < Lower_NT_Len and then
(Lower_NT(Loc+1) = '!' or else
Lower_NT(Loc+1) = ';') then
-- Soft hyphen or no-op, remove.
Lower_NT(Loc .. Lower_NT_Len-2) :=
Lower_NT(Loc+2 .. Lower_NT_Len);
Lower_NT_Len := Lower_NT_Len - 2;
else -- Unknown.
exit;
end if;
else -- nothing to do, move to next character
Loc := Loc + 1;
end if;
end loop;
declare
Clause : constant String :=
ARM_Syntax.Non_Terminal_Clause (Lower_NT(1..Lower_NT_Len));
Target : constant ARM_Syntax.Target_Type :=
ARM_Syntax.Non_Terminal_Link_Target (Lower_NT(1..Lower_NT_Len));
Org_Font : ARM_Output.Font_Family_Type :=
Format_Object.Text_Format.Font;
begin
Format_Object.Text_Format.Font := ARM_Output.Swiss;
if Clause = "" then -- Not found. No link, but error message:
if Ada.Strings.Fixed.Index (Lower_NT(1..Lower_NT_Len), "@") /= 0 then
Ada.Text_IO.Put_Line (" %% Non-terminal with complex embedded commands " &
Lower_NT(1..Lower_NT_Len) & " on line " & ARM_Input.Line_String (Input_Object));
else
Ada.Text_IO.Put_Line (" ?? Unknown non-terminal " &
Lower_NT(1..Lower_NT_Len) & " on line " & ARM_Input.Line_String (Input_Object));
end if;
ARM_Format.Format (Format_Object,
Name(1..Len),
Output_Object,
Text_Name => "@nt{}",
No_Annotations => False);
else
ARM_Output.Local_Link_Start (Output_Object,
Target => Target, Clause_Number => Clause);
ARM_Format.Format (Format_Object,
Name(1..Len),
Output_Object,
Text_Name => "@nt{}",
No_Annotations => False);
ARM_Output.Local_Link_End (Output_Object,
Target => Target, Clause_Number => Clause);
end if;
Format_Object.Text_Format.Font := Org_Font;
end;
end;
else -- Ordinary link.
declare
Lower_NT : constant String :=
Ada.Characters.Handling.To_Lower (Name(1..Len));
Clause : constant String :=
ARM_Syntax.Non_Terminal_Clause (Lower_NT);
Target : constant ARM_Syntax.Target_Type :=
ARM_Syntax.Non_Terminal_Link_Target (Lower_NT);
begin
if Clause = "" then -- Not found. No link, but error message:
Ada.Text_IO.Put_Line (" ?? Unknown non-terminal " &
Name(1..Len) & " on line " & ARM_Input.Line_String (Input_Object));
ARM_Output.Ordinary_Text (Output_Object, Name(1..Len));
else
ARM_Output.Local_Link (Output_Object, Text => Name(1..Len),
Target => Target, Clause_Number => Clause);
end if;
end;
end if;
else
if Ada.Strings.Fixed.Index (Name(1..Len), "@") /= 0 then
-- Embedded commands, better execute them.
declare
Org_Font : ARM_Output.Font_Family_Type :=
Format_Object.Text_Format.Font;
begin
Format_Object.Text_Format.Font := ARM_Output.Swiss;
ARM_Format.Format (Format_Object,
Name(1..Len),
Output_Object,
Text_Name => "@nt{}",
No_Annotations => False);
Format_Object.Text_Format.Font := Org_Font;
end;
else
ARM_Output.Ordinary_Text (Output_Object, Name(1..Len));
end if;
end if;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
Format_Object.Last_Non_Space := True;
end;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Nonterminal)");
-- Versioned breaking:
when New_Page_for_Version | RM_New_Page_for_Version |
New_Column_for_Version |
Not_ISO_RM_New_Page_for_Version |
ISO_Only_RM_New_Page_for_Version =>
declare
Version : ARM_Contents.Change_Version_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version := Version;
end;
-- Tables:
when Table =>
-- @table(Columns=<number>,
-- Alignment=<AllLeft|AllCenter|CenterExceptFirst>,
-- FirstColWidth=<number>,
-- LastColWidth=<number>,
-- NoBreak=<T|F>,
-- Border=<T|F>,
-- SmallSize=<T|F>,
-- Caption=<text>,
-- Headers=<text>,
-- Body=<row_text>)
-- Columns must be a single digit (2-9).
-- Caption defines the table caption.
-- Headers defines the table headers.
-- Body defines the table body.
Check_End_Paragraph; -- End any paragraph we're in.
declare
Close_Ch, Ch : Character;
Align_Name : ARM_Input.Command_Name_Type;
Cols, FirstWidth, LastWidth : Character;
No_Page_Break : Boolean;
Has_Border : Boolean;
Small_Text : Boolean;
Alignment : ARM_Output.Column_Text_Alignment;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Columns" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
ARM_Input.Get_Char (Input_Object, Cols);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Table Columns on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Cols not in '2'..'9' then
Ada.Text_IO.Put_Line (" ** Bad table column count on line " & ARM_Input.Line_String (Input_Object));
end if;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Alignment" & (10..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the alignment word:
Arm_Input.Get_Name (Input_Object, Align_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Table Alignment on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"allleft" then
Alignment := ARM_Output.Left_All;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"allcenter" then
Alignment := ARM_Output.Center_All;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"centerexceptfirst" then
Alignment := ARM_Output.Center_Except_First;
else
Ada.Text_IO.Put_Line (" ** Bad column alignment: " &
Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "FirstColWidth" & (14..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
ARM_Input.Get_Char (Input_Object, FirstWidth);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Table FirstColWidth on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if FirstWidth not in '1'..'9' then
Ada.Text_IO.Put_Line (" ** Bad table 1st column width on line " & ARM_Input.Line_String (Input_Object));
end if;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "LastColWidth" & (13..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
ARM_Input.Get_Char (Input_Object, LastWidth);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Table FirstColWidth on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if FirstWidth not in '1'..'9' then
Ada.Text_IO.Put_Line (" ** Bad table last column width on line " & ARM_Input.Line_String (Input_Object));
end if;
end if;
Get_Boolean ("NoBreak" & (8..ARM_Input.Command_Name_Type'Last => ' '), No_Page_Break);
Get_Boolean ("Border" & (7..ARM_Input.Command_Name_Type'Last => ' '), Has_Border);
Get_Boolean ("SmallSize" & (10..ARM_Input.Command_Name_Type'Last => ' '), Small_Text);
-- Set to the table format:
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Format_Object.Paragraph_Tab_Stops;
Format_Object.Next_Paragraph_Format_Type := In_Table;
Format_Object.In_Paragraph := True; -- A fake, but we cannot have any format.
Format_Object.No_Start_Paragraph := False; -- For most purposes, being in a table is like being in a paragraph.
-- OK, we've started the table. Now, get the caption:
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Caption" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Check if the parameter is empty:
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
-- There is a caption:
ARM_Input.Replace_Char (Input_Object);
-- Create the table.
Arm_Output.Start_Table (
Output_Object,
Columns => Character'Pos(Cols) - Character'Pos('0'),
First_Column_Width => Character'Pos(FirstWidth) - Character'Pos('0'),
Last_Column_Width => Character'Pos(LastWidth) - Character'Pos('0'),
Alignment => Alignment,
No_Page_Break => No_Page_Break,
Has_Border => Has_Border,
Small_Text_Size => Small_Text,
Header_Kind => ARM_Output.Both_Caption_and_Header);
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Table_Param_Caption,
Close_Ch => Close_Ch);
else -- Empty Caption. Move on to the Headers
-- command.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Headers" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Check if the parameter is empty:
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
-- There is a header:
ARM_Input.Replace_Char (Input_Object);
-- Create the table.
Arm_Output.Start_Table (
Output_Object,
Columns => Character'Pos(Cols) - Character'Pos('0'),
First_Column_Width => Character'Pos(FirstWidth) - Character'Pos('0'),
Last_Column_Width => Character'Pos(LastWidth) - Character'Pos('0'),
Alignment => Alignment,
No_Page_Break => No_Page_Break,
Has_Border => Has_Border,
Small_Text_Size => Small_Text,
Header_Kind => ARM_Output.Header_Only);
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Table_Param_Header,
Close_Ch => Close_Ch);
else -- Empty Headers, too. Move on to the
-- Body command.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Body" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Create the table.
Arm_Output.Start_Table (
Output_Object,
Columns => Character'Pos(Cols) - Character'Pos('0'),
First_Column_Width => Character'Pos(FirstWidth) - Character'Pos('0'),
Last_Column_Width => Character'Pos(LastWidth) - Character'Pos('0'),
Alignment => Alignment,
No_Page_Break => No_Page_Break,
Has_Border => Has_Border,
Small_Text_Size => Small_Text,
Header_Kind => ARM_Output.No_Headers);
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Table_Param_Body,
Close_Ch => Close_Ch);
-- else no parameter, weird.
end if;
end if;
-- else no parameter, weird.
end if;
end if;
-- else no parameter, weird.
end if;
end;
-- Pictures:
when Picture_Alone | Picture_Inline =>
-- @PictureInline(Alignment=<Inline|FloatLeft|FloatRight>,
-- Border=<None|Thin|Thick>,
-- Height=<nnn>,
-- Width=<nnn>,
-- Name=<name>,
-- Descr=<descr>)
-- @PictureAlone(Alignment=<Left|Right|Center>,
-- Border=<None|Thin|Thick>,
-- Height=<nnn>,
-- Width=<nnn>,
-- Name=<name>,
-- Descr=<descr>)
declare
Close_Ch, Ch : Character;
Align_Name : ARM_Input.Command_Name_Type;
Alignment : ARM_Output.Picture_Alignment;
Border : ARM_Output.Border_Kind;
Height : Natural := 0;
Width : Natural := 0;
Name, Descr : String(1..120);
NLen, DLen : Natural := 0;
begin
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command =
Picture_Alone then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Alignment" & (10..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the alignment word:
Arm_Input.Get_Name (Input_Object, Align_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Picture Alignment on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"left" then
Alignment := ARM_Output.Alone_Left;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"right" then
Alignment := ARM_Output.Alone_Right;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"center" then
Alignment := ARM_Output.Alone_Center;
else
Ada.Text_IO.Put_Line (" ** Bad stand-alone picture alignment: " &
Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
-- else no parameter. Weird.
end if;
else -- Picture_Inline.
Check_Paragraph; -- Make sure we're in a paragraph.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Alignment" & (10..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the alignment word:
Arm_Input.Get_Name (Input_Object, Align_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Picture Alignment on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"inline" then
Alignment := ARM_Output.Inline;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"floatleft" then
Alignment := ARM_Output.Float_Left;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"floatright" then
Alignment := ARM_Output.Float_Right;
else
Ada.Text_IO.Put_Line (" ** Bad inline picture alignment: " &
Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
-- else no parameter. Weird.
end if;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Border" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Get the alignment word:
Arm_Input.Get_Name (Input_Object, Align_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Picture Border on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"none" then
Border := ARM_Output.None;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"thin" then
Border := ARM_Output.Thin;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right)) =
"thick" then
Border := ARM_Output.Thick;
else
Ada.Text_IO.Put_Line (" ** Bad picture border: " &
Ada.Strings.Fixed.Trim (Align_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Height" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Name,
NLen);
begin
Height := Natural'Value(Name(1..NLen));
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line (" ** Bad picture height: " &
Name(1..NLen) & " on line " & ARM_Input.Line_String (Input_Object));
end;
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Width" & (6..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Name,
NLen);
begin
Width := Natural'Value(Name(1..NLen));
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line (" ** Bad picture width: " &
Name(1..NLen) & " on line " & ARM_Input.Line_String (Input_Object));
end;
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Name" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Name,
NLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Descr" & (6..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Descr,
DLen);
-- else no parameter. Weird.
end if;
ARM_Output.Picture (
Output_Object,
Alignment => Alignment,
Border => Border,
Height => Height,
Width => Width,
Name => Name(1..NLen),
Descr => Descr(1..DLen));
end;
-- Normal processing should remove the command end marker.
-- Paragraph kind commands:
when Text_Begin =>
declare
Type_Name : ARM_Input.Command_Name_Type;
Ch : Character;
begin
-- OK, now read the begin "type":
Arm_Input.Get_Name (Input_Object, Type_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch = ',' then
-- Multiple parameters. The remaining
-- parameters appear to be format instructions,
-- which we ought to replace or remove.
Ada.Text_IO.Put_Line (" -- Multi-parameter begin, line " & ARM_Input.Line_String (Input_Object));
-- We ignore everything until the end of the
-- parameter.
while Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char loop
-- Ignore everything until the end character
-- turns up.
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
end if;
if Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char = Ch then
-- Found the end of the parameter.
-- Replace the top of stack with the appropriate begin record:
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr) :=
(Name => Ada.Characters.Handling.To_Lower (Type_Name),
Kind => Begin_Word,
Command => Text_Begin,
Close_Char => ' ',-- No close character.
Text_Format => Format_Object.Text_Format,
-- Save the current format.
Old_Last_Subhead_Paragraph => Format_Object.Last_Paragraph_Subhead_Type,
Old_Next_Subhead_Paragraph => Format_Object.Next_Paragraph_Subhead_Type,
Old_Next_Paragraph_Format => Format_Object.Next_Paragraph_Format_Type,
Old_Tab_Stops => Format_Object.Paragraph_Tab_Stops,
Old_Next_Enum_Num => Format_Object.Next_Enumerated_Num,
Is_Formatting => True, -- Reset if needed later.
Change_Version => '0', -- Not used.
Was_Text => False, -- Not used.
Prev_Change => ARM_Output.None, -- Not used.
Prev_Change_Version => '0', -- Not used.
Prev_Added_Change_Version => '0'); -- Not used.
Process_Begin;
else
ARM_Input.Replace_Char (Input_Object);
Ada.Text_IO.Put_Line (" ** Failed to find close for parameter to begin, line " & ARM_Input.Line_String (Input_Object));
--Bracket_Check := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Bracket_State;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Bad Begin)");
end if;
end;
when Text_End =>
declare
Type_Name : ARM_Input.Command_Name_Type;
Ch : Character;
begin
Arm_Input.Get_Name (Input_Object, Type_Name); -- Get the end "type".
ARM_Input.Get_Char (Input_Object, Ch);
if Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char = Ch then
-- Found end of parameter:
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "End" record.
-- Check for the matching begin, and remove it.
if Format_State.Nesting_Stack_Ptr = 0 then
Ada.Text_IO.Put_Line (" ** No begin for end, line " & ARM_Input.Line_String (Input_Object));
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name /=
Ada.Characters.Handling.To_Lower (Type_Name) then
Ada.Text_IO.Put_Line (" ** Names of begin and end mismatch, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Begin name: " & Ada.Strings.Fixed.Trim(Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right) &
" End name: " & Ada.Strings.Fixed.Trim(Type_Name, Ada.Strings.Right));
--Ada.Text_IO.Put_Line (" &Stack name is " & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name);
else
if Format_Object.Next_Paragraph_Subhead_Type /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph then
Format_Object.Last_Paragraph_Subhead_Type := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph;
-- else still in same subhead, leave alone. (If
-- we didn't do this, we'd output the subhead
-- multiple times).
end if;
Format_Object.Next_Paragraph_Subhead_Type := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph;
Format_Object.Next_Paragraph_Format_Type := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format;
Format_Object.Paragraph_Tab_Stops := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops;
Format_Object.Next_Enumerated_Num := Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Enum_Num;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (End)");
--!!Debug:
--Ada.Text_IO.Put_Line ("(End) Next=" & Paragraph_Type'Image(Format_Object.Next_Paragraph_Subhead_Type));
end if;
Check_End_Paragraph; -- End any paragraph that we're in.
declare
Lower_Type_Name : constant String :=
Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (
Type_Name, Ada.Strings.Right));
begin
-- Check if number of columns is changing:
if Lower_Type_Name = "twocol" then
-- Leaving two column region, reset to one:
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 1);
elsif Lower_Type_Name = "fourcol" then
-- Leaving four column region, reset to one:
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 1);
end if;
-- Check if we're leaving a bundle:
if Lower_Type_Name = "bundle" then
Format_Object.In_Bundle := False;
end if;
-- Check if we're leaving an enumerated list:
if Lower_Type_Name = "enumerate" or else
Lower_Type_Name = "innerenumerate" then
Format_Object.Enumerated_Level :=
Format_Object.Enumerated_Level - 1;
end if;
end;
else
ARM_Input.Replace_Char (Input_Object);
Ada.Text_IO.Put_Line (" ** Failed to find close for parameter to end, line " & ARM_Input.Line_String (Input_Object));
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Bad End)");
end if;
end;
-- Indexing commands:
when Defn | RootDefn =>
-- @Defn{term} or @RootDefn{term}. Index the term.
-- Note that there is no difference between these in terms
-- of the index, so we do them together.
declare
Term : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Term,
Len);
ARM_Index.Add (Term => Term(1..Len),
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Defn then
Display_Index_Entry (Term(1..Len));
else -- RootDefn
Display_Index_Entry (Term(1..Len), Special => Is_Root);
end if;
end if;
ARM_Output.Index_Target (Output_Object, Key);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "(Root)Defn" record.
end;
when PDefn =>
-- @PDefn{term} ot @RootDefn{term}. Index the term as a partial
-- definition.
declare
Term : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Term,
Len);
ARM_Index.Add (Term => Term(1..Len),
Kind => ARM_Index.Partial_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Term(1..Len), Special => Is_Partial);
end if;
ARM_Output.Index_Target (Output_Object, Key);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "PDefn" record.
end;
when Defn2 | RootDefn2 =>
-- @Defn2[Term={term}, Sec={sec}]
-- @RootDefn[Term={term}, Sec={sec}]. Index the term and subterm.
-- Note that there is no difference between these in terms
-- of the index, so we do them together.
declare
Close_Ch : Character;
Term, Subterm : String(1..90);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Sec" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Subterm,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => Subterm(1..SLen),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Defn2 then
Display_Index_Entry (Term(1..TLen) & " (" & Subterm(1..SLen) & ')');
else -- RootDefn
Display_Index_Entry (Term(1..TLen) & " (" & Subterm(1..SLen) & ')', Special => Is_Root);
end if;
end if;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when PDefn2 =>
-- @PDefn2[Term={term}, Sec={sec}]. Index the term and subterm.
-- Note that there is no difference between these in terms
-- of the index, so we do them together.
declare
Close_Ch : Character;
Term, Subterm : String(1..90);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Sec" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Subterm,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => Subterm(1..SLen),
Kind => ARM_Index.Partial_Term_with_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Term(1..TLen) & " (" & Subterm(1..SLen) & ')',
Special => Is_Partial);
end if;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when Index_See =>
-- @IndexSee[Term={term}, See={see}]. Index a See item.
declare
Close_Ch : Character;
Term, See : String(1..80);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "See" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
See,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => See(1..SLen),
Kind => ARM_Index.See_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Term(1..TLen) & ": See " & See(1..SLen));
end if;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when Index_See_Also =>
-- @IndexSeeAlso[Term={term}, See={see}]. Index a See Also item.
declare
Close_Ch : Character;
Term, See : String(1..80);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "See" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
See,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => See(1..SLen),
Kind => ARM_Index.See_Also_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Term(1..TLen) & ": See also " & See(1..SLen));
end if;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when See_Other =>
-- @SeeOther[Primary={term}, Other={see}]. Generate a
-- See {see} in the index, but no reference.
declare
Close_Ch : Character;
Term, See : String(1..80);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Primary" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Other" & (6..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
See,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => See(1..SLen),
Kind => ARM_Index.See_Other_Term,
Clause => "",
Paragraph => "",
Key => Key);
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when See_Also =>
-- @SeeAlso[Primary={term}, Other={see}]. Generate a
-- See also {see} in the index, but no reference.
declare
Close_Ch : Character;
Term, See : String(1..80);
TLen, SLen : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Primary" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Term,
TLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Other" & (6..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
See,
SLen);
-- else no parameter. Weird.
end if;
ARM_Index.Add (Term => Term(1..TLen),
Subterm => See(1..SLen),
Kind => ARM_Index.See_Also_Other_Term,
Clause => "",
Paragraph => "",
Key => Key);
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when Index_Root_Unit =>
-- @RootLibUnit{<unit>}
-- Generates two index entries: An index entry for
-- "Language-Defined Library Units" with a secondary
-- entry of <unit>, and an index entry for <unit>.
declare
Term : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key := ARM_Index.Get_Key;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Term,
Len);
-- Set the current unit for future use:
Format_Object.Unit (1..Len) := Term(1..Len);
Format_Object.Unit_Len := Len;
-- Determine what to do with the "Language-Defined" entry:
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => '2',
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
null; -- Ignore this.
elsif Disposition = ARM_Output.None then
-- Make reference:
ARM_Index.Add_Reusing_Key (
Term => "Language-Defined Library Units",
Subterm => Term(1..Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
elsif Disposition = ARM_Output.Deletion then
null; -- Ignore this (no change info in the index).
else -- Insertion.
raise Program_Error; -- An insertion inside of a deletion command!
end if;
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add_Reusing_Key (
Term => Term(1..Len),
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Format_Object.Package_Index,
Entity => Term(1..Len),
Kind => ARM_Subindex.Top_Level,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "RootLibUnit" record.
end;
when Index_Child_Unit =>
-- @ChildUnit{Parent=[<parent>],Child=[<child>]}
-- Generates three index entries: An index entry for <child>, with a secondary
-- of "@i{child of} <parent>", an index entry for "Language-Defined
-- Library Units" with a secondary entry of <parent>.<child>,
-- and an index entry for <parent>.<child>.
Child_Unit (Format_Object.Package_Index,
Format_Object,
Output_Object);
when Index_Subprogram_Child_Unit =>
-- @ChildUnit{Parent=[<parent>],Child=[<child>]}
-- Generates three index entries: An index entry for <child>, with a secondary
-- of "@i{child of} <parent>", an index entry for "Language-Defined
-- Library Units" with a secondary entry of <parent>.<child>,
-- and an index entry for <parent>.<child>.
Child_Unit (Format_Object.Subprogram_Index,
Format_Object,
Output_Object);
when Index_Type =>
-- @AdaTypeDefn{<defn>}
-- Generates two index entries: one for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.),
-- adds a similar entry to the exception list,
-- and second for "Language-Defined Type" with a
-- secondary entry of "<defn> @i{in} <Unit>".
-- Also outputs the <defn> to the output file.
Simple_Subindex_Item (
Format_Object.Type_Index,
Format_Object,
Output_Object,
Entity_Kind_Name => "Type");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaTypeDefn" record.
when Index_Subtype =>
-- @AdaSubTypeDefn{Name=<defn>,Of=<type>}
-- Generates an index entry of "<defn> @i{subtype of}
-- <type>" with a secondary entry of "@i{in} <Unit>" (where
-- Unit is the unit saved by a previous RootLibUnit or
-- ChildUnit.) The entry is added to the type list as well.
-- Also outputs the <defn> to the output file.
declare
Subtype_Name, Type_Name : String(1..80);
SLen, TLen : Natural := 0;
Key : ARM_Index.Index_Key := ARM_Index.Get_Key;
Close_Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Name" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Subtype_Name,
SLen);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Of" & (3..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy over the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Type_Name,
TLen);
-- else no parameter. Weird.
end if;
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
if Format_Object.Unit_Len = 0 then
Ada.Text_IO.Put_Line ("** No unit defined for index entry expecting one on line " & ARM_Input.Line_String (Input_Object));
ARM_Index.Add_Reusing_Key (
Term => Subtype_Name(1..SLen) & " subtype of " &
Type_Name(1..TLen),
Subterm => "*unknown*",
Kind => ARM_Index.Subtype_Declaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Format_Object.Type_Index,
Entity => Subtype_Name(1..SLen) & " subtype of " &
Type_Name(1..TLen),
From_Unit => "*unknown*",
Kind => ARM_Subindex.Subtype_In_Unit,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
else
ARM_Index.Add_Reusing_Key (
Term => Subtype_Name(1..SLen) & " subtype of " &
Type_Name(1..TLen),
Subterm => Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Index.Subtype_Declaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Subindex.Insert (
Subindex_Object => Format_Object.Type_Index,
Entity => Subtype_Name(1..SLen) & " subtype of " &
Type_Name(1..TLen),
From_Unit => Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Subindex.Subtype_In_Unit,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
end if;
ARM_Output.Ordinary_Text (Output_Object, Subtype_Name(1..SLen));
Format_Object.Last_Non_Space := True;
-- Leave the command end marker, let normal processing
-- get rid of it.
end;
when Index_Subprogram =>
-- @AdaSubDefn{<defn>}
-- Generates two index entries: one for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.),
-- adds a similar entry to the exception list,
-- and second for "Language-Defined Subprogram" with a
-- secondary entry of "<defn> @i{in} <Unit>".
-- Also outputs the <defn> to the output file.
Simple_Subindex_Item (
Format_Object.Subprogram_Index,
Format_Object,
Output_Object,
Entity_Kind_Name => "Subprogram");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaSubDefn" record.
when Index_Exception =>
-- @AdaExcDefn{<defn>}
-- Generates and index entries for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.),
-- and adds a similar entry to the exception list.
-- Also outputs the <defn> to the output file.
Simple_Subindex_Item (
Format_Object.Exception_Index,
Format_Object,
Output_Object,
Entity_Kind_Name => "");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaExcDefn" record.
when Index_Object =>
-- @AdaObjDefn{<defn>}
-- Generates and index entries for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.),
-- and adds a similar entry to the exception list.
-- Also outputs the <defn> to the output file.
Simple_Subindex_Item (
Format_Object.Object_Index,
Format_Object,
Output_Object,
Entity_Kind_Name => "");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaObjDefn" record.
when Index_Package =>
-- @AdaObjDefn{<defn>}
-- Generates and index entries for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.),
-- and adds a similar entry to the package list.
-- Also outputs the <defn> to the output file.
Simple_Subindex_Item (
Format_Object.Package_Index,
Format_Object,
Output_Object,
Entity_Kind_Name => "");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaPackDefn" record.
when Index_Other =>
-- @AdaDefn{<defn>}
-- Generate an index entries for <defn> with a
-- secondary entry of "@i{in} <Unit>" (where Unit is
-- the unit saved by a previous RootLibUnit or ChildUnit.).
-- Also outputs the <defn> to the output file.
declare
Item : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Item,
Len);
ARM_Index.Add (Term => Item(1..Len),
Subterm => Format_Object.Unit(1..Format_Object.Unit_Len),
Kind => ARM_Index.Declaration_in_Package,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
ARM_Output.Index_Target (Output_Object, Key);
ARM_Output.Ordinary_Text (Output_Object, Item(1..Len));
Format_Object.Last_Non_Space := True;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "AdaDefn" record.
end;
when Index_Check =>
-- @Indexcheck{<check>}
-- Generates index items for
-- "check, language-defined", <check>,
-- and <check> [partial].
declare
Term : String(1..80);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Term,
Len);
ARM_Index.Add (Term => Term(1..Len),
Kind => ARM_Index.Partial_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
Check_Paragraph;
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Term(1..Len), Special => Is_Partial);
end if;
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => "check, language-defined",
Subterm => Term(1..Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
if Format_Object.Display_Index_Entries then
Display_Index_Entry ("check, language-defined (" & Term(1..Len) & ")");
end if;
ARM_Output.Index_Target (Output_Object, Key);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Indexcheck" record.
end;
when Index_Attr =>
-- This command indexes an attribute name.
-- This calls Defn2("attributes", <param>), and
-- also writes <param> to output.
declare
Param : String(1..20);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Param,
Len);
Check_Paragraph;
ARM_Index.Add (Term => "attributes",
Subterm => Param(1..Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => Param(1..Len) & " attribute",
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Output.Ordinary_Text (Output_Object,
Param(1..Len));
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Index_Attr" record.
end;
when Index_Pragma =>
-- This command indexes a pragma name.
-- This calls Defn2("pragmas", <param>), and
-- also writes <param> to output.
declare
Param : String(1..30);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Param,
Len);
Check_Paragraph;
ARM_Index.Add (Term => "pragmas",
Subterm => Param(1..Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => Param(1..Len) & " pragma",
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Output.Ordinary_Text (Output_Object,
Param(1..Len));
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Index_Pragma" record.
end;
when Index_Aspect =>
-- This command indexes an aspect name.
-- This calls Defn2("aspects", <param>), and
-- Defn(<param> "aspect")
declare
Param : String(1..30);
Len : Natural := 0;
Key : ARM_Index.Index_Key;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Param,
Len);
Check_Paragraph;
ARM_Index.Add (Term => "aspects",
Subterm => Param(1..Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => Param(1..Len) & " aspect",
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Index_Aspect" record.
end;
when Syntax_Rule =>
-- @syn{[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
-- Marks a syntax production of the form:
-- @nt<Non-Terminal> ::= <Production>
-- <Tabset> defines any tabs needed by the syntax production.
--
-- Also, the <Non-terminal> is indexed. The <Non-Terminal>
-- and <Production> (and the clause number) are sent to the
-- syntax manager. Also, saves <Non-terminal> for any
-- following Syntax_Term (@Syn2) to use.
declare
RHS_Close_Ch : Character;
begin
Get_Syntax_Parameters (Has_Version => False,
RHS_Close_Ch => RHS_Close_Ch);
Gen_Syntax_Rule (ARM_Output.None, RHS_Close_Ch);
end;
when Added_Syntax_Rule =>
-- @AddedSyn{Version=[Version],[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
-- Marks an added syntax production of the form:
-- @nt<Non-Terminal> ::= <Production>
-- See Syntax_Rule for the details.
declare
RHS_Close_Ch : Character;
Disposition : ARM_Output.Change_Type;
begin
Get_Syntax_Parameters (Has_Version => True,
RHS_Close_Ch => RHS_Close_Ch);
if Format_Object.In_Change then
Ada.Text_IO.Put_Line (" ** In change for AddedSyn on line " & ARM_Input.Line_String (Input_Object));
raise Program_Error;
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
Gen_Syntax_Rule (Disposition, RHS_Close_Ch);
end;
when Deleted_Syntax_Rule =>
-- @DeletedSyn{Version=[Version],[Tabs=<Tabset>, ]LHS=<Non-terminal>, RHS=<Production>}
-- Marks a deleted syntax production of the form:
-- @nt<Non-Terminal> ::= <Production>
-- See Syntax_Rule for the details.
declare
RHS_Close_Ch : Character;
Disposition : ARM_Output.Change_Type;
begin
Get_Syntax_Parameters (Has_Version => True,
RHS_Close_Ch => RHS_Close_Ch);
if Format_Object.In_Change then
Ada.Text_IO.Put_Line (" ** In change for DeletedSyn on line " & ARM_Input.Line_String (Input_Object));
raise Program_Error;
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
Gen_Syntax_Rule (Disposition, RHS_Close_Ch);
end;
when Syntax_Term | Syntax_Term_Undefined =>
-- Marks a non-terminal name in the production of a syntax
-- rule. Generates the term in the same style as
-- @nt (Non_Terminal). "Undefined" means the term is
-- not formally defined (like the character class names in
-- the Ada standard).
-- If the current LHS non-terminal is not null, generates
-- a syntax cross reference entry:
-- <Name> in <Non-Terminal> at <ClauseNum>. Also,
-- generate an index entry for the item:
-- @Defn2(Term=<Name>,Sec=@i{used}.
-- Note: We assume no internal formatting in <Name>.
declare
Name : String(1..40);
Len : Natural;
Key : ARM_Index.Index_Key;
Defined : constant Boolean :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command =
Syntax_Term;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Name, Len);
if Format_Object.Syntax_NT_Len /= 0 then
-- Generate a syntax cross-reference entry.
declare
NT : constant String := Get_NT;
begin
if NT /= "" then
ARM_Syntax.Add_Xref (
Name => Name(1..Len),
Used_In => Get_NT,
Clause => Clause_String (Format_Object),
Defined => Defined);
-- else this is a deleted production that is
-- still displayed; forget the XRef.
end if;
end;
end if;
-- Index the non-terminal:
ARM_Index.Add (Term => Name(1..Len),
Kind => ARM_Index.Syntax_NT_Used,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
-- Set the appropriate style:
Check_Paragraph;
declare
Swiss_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Swiss_Format.Font := ARM_Output.Swiss;
ARM_Output.Text_Format (Output_Object,
Swiss_Format);
end;
if not Defined then
-- No linking to do.
ARM_Output.Ordinary_Text (Output_Object, Name(1..Len));
elsif Format_Object.Link_Non_Terminals then
declare
Lower_NT : constant String :=
Ada.Characters.Handling.To_Lower (Name(1..Len));
Clause : constant String :=
ARM_Syntax.Non_Terminal_Clause (Lower_NT);
Target : constant ARM_Syntax.Target_Type :=
ARM_Syntax.Non_Terminal_Link_Target (Lower_NT);
begin
if Clause = "" then -- Not found. No link, but error message:
Ada.Text_IO.Put_Line (" ** Unknown non-terminal in syntax production " &
Name(1..Len) & " on line " & ARM_Input.Line_String (Input_Object));
ARM_Output.Ordinary_Text (Output_Object, Name(1..Len));
else
ARM_Output.Local_Link (Output_Object, Text => Name(1..Len),
Target => Target, Clause_Number => Clause);
end if;
end;
else
ARM_Output.Ordinary_Text (Output_Object, Name(1..Len));
end if;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset the format.
Format_Object.Last_Non_Space := True;
end;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Syntax Term)");
when Syntax_Prefix =>
-- Marks the prefix of a non-terminal. Writes italized
-- text in the current font.
-- Set the appropriate style:
Check_Paragraph;
Format_Object.Text_Format.Italic := True;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
when To_Glossary | To_Glossary_Also =>
-- This is a glossary command.
-- It is of the form @ToGlossary(Term=[<term>], Text=[<text>])
-- We will store the term and definition in the glossary
-- database. We also have to pass through the Text
-- parameter, either to the regular text (for
-- ToGlossaryAlso) or the AARM (for ToGlossary).
declare
Close_Ch : Character;
Key : ARM_Index.Index_Key;
begin
if Format_Object.Glossary_Info.Active then
Ada.Text_IO.Put_Line (" ** Nested glossary entry on line " & ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
-- Setup glossary information for this command:
Format_Object.Glossary_Info :=
(Active => True,
Change_Kind => ARM_Database.None,
-- No change for this command.
Term => <>, -- Set below.
Term_Len => <>, -- Set below.
Add_to_Glossary => True, -- Always add it.
Displayed => False); -- Until we decide differently.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Glossary_Info.Term,
Format_Object.Glossary_Info.Term_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Glossary_Text_Param,
Close_Ch => Close_Ch);
ARM_Input.Start_Recording (Input_Object);
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = To_Glossary_Also then
-- The text just goes straight to the file.
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
ARM_Output.Ordinary_Text (Output_Object,
"[Glossary Entry]");
Format_Object.Last_Non_Space := True;
-- else no marker.
end if;
-- Index the term (because it does appear here):
Check_Paragraph; -- We've got to be in a paragraph to write this.
ARM_Index.Add (Term => Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len),
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
Format_Object.Glossary_Info.Displayed := True;
elsif Format_Object.Include_Annotations then
Check_End_Paragraph; -- End any paragraph that we're in.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Format_Object.Paragraph_Tab_Stops;
Format_Object.Next_Paragraph_Format_Type := Glossary_Marker;
Format_Object.Next_Paragraph_Subhead_Type := Glossary_Marker;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
Format_Object.Glossary_Info.Displayed := True;
-- Note: The term is indexed in the glossary,
-- but not here.
else -- No annotations, "To_Glossary"
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
ARM_Output.Ordinary_Text (Output_Object,
"[Glossary Entry]");
Format_Object.Last_Non_Space := True;
-- else no marker.
end if;
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
Format_Object.Glossary_Info.Displayed := False;
-- Note: The term is indexed in the glossary,
-- but not here.
end if;
end if;
end;
when Change_To_Glossary | Change_To_Glossary_Also =>
-- This is a change glossary command.
-- It is of the form
-- @ChgToGlossary(Version=[<version>],Kind=(<kind>),Term=[<term>], Text=[<text>])
-- We will store the term and definition in the glossary
-- database. We also have to pass through the Text
-- parameter, either to the regular text (for
-- ChgToGlossaryAlso) or the AARM (for ChgToGlossary).
declare
Close_Ch : Character;
Key : ARM_Index.Index_Key;
Kind : ARM_Database.Paragraph_Change_Kind_Type;
Our_Version : ARM_Contents.Change_Version_Type;
use type ARM_Database.Paragraph_Change_Kind_Type;
Local_Change : ARM_Output.Change_Type;
begin
if Format_Object.Glossary_Info.Active then
Ada.Text_IO.Put_Line (" ** Nested glossary entry on line " & ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
Get_Change_Version (Is_First => True,
Version => Our_Version);
-- Read a parameter named "Version".
Get_Change_Kind (Kind);
-- Read a parameter named "Kind".
-- Setup glossary information for this command (now
-- that we know the above):
-- Note: Discriminants need to be static, so we have
-- to use the following brain-damaged initialization.
-- At least this lets us strip the number and message
-- information from Inserted and Deleted (which we
-- would have to do anyway).
case Kind is
when ARM_Database.Inserted |
ARM_Database.Inserted_Normal_Number =>
Format_Object.Glossary_Info :=
(Active => True,
Change_Kind => ARM_Database.Inserted,
Version => Our_Version,
Term => <>, -- Set below.
Term_Len => <>, -- Set below.
Add_to_Glossary => <>, -- Set below.
Displayed => <>); -- Set below.
when ARM_Database.Deleted |
ARM_Database.Deleted_Inserted_Number |
ARM_Database.Deleted_No_Delete_Message |
ARM_Database.Deleted_Inserted_Number_No_Delete_Message =>
Format_Object.Glossary_Info :=
(Active => True,
Change_Kind => ARM_Database.Deleted,
Version => Our_Version,
Term => <>, -- Set below.
Term_Len => <>, -- Set below.
Add_to_Glossary => <>, -- Set below.
Displayed => <>); -- Set below.
when ARM_Database.Revised =>
Format_Object.Glossary_Info :=
(Active => True,
Change_Kind => ARM_Database.Revised,
Version => Our_Version,
Term => <>, -- Set below.
Term_Len => <>, -- Set below.
Add_to_Glossary => <>, -- Set below.
Displayed => <>); -- Set below.
when ARM_Database.Revised_Inserted_Number =>
Format_Object.Glossary_Info :=
(Active => True,
Change_Kind => ARM_Database.Revised_Inserted_Number,
Version => Our_Version,
Term => <>, -- Set below.
Term_Len => <>, -- Set below.
Add_to_Glossary => <>, -- Set below.
Displayed => <>); -- Set below.
when ARM_Database.None =>
raise Program_Error; -- Can't happen.
end case;
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Change_To_Glossary_Also then
-- The text just goes straight to the file. It will
-- get formatted appropriately. So we only need to
-- figure out whether it will get indexed and displayed
-- in the Glossary.
Format_Object.Glossary_Info.Displayed := True;
Local_Change := ARM_Output.None;
if Format_Object.Changes = ARM_Format.Old_Only and then
Format_Object.Glossary_Info.Version > '0' then
-- Old only, don't display it (and it won't be
-- inserted, either).
Format_Object.Glossary_Info.Add_to_Glossary := False;
elsif Format_Object.Glossary_Info.Change_Kind = ARM_Database.Inserted then
if Format_Object.Glossary_Info.Version <= Format_Object.Change_Version then
Format_Object.Glossary_Info.Add_to_Glossary := True;
else --This reference is too new, ignore it.
Format_Object.Glossary_Info.Displayed := False;
Format_Object.Glossary_Info.Add_to_Glossary := False;
end if;
elsif Format_Object.Glossary_Info.Change_Kind = ARM_Database.Deleted then
Format_Object.Glossary_Info.Add_to_Glossary := True;
else -- we always display it.
Format_Object.Glossary_Info.Add_to_Glossary := True;
end if;
else
if Format_Object.Glossary_Info.Change_Kind = ARM_Database.Inserted then
Calc_Change_Disposition
(Format_Object => Format_Object,
Version => Format_Object.Glossary_Info.Version,
Operation => ARM_Output.Insertion,
Text_Kind => Local_Change);
case Local_Change is
when Do_Not_Display_Text =>
Format_Object.Glossary_Info.Displayed := False;
Format_Object.Glossary_Info.Add_to_Glossary := False;
Local_Change := ARM_Output.None;
when ARM_Output.None|ARM_Output.Insertion =>
Format_Object.Glossary_Info.Displayed :=
Format_Object.Include_Annotations;
Format_Object.Glossary_Info.Add_to_Glossary := True;
when ARM_Output.Deletion =>
raise Program_Error;
end case;
elsif Format_Object.Glossary_Info.Change_Kind = ARM_Database.Deleted then
-- Note: other forms of delete removed previously.
Calc_Change_Disposition
(Format_Object => Format_Object,
Version => Format_Object.Glossary_Info.Version,
Operation => ARM_Output.Deletion,
Text_Kind => Local_Change);
case Local_Change is
when Do_Not_Display_Text =>
Format_Object.Glossary_Info.Displayed := False;
Format_Object.Glossary_Info.Add_to_Glossary := True;
-- We still add this to the glossary so that
-- the deleted paragraph message can be displayed for it.
Local_Change := ARM_Output.None;
when ARM_Output.None|ARM_Output.Deletion =>
Format_Object.Glossary_Info.Displayed :=
Format_Object.Include_Annotations;
Format_Object.Glossary_Info.Add_to_Glossary := True;
when ARM_Output.Insertion =>
raise Program_Error;
end case;
else -- we always display it.
Format_Object.Glossary_Info.Displayed :=
Format_Object.Include_Annotations;
Format_Object.Glossary_Info.Add_to_Glossary := True;
Local_Change := ARM_Output.None;
end if;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Term" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Copy the term:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Glossary_Info.Term,
Format_Object.Glossary_Info.Term_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Now, handle the parameter:
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Glossary_Text_Param,
Close_Ch => Close_Ch);
ARM_Input.Start_Recording (Input_Object);
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = Change_To_Glossary_Also then
-- The text just goes straight to the file.
if Format_Object.Glossary_Info.Add_to_Glossary then
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
ARM_Output.Ordinary_Text (Output_Object,
"[Glossary Entry]");
Format_Object.Last_Non_Space := True;
-- else no marker.
end if;
-- Index the term (because it does appear here):
Check_Paragraph; -- We've got to be in a paragraph to write this.
ARM_Index.Add (Term => Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len),
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
-- else no indexing.
end if;
elsif Format_Object.Glossary_Info.Displayed then -- Change_To_Glossary
-- Create the AARM annotation:
Check_End_Paragraph; -- End any paragraph that we're in.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Format_Object.Paragraph_Tab_Stops;
Format_Object.Next_Paragraph_Format_Type := Glossary_Marker;
Format_Object.Next_Paragraph_Subhead_Type := Glossary_Marker;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Format_Object.Next_Paragraph_Version := Format_Object.Glossary_Info.Version;
Format_Object.Next_Paragraph_Change_Kind := Kind;
-- We assume no outer changes;
-- set new change state:
Format_Object.Text_Format.Change := Local_Change;
Format_Object.Text_Format.Version :=
Format_Object.Glossary_Info.Version;
Format_Object.Text_Format.Added_Version := '0';
-- Change the state *before* outputting the
-- paragraph header, so the AARM prefix is included.
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
Format_Object.Text_Format.Change := ARM_Output.None; -- Undo (header) change.
Format_Object.Text_Format.Version := '0';
elsif Format_Object.Glossary_Info.Add_to_Glossary then -- Change_To_Glossary
-- No AARM annotation:
if Format_Object.Display_Index_Entries then
Display_Index_Entry (Format_Object.Glossary_Info.Term (1..Format_Object.Glossary_Info.Term_Len)); -- Includes Check_Paragraph.
ARM_Output.Ordinary_Text (Output_Object,
"[Glossary Entry]");
Format_Object.Last_Non_Space := True;
-- else no marker.
end if;
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
-- Note: The term is indexed in the glossary,
-- but not here.
else
-- Skip the text (it won't be used at all):
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
end if;
end if;
end;
when Implementation_Defined =>
-- Store an "implementation-defined" entry for the parameter;
-- also save the clause and paragraph reference.
ARM_Input.Start_Recording (Input_Object);
if Format_Object.Impdef_Info.Command /= None then
Ada.Text_IO.Put_Line (" ** Nested impdef entry on line " & ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
-- Setup impdef information for this command:
Format_Object.Impdef_Info :=
(Command => Impdef,
Change_Kind => ARM_Database.None,
Version => '0',
Initial_Version => '0',
Add_to_DB => True, -- Until we decide differently.
Paragraph_String => <>, -- Set below.
Paragraph_Len => <>);-- Set below.
if Format_Object.In_Paragraph then
-- Do this to preserve any inserted paragraph info.
Format_Object.Impdef_Info.Paragraph_String :=
Format_Object.Current_Paragraph_String;
Format_Object.Impdef_Info.Paragraph_Len :=
Format_Object.Current_Paragraph_Len;
else
declare
PNum : constant String := Positive'Image (
Format_Object.Next_Paragraph - 1);
begin
Format_Object.Impdef_Info.Paragraph_Len := PNum'Length - 1;
Format_Object.Impdef_Info.Paragraph_String (1 .. PNum'Last-1) :=
PNum (2 .. PNum'Last);
end;
end if;
if Format_Object.Include_Annotations then
Check_End_Paragraph; -- End any paragraph that we're in.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph := Format_Object.Last_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph := Format_Object.Next_Paragraph_Subhead_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format := Format_Object.Next_Paragraph_Format_Type;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops := Format_Object.Paragraph_Tab_Stops;
Format_Object.Next_Paragraph_Format_Type := Bare_Annotation;
Format_Object.Next_Paragraph_Subhead_Type := Bare_Annotation;
Format_Object.Paragraph_Tab_Stops := ARM_Output.NO_TABS;
Check_Paragraph;
declare
Bold_Format : ARM_Output.Format_Type :=
Format_Object.Text_Format;
begin
Bold_Format.Bold := True; -- Change only the boldface.
ARM_Output.Text_Format (Output_Object,
Bold_Format);
end;
ARM_Output.Ordinary_Text (Output_Object,
Text => "Implementation defined: ");
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset style.
Format_Object.Last_Paragraph_Subhead_Type := Bare_Annotation;
Format_Object.Last_Non_Space := False;
else -- No annotations
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
end if;
when Prefix_Type =>
-- Copy the text into the Format_Object.Prefix_Text string.
Check_Paragraph;
ARM_Input.Start_Recording (Input_Object);
-- No changes in this version (use ChgAttribute if you need that).
Format_Object.Attr_Prefix_Change_Kind := ARM_Database.None;
Format_Object.Attr_Prefix_Version := '0';
when Reset_Prefix_Type =>
-- Set Format_Object.Prefix_Text string to the default.
Format_Object.Prefix_Text := "@b{NONE!}" & (10..200 => ' ');
Format_Object.Prefix_Text_Len := 9;
when Attribute | Attribute_Leading =>
-- @Attribute{Prefix=<Prefix>,AttrName=<Name>,Text=<Text>}
-- Defines an attribute. Creates a hanging text item <Prefix>'<Name>,
-- with the specified text. The text can contain arbitrary commands;
-- it will be run through the full evaluation code.
-- The attribute and text is also sent to a database used to later create
-- Annex K. (This uses the current value of PrefixType.) Finally, the
-- attribute <Name> is indexed as by calling @Defn2{Term=[Attribute],
-- Sec=<Name>}, and as by calling @Defn{<Name> attribute}.
declare
Close_Ch : Character;
Key : ARM_Index.Index_Key;
begin
Check_End_Paragraph; -- This is always a paragraph end.
-- No changes in this version (use ChgAttribute if you need that).
Format_Object.Attr_Change_Kind := ARM_Database.None;
Format_Object.Attr_Version := '0';
Format_Object.Attr_Initial_Version := '0';
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Prefix" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save prefix:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Attr_Prefix,
Format_Object.Attr_Prefix_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "AttrName" & (9..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Attr_Name,
Format_Object.Attr_Name_Len);
-- else no parameter. Weird.
end if;
-- Output <Prefix>'<Name> as the hanging text.
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Attribute_Leading then
Format_Object.Space_After := ARM_Output.Narrow;
Format_Object.Attr_Leading := True;
else
Format_Object.Space_After := ARM_Output.Normal;
Format_Object.Attr_Leading := False;
end if;
Check_Paragraph;
ARM_Output.Ordinary_Text (Output_Object,
Format_Object.Attr_Prefix (1 .. Format_Object.Attr_Prefix_Len));
ARM_Output.Ordinary_Character (Output_Object, ''');
ARM_Output.Ordinary_Text (Output_Object,
Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len));
ARM_Output.End_Hang_Item (Output_Object);
Format_Object.Last_Non_Space := False; -- Treat like start of a line.
ARM_Index.Add (Term => "attributes",
Subterm => Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len) & " attribute",
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Now, handle the parameter:
-- The text goes to the file *and* is recorded.
Arm_Input.Start_Recording (Input_Object);
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Attribute_Text_Param,
Close_Ch => Close_Ch);
end if;
end;
when Pragma_Syntax =>
-- @PragmaSyntax{<Text>}
-- Defines a pragma. The text can contain arbitrary commands;
-- it will be run through the full evaluation code.
-- The text is also sent to a database used to later create
-- Annex L.
-- Note that these are indented slightly more than regular
-- syntax text. We handle that by adding a couple of
-- spaces before the text.
--Ada.Text_IO.Put_Line ("%% Pragma - normal initialization.");
-- All we have to do here is output a couple of
-- hard spaces and then start recording.
Check_Paragraph;
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
ARM_Input.Start_Recording (Input_Object);
-- Just handle the text normally.
when Added_Pragma_Syntax =>
-- @AddedPragmaSyntax{Version=[<Version>],<Text>}
-- Defines a pragma. The text can contain arbitrary commands;
-- it will be run through the full evaluation code.
-- The text is also sent to a database used to later create
-- Annex L.
-- Note that these are indented slightly more than regular
-- syntax text. We handle that by adding a couple of
-- spaces before the text.
declare
Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= ',' then
Ada.Text_IO.Put_Line (" ** Missing comma for AddedPragmaSyn on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version := Version;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version := Version; -- Don't have or need an InitialVersion parameter.
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
-- All we have to do here is output a couple of
-- hard spaces (if anything will be displayed) and then
-- start recording. The inner @Chg will handle the
-- formatting for this.
--Ada.Text_IO.Put_Line ("%% Added pragma.");
Check_Paragraph;
if Disposition /= Do_Not_Display_Text then
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
-- else nothing to display.
end if;
ARM_Input.Start_Recording (Input_Object);
-- Just handle the text normally.
end;
when Deleted_Pragma_Syntax =>
-- @DeletedPragmaSyntax{Version=[<Version>],InitialVersion=[<InitialVersion>],<Text>}
-- Defines a pragma. The text can contain arbitrary commands;
-- it will be run through the full evaluation code.
-- The text is also sent to a database used to later create
-- Annex L.
-- Note that these are indented slightly more than regular
-- syntax text. We handle that by adding a couple of
-- spaces before the text.
declare
Close_Ch, Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Initial_Version : ARM_Contents.Change_Version_Type := '0';
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Now, get InitialVersion.
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "InitialVersion" & (15..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
ARM_Input.Get_Char (Input_Object, Initial_Version);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for InitialVersion parameter on line " &
ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= ',' then
Ada.Text_IO.Put_Line (" ** Missing comma for AddedPragmaSyn on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version := Version;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version := Initial_Version;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
--Ada.Text_IO.Put_Line ("%% Deleted pragma.");
-- All we have to do here is output a couple of
-- hard spaces (if anything will be displayed) and then
-- start recording. The inner @Chg will handle the
-- formatting for this.
Check_Paragraph;
if Disposition /= Do_Not_Display_Text then
ARM_Output.Hard_Space (Output_Object);
ARM_Output.Hard_Space (Output_Object);
-- else nothing to display.
end if;
ARM_Input.Start_Recording (Input_Object);
-- Just handle the text normally.
end;
-- Clause title and reference commands:
when Labeled_Section | Labeled_Section_No_Break |
Labeled_Annex | Labeled_Informative_Annex |
Labeled_Normative_Annex | Labeled_Clause |
Labeled_Subclause | Labeled_Subsubclause |
Unnumbered_Section =>
-- Load the title into the Title string:
declare
Title : ARM_Contents.Title_Type;
Title_Length : Natural;
Level : ARM_Contents.Level_Type;
begin
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char,
Title, Title_Length);
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Subclause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause,
Subclause => Format_Object.Clause_Number.Subclause + 1,
Subsubclause => 0);
Level := ARM_Contents.Subclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Subsubclause then
Format_Object.Clause_Number.Subsubclause :=
Format_Object.Clause_Number.Subsubclause + 1;
Level := ARM_Contents.Subsubclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Clause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause + 1,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Clause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Unnumbered_Section then
Format_Object.Unnumbered_Section :=
Format_Object.Unnumbered_Section + 1;
Format_Object.Clause_Number :=
(Section => 0,
Clause => Format_Object.Unnumbered_Section,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Unnumbered_Section;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Section or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Section_No_Break then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Section;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Plain_Annex;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Normative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Normative_Annex;
else -- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Informative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Informative_Annex;
end if;
Title(Title_Length+1 .. Title'Last) :=
(others => ' ');
begin
declare
Clause_Number : constant String :=
ARM_Contents.Lookup_Clause_Number (Title);
begin
Check_End_Paragraph; -- End any paragraph that we're in.
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Section_No_Break then
ARM_Output.Clause_Header (Output_Object,
Title(1..Title_Length),
Level => ARM_Contents.Section,
Clause_Number => Clause_Number,
No_Page_Break => True,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
else -- Other cases:
ARM_Output.Clause_Header (Output_Object,
Title(1..Title_Length),
Level => Level,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end if;
-- Check that the section numbers match the title:
if Ada.Characters.Handling.To_Lower (Title) /=
Ada.Characters.Handling.To_Lower (ARM_Contents.Lookup_Title (
Level, Format_Object.Clause_Number)) then
Ada.Text_IO.Put_Line ("** Unable to match title with section numbers, line " & ARM_Input.Line_String (Input_Object));
end if;
--!!Debug:
--Ada.Text_IO.Put_Line ("Start clause " & Clause_Number & " -- " & Title(1..Title_Length));
end;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find header reference, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & Title(1..Title_Length));
end;
end;
-- Reset the paragraph numbers:
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
if Format_Object.Use_ISO_2004_Note_Format then
-- Reset the note number:
Format_Object.Next_Note := 1;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Section or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Section_No_Break or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Informative_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Normative_Annex then
-- Reset the note number, only for sections:
Format_Object.Next_Note := 1;
end if;
-- Reset the subhead:
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Header)");
when Labeled_Revised_Annex |
Labeled_Revised_Informative_Annex |
Labeled_Revised_Normative_Annex |
Labeled_Revised_Section |
Labeled_Revised_Clause |
Labeled_Revised_Subclause |
Labeled_Revised_Subsubclause =>
-- Load the title into the Title string:
declare
New_Title : ARM_Contents.Title_Type;
New_Title_Length : Natural;
Old_Title : ARM_Contents.Title_Type;
Old_Title_Length : Natural;
Close_Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Initial_Version : ARM_Contents.Change_Version_Type := '0';
Level : ARM_Contents.Level_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Check for the optional "InitialVersion" parameter,
-- stopping when we reach "New":
declare
Which_Param : ARM_Input.Param_Num;
Ch : Character;
begin
-- If there is no InitialVersion command, use the same
-- version of the rest of the command.
loop
ARM_Input.Check_One_of_Parameter_Names (Input_Object,
Param_Name_1 => "InitialVersion" & (15..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_2 => "New" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Found => Which_Param,
Param_Close_Bracket => Close_Ch);
if Which_Param = 1 and then Close_Ch /= ' ' then
-- Found InitialVersion
ARM_Input.Get_Char (Input_Object, Ch);
Initial_Version := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for InitialVersion parameter on line " &
ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
else -- We found "New" (or an error)
exit; -- Handling of New is below.
end if;
end loop;
end;
if Close_Ch /= ' ' then
-- There is a parameter:
-- Load the new title into the Title string:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
New_Title, New_Title_Length);
New_Title(New_Title_Length+1 .. New_Title'Last) :=
(others => ' ');
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Old" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- There is a parameter:
-- Load the new title into the Title string:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Old_Title, Old_Title_Length);
Old_Title(Old_Title_Length+1 .. Old_Title'Last) :=
(others => ' ');
end if;
end if;
ARM_Input.Get_Char (Input_Object, Close_Ch);
if Close_Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char then
Ada.Text_IO.Put_Line (" ** Bad close for Labeled_Revised_(SubClause|Annex) on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Subclause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause,
Subclause => Format_Object.Clause_Number.Subclause + 1,
Subsubclause => 0);
Level := ARM_Contents.Subclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Subsubclause then
Format_Object.Clause_Number.Subsubclause :=
Format_Object.Clause_Number.Subsubclause + 1;
Level := ARM_Contents.Subsubclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Clause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause + 1,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Clause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Section then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Section;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Plain_Annex;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Normative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Normative_Annex;
else -- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Informative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Informative_Annex;
end if;
begin
declare
Clause_Number : constant String :=
ARM_Contents.Lookup_Clause_Number (New_Title);
New_Disposition : ARM_Output.Change_Type;
Old_Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Check_End_Paragraph; -- End any paragraph that we're in.
-- Check that the section numbers match the title:
if Ada.Characters.Handling.To_Lower (New_Title) /=
Ada.Characters.Handling.To_Lower (ARM_Contents.Lookup_Title (
Level, Format_Object.Clause_Number)) then
Ada.Text_IO.Put_Line ("** Unable to match title with section numbers, line " & ARM_Input.Line_String (Input_Object));
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => New_Disposition);
-- Note: We use insertion here because
-- we want to decide what to do with
-- the New part.
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Initial_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Old_Disposition);
if New_Disposition = Do_Not_Display_Text then
if Old_Disposition = Do_Not_Display_Text then
null; -- Show nothing.
elsif Old_Disposition = ARM_Output.None then
-- Use the old only:
ARM_Output.Clause_Header (Output_Object,
Old_Title(1..Old_Title_Length),
Level => Level,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
elsif Old_Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- an insertion of the Old. Show this like an added item:
ARM_Output.Revised_Clause_Header (Output_Object,
New_Header_Text => Old_Title(1..Old_Title_Length),
Old_Header_Text => "",
Level => Level,
Version => Initial_Version,
Old_Version => '0',
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end if;
elsif New_Disposition = ARM_Output.None then
-- Use the new only:
ARM_Output.Clause_Header (Output_Object,
New_Title(1..New_Title_Length),
Level => Level,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
-- In this case, we have no sane
-- way to show the old, so we hope that
-- isn't expected.
--!!Debug:
--Ada.Text_IO.Put_Line ("Start clause " & Clause_Number & " -- " & New_Title(1..New_Title_Length));
elsif New_Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
if Format_Object.Changes = ARM_Format.New_Changes or else
Old_Disposition = Do_Not_Display_Text then
ARM_Output.Revised_Clause_Header (Output_Object,
New_Header_Text => New_Title(1..New_Title_Length),
Old_Header_Text => " ",
Level => Level,
Version => Version,
Old_Version => '0',
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
elsif Old_Disposition = ARM_Output.None then
-- Show old without any insertion marks:
ARM_Output.Revised_Clause_Header (Output_Object,
New_Header_Text => New_Title(1..New_Title_Length),
Old_Header_Text => Old_Title(1..Old_Title_Length),
Level => Level,
Version => Version,
Old_Version => '0',
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
elsif Old_Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- An insertion of the Old item:
ARM_Output.Revised_Clause_Header (Output_Object,
New_Header_Text => New_Title(1..New_Title_Length),
Old_Header_Text => Old_Title(1..Old_Title_Length),
Level => Level,
Version => Version,
Old_Version => Initial_Version,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end if;
--!!Debug:
--Ada.Text_IO.Put_Line ("Start clause " & Clause_Number & " -- " & New_Title(1..New_Title_Length));
end if;
end;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find header reference, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & New_Title(1..New_Title_Length));
end;
-- Reset the paragraph numbers:
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
if Format_Object.Use_ISO_2004_Note_Format then
-- Reset the note number:
Format_Object.Next_Note := 1;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Section or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Informative_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Revised_Normative_Annex then
-- Reset the note number, only for sections:
Format_Object.Next_Note := 1;
end if;
-- Reset the subhead:
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Header)");
end;
when Labeled_Added_Annex |
Labeled_Added_Informative_Annex |
Labeled_Added_Normative_Annex |
Labeled_Added_Section |
Labeled_Added_Clause |
Labeled_Added_Subclause |
Labeled_Added_Subsubclause =>
-- Load the title into the Title string:
declare
New_Title : ARM_Contents.Title_Type;
New_Title_Length : Natural;
Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Level : ARM_Contents.Level_Type;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Name" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Ch);
if Ch /= ' ' then
-- There is a parameter:
-- Load the new title into the Title string:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Ch,
New_Title, New_Title_Length);
New_Title(New_Title_Length+1 .. New_Title'Last) :=
(others => ' ');
end if;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char then
Ada.Text_IO.Put_Line (" ** Bad close for Labeled_Added_(Sub)Clause on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
null; -- Ignore this; it isn't numbered or anything.
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Subclause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause,
Subclause => Format_Object.Clause_Number.Subclause + 1,
Subsubclause => 0);
Level := ARM_Contents.Subclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Subsubclause then
Format_Object.Clause_Number.Subsubclause :=
Format_Object.Clause_Number.Subsubclause + 1;
Level := ARM_Contents.Subsubclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Clause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause + 1,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Clause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Section then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Section;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Plain_Annex;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Normative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Normative_Annex;
else -- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Informative_Annex then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section, -- Will be set elsewhere.
Clause => 0,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Informative_Annex;
end if;
begin
declare
Clause_Number : constant String :=
ARM_Contents.Lookup_Clause_Number (New_Title);
begin
if Disposition = ARM_Output.None then
-- Normal reference:
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Clause_Header (Output_Object,
New_Title(1..New_Title_Length),
Level => Level,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
else -- Insertion.
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Revised_Clause_Header (Output_Object,
New_Header_Text => New_Title(1..New_Title_Length),
Old_Header_Text => "",
Level => Level,
Version => Version,
Old_Version => '0',
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end if;
-- Check that the section numbers match the title:
if Ada.Characters.Handling.To_Lower (New_Title) /=
Ada.Characters.Handling.To_Lower (ARM_Contents.Lookup_Title (
Level, Format_Object.Clause_Number)) then
Ada.Text_IO.Put_Line ("** Unable to match title with section numbers, line " & ARM_Input.Line_String (Input_Object));
end if;
--!!Debug:
--Ada.Text_IO.Put_Line ("Start clause " & Clause_Number & " -- " & New_Title(1..New_Title_Length));
end;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find header reference, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & New_Title(1..New_Title_Length));
end;
-- Reset the paragraph numbers:
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
if Format_Object.Use_ISO_2004_Note_Format then
-- Reset the note number:
Format_Object.Next_Note := 1;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Section or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Informative_Annex or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Added_Normative_Annex then
-- Reset the note number, only for sections:
Format_Object.Next_Note := 1;
end if;
-- Reset the subhead:
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
end if;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Header)");
end;
when Labeled_Deleted_Clause |
Labeled_Deleted_Subclause |
Labeled_Deleted_Subsubclause =>
-- Load the title into the Title string:
declare
Old_Title : ARM_Contents.Title_Type;
Old_Title_Length : Natural;
Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Level : ARM_Contents.Level_Type;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Name" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Ch);
if Ch /= ' ' then
-- There is a parameter:
-- Load the new title into the Title string:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Ch,
Old_Title, Old_Title_Length);
Old_Title(Old_Title_Length+1 .. Old_Title'Last) :=
(others => ' ');
end if;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char then
Ada.Text_IO.Put_Line (" ** Bad close for Labeled_Deleted_(Sub)Clause on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
--Ada.Text_IO.Put_Line ("Labeled_Deleted disp: " & ARM_Output.Change_Type'Image(Disposition));
--Ada.Text_IO.Put_Line (" Version:" & Version);
if Disposition = Do_Not_Display_Text then
null; -- Ignore this; it isn't numbered or anything.
elsif Disposition = ARM_Output.Insertion then
raise Program_Error; -- An insertion inside of a deletion command!
elsif Disposition = ARM_Output.Deletion then
-- Format the text as a deletion, but not as a header.
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Title,
Indent => 0,
Number => "");
ARM_Output.Text_Format (Output_Object,
Format => (Bold => True,
Italic => False,
Font => ARM_Output.Default,
Size => ARM_Output.Size_Type(-2),
Color => ARM_Output.Default,
Change => ARM_Output.Deletion,
Version => Version,
Added_Version => '0',
Location => ARM_Output.Normal));
ARM_Output.Ordinary_Text (Output_Object,
Old_Title(1..Old_Title_Length));
ARM_Output.Text_Format (Output_Object,
ARM_Output.NORMAL_FORMAT);
ARM_Output.End_Paragraph (Output_Object);
-- Reset the paragraph numbers: (for the following deleted text, presumably also shown).
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
if Format_Object.Use_ISO_2004_Note_Format then
-- Reset the note number:
Format_Object.Next_Note := 1;
--elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Section or else
-- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Annex or else
-- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Informative_Annex or else
-- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Normative_Annex then
-- -- Reset the note number, only for sections: (no sections yet)
-- Format_Object.Next_Note := 1;
end if;
-- Reset the subhead:
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
else -- Disposition = ARM_Output.None then
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Subclause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause,
Subclause => Format_Object.Clause_Number.Subclause + 1,
Subsubclause => 0);
Level := ARM_Contents.Subclause;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Subsubclause then
Format_Object.Clause_Number.Subsubclause :=
Format_Object.Clause_Number.Subsubclause + 1;
Level := ARM_Contents.Subsubclause;
else --Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Labeled_Deleted_Clause then
Format_Object.Clause_Number :=
(Section => Format_Object.Clause_Number.Section,
Clause => Format_Object.Clause_Number.Clause + 1,
Subclause => 0, Subsubclause => 0);
Level := ARM_Contents.Clause;
end if;
begin
declare
Clause_Number : constant String :=
ARM_Contents.Lookup_Clause_Number (Old_Title);
begin
-- Normal reference:
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Clause_Header (Output_Object,
Old_Title(1..Old_Title_Length),
Level => Level,
Clause_Number => Clause_Number,
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
end;
-- Check that the section numbers match the title:
if Ada.Characters.Handling.To_Lower (Old_Title) /=
Ada.Characters.Handling.To_Lower (ARM_Contents.Lookup_Title (
Level, Format_Object.Clause_Number)) then
Ada.Text_IO.Put_Line ("** Unable to match title with section numbers, line " & ARM_Input.Line_String (Input_Object));
end if;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find header reference, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & Old_Title(1..Old_Title_Length));
end;
-- Reset the paragraph numbers:
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
-- Reset the subhead:
Format_Object.Last_Paragraph_Subhead_Type := Plain;
Format_Object.Next_Paragraph_Format_Type := Plain;
end if;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Header)");
end;
when Preface_Section =>
Check_End_Paragraph; -- End any paragraph that we're in.
--ARM_Output.New_Page (Output_Object, ARM_Output.Odd_Page_Only);
ARM_Output.Clause_Header (Output_Object,
Header_Text => "",
Level => ARM_Contents.Unnumbered_Section,
Clause_Number => "0.99",
Top_Level_Subdivision_Name => Format_Object.Top_Level_Subdivision_Name);
when Subheading =>
-- This is used in preface sections where no numbers or
-- contents are desired.
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Wide_Above,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => True);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Format_Object.Text_Format.Bold := True;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
Format_Object.Text_Format.Size := 2;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
when Added_Subheading =>
-- This is used in preface sections where no numbers or
-- contents are desired.
declare
Ch : Character;
Version : ARM_Contents.Change_Version_Type := '0';
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= ',' then
Ada.Text_IO.Put_Line (" ** Missing comma for AddedSubheading on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version := Version;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
elsif Disposition = ARM_Output.None then
-- Normal text:
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Wide_Above,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => True);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Format_Object.Text_Format.Bold := True;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
Format_Object.Text_Format.Size := 2;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Wide_Above,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => True);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Format_Object.Text_Format.Bold := True;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
Format_Object.Text_Format.Size := 2;
Format_Object.Text_Format.Change := ARM_Output.Insertion;
Format_Object.Text_Format.Version := Version;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
end if;
end;
when Heading =>
-- This is used in preface sections where no numbers or
-- contents are desired.
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Title,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => True,
Justification => ARM_Output.Center);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Format_Object.Text_Format.Bold := True;
Format_Object.Text_Format.Font := ARM_Output.Swiss;
Format_Object.Text_Format.Size := 0;
-- Note that the size is +3 from the Title format.
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
when Center =>
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Normal,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => False,
Justification => ARM_Output.Center);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
when Right =>
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.Start_Paragraph (Output_Object,
Style => ARM_Output.Normal,
Indent => 0,
Number => "",
No_Breaks => True, Keep_with_Next => False,
Justification => ARM_Output.Right);
Format_Object.In_Paragraph := True;
Format_Object.No_Start_Paragraph := False;
when Ref_Section | Ref_Section_Number =>
-- Load the title into the Title string:
declare
Ch : Character;
Title : ARM_Contents.Title_Type;
Title_Length : Natural;
begin
ARM_Input.Get_Char (Input_Object, Ch);
Title_Length := 0;
while Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char loop
Title_Length := Title_Length + 1;
Title(Title_Length) := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
Title(Title_Length+1 .. Title'Last) :=
(others => ' ');
begin
declare
Clause_Number_Text : constant String :=
ARM_Contents.Lookup_Clause_Number (Title);
begin
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section then
Check_Paragraph;
ARM_Output.Clause_Reference (Output_Object,
Text => Clause_Number_Text,
Clause_Number => Clause_Number_Text);
ARM_Output.Ordinary_Text (Output_Object, ", ");
-- Was: (To match the Ada 95 Standard)
--ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Quote);
--ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Quote);
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Double_Quote);
if Format_Object.Change_Version < '1' or else
Format_Object.Changes = ARM_Format.Old_Only then
-- Use original version:
declare
Clause_Number : ARM_Contents.Clause_Number_Type;
begin
ARM_Contents.Make_Clause (Clause_Number_Text,
Clause_Number);
ARM_Output.Clause_Reference (Output_Object,
Text => Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Old_Title (
ARM_Contents.Lookup_Level (Title),
Clause_Number),
Ada.Strings.Right),
Clause_Number => Clause_Number_Text);
end;
else
-- Use new version. We don't have version numbers for these yet.
ARM_Output.Clause_Reference (Output_Object,
Text => Title(1..Title_Length),
Clause_Number => Clause_Number_Text);
end if;
-- Was: (To match the Ada 95 Standard)
--ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote);
--ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote);
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Double_Quote);
else -- Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Ref_Section_Number then
Check_Paragraph;
ARM_Output.Clause_Reference (Output_Object,
Text => Clause_Number_Text,
Clause_Number => Clause_Number_Text);
end if;
Format_Object.Last_Non_Space := True;
end;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find section reference, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & Title(1..Title_Length));
end;
end;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Section Reference)");
when Ref_Section_by_Number =>
-- Load the number into the Number string:
declare
Ch : Character;
Number : String(1..20);
Number_Length : Natural;
begin
ARM_Input.Get_Char (Input_Object, Ch);
Number_Length := 0;
while Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char loop
Number_Length := Number_Length + 1;
Number(Number_Length) := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
Number(Number_Length+1 .. Number'Last) :=
(others => ' ');
Check_Paragraph;
ARM_Output.Clause_Reference (Output_Object,
Text => Number(1..Number_Length),
Clause_Number => Number(1..Number_Length));
Format_Object.Last_Non_Space := True;
-- No checking here.
end;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
--Ada.Text_IO.Put_Line (" &Unstack (Section Num Reference)");
-- Link commands:
when Local_Target =>
-- @LocalTarget{Target=[<target-text>],Text=[<text>]}
declare
Close_Ch : Character;
Target : String(1..40);
Target_Len : Natural;
Text : String(1..100);
Text_Len : Natural;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Target" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save URL:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Target,
Target_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Text,
Text_Len);
-- else no parameter. Weird.
end if;
Check_Paragraph;
ARM_Output.Local_Target (Output_Object,
Text => Text(1..Text_Len),
Target => Target(1..Target_Len));
if Text_Len /= 0 and then Text(Text_Len) /= ' ' then
Format_Object.Last_Non_Space := True;
end if;
end;
-- Leave the command end marker, let normal processing
-- get rid of it.
when Local_Link =>
-- @LocalLink{Target=[<target-text>],Sec=[<title>],Text=[<text>]}
declare
Close_Ch : Character;
Target : String(1..40);
Target_Len : Natural;
Text : String(1..100);
Text_Len : Natural;
Title : ARM_Contents.Title_Type;
Title_Length : Natural;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Target" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save URL:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Target,
Target_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Sec" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save URL:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Title,
Title_Length);
Title(Title_Length+1 .. Title'Last) :=
(others => ' ');
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Text,
Text_Len);
-- else no parameter. Weird.
end if;
begin
declare
Clause_Number_Text : constant String :=
ARM_Contents.Lookup_Clause_Number (Title);
begin
Check_Paragraph;
ARM_Output.Local_Link (Output_Object,
Text => Text(1..Text_Len),
Target => Target(1..Target_Len),
Clause_Number => Clause_Number_Text);
if Text_Len /= 0 and then Text(Text_Len) /= ' ' then
Format_Object.Last_Non_Space := True;
end if;
end;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find section in local link, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Looking for " & Title(1..Title_Length));
end;
end;
-- Leave the command end marker, let normal processing
-- get rid of it.
when URL_Link =>
-- @URLLink{URL=[<URL>],Text=[<text>]}
declare
Close_Ch : Character;
URL : String(1..80);
URL_Len : Natural;
Text : String(1..100);
Text_Len : Natural;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "URL" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save URL:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
URL,
URL_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Text,
Text_Len);
-- else no parameter. Weird.
end if;
Check_Paragraph;
ARM_Output.URL_Link (Output_Object,
Text => Text(1..Text_Len),
URL => URL(1..URL_Len));
if Text_Len /= 0 and then Text(Text_Len) /= ' ' then
Format_Object.Last_Non_Space := True;
end if;
end;
-- Leave the command end marker, let normal processing
-- get rid of it.
when AI_Link =>
-- @AILink{AI=[<AI>],Text=[<text>]}
declare
Close_Ch : Character;
AI : String(1..30);
AI_Len : Natural;
Text : String(1..100);
Text_Len : Natural;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "AI" & (3..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => True,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save AI:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
AI,
AI_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Text,
Text_Len);
-- else no parameter. Weird.
end if;
Check_Paragraph;
ARM_Output.AI_Reference (Output_Object,
Text => Text(1..Text_Len),
AI_Number => AI(1..AI_Len));
if Text_Len /= 0 and then Text(Text_Len) /= ' ' then
Format_Object.Last_Non_Space := True;
end if;
end;
-- Leave the command end marker, let normal processing
-- get rid of it.
-- Change commands:
when Change =>
-- This command is of the form:
-- @chg{[version=<Version>],new=[<new text>],old=[<old text>]}.
-- where the parameter names (other than version) are
-- optional (but highly recommended), and the curly and
-- square brackets can be any of the allowed bracketing characters.
-- We have to process this in parts, in order that the
-- text can be handled normally.
declare
Ch : Character;
Saw_Version : Boolean;
begin
-- Check for the optional "Version" parameter:
ARM_Input.Get_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object);
if Ch = 'V' or else Ch = 'v' then
-- There is a Version parameter, grab it.
Get_Change_Version (Is_First => True,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version);
-- Read a parameter named "Version".
Saw_Version := True;
else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version := '1';
Saw_Version := False;
end if;
-- Save the current state:
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change :=
Format_Object.Text_Format.Change;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version :=
Format_Object.Text_Format.Version;
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Added_Change_Version :=
Format_Object.Text_Format.Added_Version;
-- Check and handle the "New" parameter:
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "New" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => not Saw_Version,
Param_Close_Bracket => Ch);
if Ch /= ' ' then
-- There is a parameter:
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Change_Param_New,
Close_Ch => Ch);
Format_Object.In_Change := True;
-- Note: We can't use Calc_Change_Disposition here,
-- because it isn't intended to work on possibly
-- nested calls like these.
-- Now, handle the parameter:
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version >
Format_Object.Change_Version then
-- Ignore any changes with version numbers higher than
-- the current maximum.
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
else
case Format_Object.Changes is
when ARM_Format.Old_Only =>
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
when ARM_Format.New_Only =>
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
-- In a deleted paragraph, call Check_Paragraph
-- to trigger the "deleted paragraph" message.
-- (Otherwise, this never happens.)
Check_Paragraph;
-- else null; -- Nothing special to do.
end if;
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version <
Format_Object.Base_Change_Version then
-- Just normal output text.
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
-- In a deleted paragraph, call Check_Paragraph
-- to trigger the "deleted paragraph" message.
-- (Otherwise, this never happens.)
Check_Paragraph;
-- else null; -- Nothing special to do.
end if;
else
ARM_Input.Get_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object);
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text :=
Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char;
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text then
-- Non-empty text; Calculate new change state (current is insertion):
Check_Paragraph; -- Change the state *after* outputting the paragraph header.
case Format_Object.Text_Format.Change is
when ARM_Output.Insertion | ARM_Output.None =>
Format_Object.Text_Format.Change := ARM_Output.Insertion;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
Format_Object.Text_Format.Added_Version := '0';
when ARM_Output.Deletion =>
Format_Object.Text_Format.Change := ARM_Output.Both;
Format_Object.Text_Format.Added_Version := -- The insertion should be older.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
-- .Text_Format.Version is unchanged.
when ARM_Output.Both =>
Format_Object.Text_Format.Change := ARM_Output.Both;
Format_Object.Text_Format.Added_Version := -- The insertion should be older.
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
-- .Text_Format.Version is unchanged.
end case;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Set style.
-- else no text, so don't bother.
end if;
end if;
end case;
end if;
-- else no parameter. Weird.
end if;
end;
when Change_Param_Old | Change_Param_New =>
-- These can't get here; they represent the parameters of
-- "Change" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Change parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Added | Change_Deleted =>
-- @ChgAdded{Version=[<Version>],[NoPrefix=[T|F],][NoParanum=[T|F],]
-- [Type=[Leading|Trailing|Normal],][Keepnext=[T|F],]Text=[text]}
-- @ChgDeleted{Version=[<Version>],[NoPrefix=[T|F],][NoParanum=[T|F],]
-- [Type=[Leading|Trailing|Normal],][Keepnext=[T|F],]Text=[text]}
-- Whole paragraph change. These let us modify the AARM prefix
-- (like "Reason:" or "Discussion:", and also let us
-- conditionally handle paragraph formatting (which
-- otherwise would come too late).
declare
Which_Param : ARM_Input.Param_Num;
Close_Ch : Character;
NoPrefix, Noparanum, Keepnext : Boolean := False;
Space_After : ARM_Output.Space_After_Type := ARM_Output.Normal;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
function Read_Boolean (Close_Ch : in Character;
Name : in String) return Boolean is
-- Read a Boolean parameter for a parameter already
-- opened and ending with Close_Ch.
-- Name is the name of the parameter; for error messages only.
Ch : Character;
Result : Boolean;
begin
ARM_Input.Get_Char (Input_Object, Ch);
case Ch is
when 'F' | 'f' | 'N' | 'n' =>
Result := False;
when 'T' | 't' | 'Y' | 'y' =>
Result := True;
when others =>
Ada.Text_IO.Put_Line (" ** Bad value for boolean parameter " &
Name & " on line " & ARM_Input.Line_String (Input_Object));
end case;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for boolean parameter " &
Name & " on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
return Result;
end Read_Boolean;
function Read_Type (Close_Ch : in Character) return ARM_Output.Space_After_Type is
-- Read the Type parameter.
Type_Name : ARM_Input.Command_Name_Type;
Ch : Character;
Result : ARM_Output.Space_After_Type := ARM_Output.Normal;
begin
-- Get the type word:
Arm_Input.Get_Name (Input_Object, Type_Name);
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for Type on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
if Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Type_Name, Ada.Strings.Right)) =
"leading" then
Result := ARM_Output.Narrow;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Type_Name, Ada.Strings.Right)) =
"trailing" then
Result := ARM_Output.Wide;
elsif Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Type_Name, Ada.Strings.Right)) =
"normal" then
Result := ARM_Output.Normal;
else
Ada.Text_IO.Put_Line (" ** Bad type for paragraph type: " &
Ada.Strings.Fixed.Trim (Type_Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end if;
return Result;
end Read_Type;
begin
-- These are not allowed in other @Chg commands.
if Format_Object.In_Change then
Ada.Text_IO.Put_Line ("** ChgAdded/ChgDeleted nested in other Chg, line " & ARM_Input.Line_String (Input_Object));
end if;
Get_Change_Version (Is_First => True,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version);
-- Read a parameter named "Version".
loop
-- Handle the optional parameters; stop on Text.
ARM_Input.Check_One_of_Parameter_Names (Input_Object,
Param_Name_1 => "NoPrefix" & (9..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_2 => "NoParanum" & (10..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_3 => "Type" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_4 => "Keepnext" & (9..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_5 => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Found => Which_Param,
Param_Close_Bracket => Close_Ch);
if Which_Param = 1 and then Close_Ch /= ' ' then
NoPrefix := Read_Boolean (Close_Ch, "NoPrefix");
elsif Which_Param = 2 and then Close_Ch /= ' ' then
NoParanum := Read_Boolean (Close_Ch, "NoParanum");
elsif Which_Param = 3 and then Close_Ch /= ' ' then
Space_After := Read_Type (Close_Ch);
elsif Which_Param = 4 and then Close_Ch /= ' ' then
Keepnext := Read_Boolean (Close_Ch, "KeepNext");
else
exit; -- We found "Text" (or an error)
end if;
end loop;
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Change_Added and then
Close_Ch /= ' ' then
-- Generate an insertion, there is a Text parameter.
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Change_Added_Param,
Close_Ch => Close_Ch);
Format_Object.In_Change := True;
if Disposition = Do_Not_Display_Text then
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
elsif Disposition = ARM_Output.None then
-- Display the text normally.
Format_Object.No_Prefix := NoPrefix;
Format_Object.No_Para_Num := NoParanum;
Format_Object.Keep_with_Next := KeepNext;
Format_Object.Space_After := Space_After;
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
Format_Object.No_Prefix := NoPrefix;
Format_Object.No_Para_Num := NoParanum;
Format_Object.Keep_with_Next := KeepNext;
Format_Object.Space_After := Space_After;
-- We assume non-empty text and no outer changes;
-- set new change state:
Format_Object.Text_Format.Change := ARM_Output.Insertion;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- Change the state *before* outputting the
-- paragraph header, so the AARM prefix is included.
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset style.
end if;
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Change_Deleted and then
Close_Ch /= ' ' then
-- Generate a deletion.
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Change_Deleted_Param,
Close_Ch => Close_Ch);
Format_Object.In_Change := True;
if Disposition = Do_Not_Display_Text then
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
if ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Format_Object.Next_Paragraph_Change_Kind,
ARM_Database.Deleted_Inserted_Number_No_Delete_Message) then
-- In a deleted paragraph, call Check_Paragraph
-- to trigger the "deleted paragraph" message and
-- increment the paragraph number.
-- (Otherwise, this may never happen.)
Format_Object.No_Para_Num := NoParanum;
Check_Paragraph;
-- else null; -- Nothing special to do.
end if;
elsif Disposition = ARM_Output.None then
-- Display the text normally.
Format_Object.No_Prefix := NoPrefix;
Format_Object.No_Para_Num := NoParanum;
Format_Object.Keep_with_Next := KeepNext;
Format_Object.Space_After := Space_After;
elsif Disposition = ARM_Output.Insertion then
raise Program_Error; -- An insertion inside of a deletion command!
else -- Deletion.
if Format_Object.Changes = ARM_Format.New_Changes then
-- Special case: we ignore the deleted text, but mark its presence.
-- We assume that the text is non-empty;
-- set the new change state.
-- Note: We ignore the formatting here!
Format_Object.No_Prefix := True;
Format_Object.No_Para_Num := NoParanum;
Format_Object.Text_Format.Change := ARM_Output.Deletion;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- Output the paragraph headers *after* changing the state,
-- so that AARM headers are marked.
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset style.
ARM_Output.Ordinary_Character (Output_Object, ' ');
-- Skip the text (we're not going to output it):
ARM_Input.Skip_until_Close_Char (Input_Object, Close_Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
else -- Normal.
-- We assume that the text is non-empty;
-- set the new change state and formatting.
Format_Object.No_Prefix := NoPrefix;
Format_Object.No_Para_Num := NoParanum;
Format_Object.Keep_with_Next := KeepNext;
Format_Object.Space_After := Space_After;
Format_Object.Text_Format.Change := ARM_Output.Deletion;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- Output the paragraph headers *after* changing the state,
-- so that AARM headers are marked.
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format); -- Reset style.
end if;
end if;
-- else no parameter; previous error.
end if;
end;
when Change_Added_Param | Change_Deleted_Param =>
-- These can't get here; they represent the parameter of
-- "Change_Added" and "Change_Deleted" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Change_xxx parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Table_Param_Caption | Table_Param_Header | Table_Param_Body =>
-- These can't get here; they represent the parameters of
-- "Table" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Table parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Syntax_Rule_RHS =>
-- This can't get here; it represents the second parameter of
-- "Syn" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Syntax parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Glossary_Text_Param =>
-- This can't get here; it represents the second parameter of
-- "ToGlossary" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Glossary parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Attribute_Text_Param =>
-- This can't get here; it represents the third parameter of
-- "Attribute" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Attribute parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Impdef_Text_Param =>
-- This can't get here; it represents the third parameter of
-- "ChgImpldef" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Impdef parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Impladv_Text_Param =>
-- This can't get here; it represents the third parameter of
-- "ChgImpladvice" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Impladv parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Docreq_Text_Param =>
-- This can't get here; it represents the third parameter of
-- "ChgDocReq" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Docreq parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_AspectDesc_Text_Param =>
-- This can't get here; it represents the fourth parameter of
-- "ChgAspectDesc" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** AspectDesc parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Prefix_Text_Param =>
-- This can't get here; it represents the second parameter of
-- "ChgPrefixType" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** ChgPrefix parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Reference =>
-- This command is of the form:
-- @chgref{Version=[<version>], Kind=(<kind>)
-- {,Ref=(<DR_Number>)}{,ARef=(<AI_Number>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, followed by zero or more
-- DR references, and finally zero or more AI references.
-- As usual, any of the allowed bracketing characters can
-- be used.
declare
Ch : Character;
Kind : ARM_Database.Paragraph_Change_Kind_Type;
Version : ARM_Contents.Change_Version_Type;
Display_It : Boolean;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
Get_Change_Kind (Kind);
-- Read a parameter named "Kind".
if Version <= Format_Object.Change_Version then
Format_Object.Next_Paragraph_Version := Version;
Format_Object.Next_Paragraph_Change_Kind := Kind;
if (ARM_Database."=" (Kind, ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- In this case, display nothing, period.
Display_It := False;
-- Check if any Ref's already exist; remove them
-- if they do. %% Ugly: This is needed if
-- a paragraph is first revised, then deleted,
-- as in 4.6. There ought to be a better way
-- of handling this, not sure what it is.
Dump_References (Format_Object.References);
elsif (ARM_Database."=" (Kind, ARM_Database.Deleted) or else
ARM_Database."=" (Kind, ARM_Database.Deleted_Inserted_Number)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) and then
(not Format_Object.Number_Paragraphs) then
-- No delete messages ever in this case, so
-- display nothing, period.
Display_It := False;
-- Check if any Ref's already exist; see above.
Dump_References (Format_Object.References);
else
Display_It := Format_Object.Include_Annotations;
end if;
else --This reference is too new, ignore it.
Display_It := False;
end if;
-- Handle zero or more "Ref" parameters.
loop
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= ',' then
exit; -- No more commands.
else
ARM_Input.Replace_Char (Input_Object);
end if;
Gen_Ref_or_ARef_Parameter (Display_It);
-- Read (and possibly generate) a "Ref" or "ARef" parameter.
end loop;
-- Now, close the command.
-- Ch was read when checking for commas, above.
if Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char then
Ada.Text_IO.Put_Line (" ** Bad close for Chgref on line " & ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Change_Reference" record.
end;
when Change_Note =>
-- Skip the contents of this command.
ARM_Input.Skip_until_Close_Char (Input_Object,
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char);
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Change_Note" record.
when Change_Implementation_Defined =>
-- This command is of the form:
-- @chgimpldef{Version=[<version>], Kind=(<kind>),
-- Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
Gen_Chg_xxxx (Param_Cmd => Change_Impdef_Text_Param,
AARM_Prefix => "Implementation defined: ");
when Change_Implementation_Advice =>
-- This command is of the form:
-- @chgimpladvice{Version=[<version>], Kind=(<kind>),
-- Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
Gen_Chg_xxxx (Param_Cmd => Change_Impladv_Text_Param,
AARM_Prefix => "Implementation Advice: ");
when Change_Documentation_Requirement =>
-- This command is of the form:
-- @chgdocreq{Version=[<version>], Kind=(<kind>),
-- Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
Gen_Chg_xxxx (Param_Cmd => Change_Docreq_Text_Param,
AARM_Prefix => "Documentation Requirement: ");
when Change_Aspect_Description =>
-- This command is of the form:
-- @chgaspectdesc{Version=[<version>], Kind=(<kind>),
-- Aspect=[<name>],Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, <Name> is the aspect
-- name, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
Gen_Chg_xxxx (Param_Cmd => Change_AspectDesc_Text_Param,
AARM_Prefix => "Aspect Description for ");
when Change_Attribute =>
-- @ChgAttribute{Version=[<version>], Kind=(<kind>),
-- Chginannex=[T|F],Leading=[T|F],
-- Prefix=<Prefix>,AttrName=<Name>,
-- {[A]Ref=[<DR_Number>]},Text=<Text>}
-- Defines a changed attribute.
declare
Close_Ch : Character;
Key : ARM_Index.Index_Key;
Chg_in_Annex : Boolean;
Is_Leading : Boolean;
Kind : ARM_Database.Paragraph_Change_Kind_Type;
Version : ARM_Contents.Change_Version_Type;
InitialVersion : ARM_Contents.Change_Version_Type;
Display_Ref : Boolean;
References : Reference_Ptr := null;
procedure Make_Attribute_Text is
-- Generate the attribute text.
-- Output <Prefix>'<Name> as the hanging text.
-- Generate the needed index entries.
begin
Check_Paragraph;
ARM_Output.Ordinary_Text (Output_Object,
Format_Object.Attr_Prefix (1 .. Format_Object.Attr_Prefix_Len));
ARM_Output.Ordinary_Character (Output_Object, ''');
ARM_Output.Ordinary_Text (Output_Object,
Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len));
ARM_Output.End_Hang_Item (Output_Object);
Format_Object.Last_Non_Space := False; -- Treat like start of a line.
ARM_Index.Add (Term => "attributes",
Subterm => Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len),
Kind => ARM_Index.Primary_Term_and_Subterm,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
ARM_Index.Add (Term => Format_Object.Attr_Name (1 .. Format_Object.Attr_Name_Len) & " attribute",
Kind => ARM_Index.Primary_Term,
Clause => Clause_String (Format_Object),
Paragraph => Paragraph_String,
Key => Key);
ARM_Output.Index_Target (Output_Object, Key);
Make_References (References, Format_Object, Output_Object);
end Make_Attribute_Text;
begin
Check_End_Paragraph; -- This is always a paragraph end.
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
Get_Change_Kind (Kind);
-- Read a parameter named "Kind".
if Version <= Format_Object.Change_Version then
Format_Object.Next_Paragraph_Version := Version;
Format_Object.Next_Paragraph_Change_Kind := Kind;
if (ARM_Database."=" (Kind, ARM_Database.Deleted_No_Delete_Message) or else
ARM_Database."=" (Kind, ARM_Database.Deleted_Inserted_Number_No_Delete_Message)) and then
ARM_Format."=" (Format_Object.Changes, ARM_Format.New_Only) then
-- In this case, display nothing, period.
Display_Ref := False;
else
Display_Ref := Format_Object.Include_Annotations;
end if;
else --This reference is too new, ignore it.
Display_Ref := False;
end if;
Get_Boolean ("ChginAnnex" & (11..ARM_Input.Command_Name_Type'Last => ' '),
Chg_in_Annex);
-- Read a boolean parameter.
if Chg_in_Annex then
Format_Object.Attr_Change_Kind := Kind;
Format_Object.Attr_Version := Version;
else -- don't save the change info.; it only applies here.
Format_Object.Attr_Change_Kind := ARM_Database.None;
Format_Object.Attr_Version := '0';
Format_Object.Attr_Initial_Version := '0';
end if;
Get_Boolean ("Leading" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_Leading);
-- Read a boolean parameter.
if Is_Leading then
Format_Object.Space_After := ARM_Output.Narrow;
Format_Object.Attr_Leading := True;
else
Format_Object.Space_After := ARM_Output.Normal;
Format_Object.Attr_Leading := False;
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Prefix" & (7..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save prefix:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Attr_Prefix,
Format_Object.Attr_Prefix_Len);
-- else no parameter. Weird.
end if;
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "AttrName" & (9..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Save name:
ARM_Input.Copy_to_String_until_Close_Char (
Input_Object,
Close_Ch,
Format_Object.Attr_Name,
Format_Object.Attr_Name_Len);
-- else no parameter. Weird.
end if;
-- Handle the Ref, ARef, and InitialVersion parameters,
-- until the Text parameter shows up.
-- Note: If there is no InitialVersion command, use the
-- value of Version.
InitialVersion := Version;
declare
Which_Param : ARM_Input.Param_Num;
Ch : Character;
begin
loop
ARM_Input.Check_One_of_Parameter_Names (Input_Object,
Param_Name_1 => "Ref" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_2 => "ARef" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_3 => "InitialVersion" & (15..ARM_Input.Command_Name_Type'Last => ' '),
Param_Name_4 => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Found => Which_Param,
Param_Close_Bracket => Close_Ch);
if (Which_Param = 1 or else Which_Param = 2) and then
Close_Ch /= ' ' then
declare
Ref_Name : ARM_Input.Command_Name_Type;
Len : Natural := 0;
New_Ref, Cursor : Reference_Ptr;
Ch : Character;
begin
-- Get the reference:
loop
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Len := Len + 1;
if Len > Ref_Name'Last then
Ada.Text_IO.Put_Line (" ** Reference too long on line " & ARM_Input.Line_String (Input_Object));
else
Ref_Name(Len) := Ch;
end if;
else -- End of the reference.
if Len = 0 then
Ada.Text_IO.Put_Line (" ** Failed to find reference on line " & ARM_Input.Line_String (Input_Object));
end if;
exit;
end if;
end loop;
if Display_Ref then
-- Save a reference for outputting
-- later.
New_Ref := Allocate_Reference;
New_Ref.all := (Ref_Name => Ref_Name,
Ref_Len => Len,
Is_DR_Ref => (Which_Param = 1),
-- DR reference if Param = 1;
-- AI reference otherwise.
Next => null);
-- Attach this to the *end* of the list.
if References = null then
References := New_Ref;
else
Cursor := References;
while Cursor.Next /= null loop
Cursor := Cursor.next;
end loop;
Cursor.Next := New_Ref;
end if;
-- else don't display it.
end if;
end;
elsif Which_Param = 3 and then Close_Ch /= ' ' then
-- Found InitialVersion
ARM_Input.Get_Char (Input_Object, Ch);
InitialVersion := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Close_Ch then
Ada.Text_IO.Put_Line (" ** Bad close for InitialVersion parameter on line " &
ARM_Input.Line_String (Input_Object));
ARM_Input.Replace_Char (Input_Object);
end if;
else
exit; -- We found "Text" (or an error)
end if;
end loop;
end;
--**Debug:
--Ada.Text_IO.Put_Line ("ChgAttr on line " & ARM_Input.Line_String (Input_Object) &
-- "; Vers=" & Version & "; InitVer=" & InitialVersion & "; Kind=" & ARM_Database.Paragraph_Change_Kind_Type'Image(Format_Object.Attr_Change_Kind));
if ARM_Database."/=" (Format_Object.Attr_Change_Kind, ARM_Database.None) then
Format_Object.Attr_Initial_Version := InitialVersion;
-- else ChginAnnex is False, don't care about this.
end if;
-- How the prefix (attribute name) is handled depends
-- only on the InitialVersion and its relationship
-- to the version we're generating. It does *not*
-- depend on the (current) change kind.
if InitialVersion = '0' then
-- Original version, never an insertion.
Make_Attribute_Text;
if Close_Ch /= ' ' then
-- Now, handle the parameter:
-- The text goes to the file *and* is recorded.
Arm_Input.Start_Recording (Input_Object);
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Attribute_Text_Param,
Close_Ch => Close_Ch);
end if;
elsif Close_Ch /= ' ' then -- All other cases.
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Attribute_Text_Param,
Close_Ch => Close_Ch);
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => InitialVersion,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object, Close_Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
--Ada.Text_IO.Put_Line("--Skip text");
elsif Disposition = ARM_Output.None then
-- Display the text normally.
Make_Attribute_Text;
-- Nothing special to do (normal text).
--Ada.Text_IO.Put_Line("--Normal text");
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
--Ada.Text_IO.Put_Line("--Insertion");
-- We assume non-empty text and no outer changes;
-- set new change state:
Format_Object.Text_Format.Change := ARM_Output.Insertion;
Format_Object.Text_Format.Version := InitialVersion;
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- Change the state *before* outputting the
-- paragraph header, so the AARM prefix is included.
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
Make_Attribute_Text;
-- Reset the state to normal:
Format_Object.Text_Format.Change := ARM_Output.None;
Format_Object.Text_Format.Version := '0';
Format_Object.Text_Format.Added_Version := '0';
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
end if;
end;
-- The text goes to the file *and* is recorded.
Arm_Input.Start_Recording (Input_Object);
-- else no parameter. Do nothing.
end if;
end;
when Change_Prefix_Type =>
-- This command is of the form:
-- @chgprefixtype{Version=[<version>], Kind=(<kind>),
-- Text=(<text>)}}
-- where <version> is a single character, <Kind> is one
-- of Revised, Added, or Deleted, and this is followed
-- by the text. As usual, any of the
-- allowed bracketing characters can be used.
declare
Close_Ch : Character;
begin
Get_Change_Version (Is_First => True,
Version => Format_Object.Attr_Prefix_Version);
-- Read a parameter named "Version".
Get_Change_Kind (Format_Object.Attr_Prefix_Change_Kind);
-- Read a parameter named "Kind".
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Close_Ch);
if Close_Ch /= ' ' then
-- Stack it so we can process the end:
Set_Nesting_for_Parameter
(Command => Change_Prefix_Text_Param,
Close_Ch => Close_Ch);
ARM_Input.Start_Recording (Input_Object);
-- else no parameter. Weird.
end if;
end;
when Added_Implementation_Advice_List =>
-- This command is of the form:
-- @AddedImplAdvice{Version=[v]}
declare
Version : ARM_Contents.Change_Version_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
DB_Report (Format_Object.ImplAdv_DB,
ARM_Database.Bullet_List,
Sorted => True,
Added_Version => Version);
end;
when Added_Documentation_Requirements_List =>
-- This command is of the form:
-- @AddedDocReq{Version=[v]}
declare
Version : ARM_Contents.Change_Version_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
DB_Report (Format_Object.Docreq_DB,
ARM_Database.Bullet_List,
Sorted => True,
Added_Version => Version);
end;
when Added_Aspect_Description_List =>
-- This command is of the form:
-- @AddedAspectList{Version=[v]}
declare
Version : ARM_Contents.Change_Version_Type;
begin
Get_Change_Version (Is_First => True,
Version => Version);
-- Read a parameter named "Version".
DB_Report (Format_Object.Aspect_DB,
ARM_Database.Hanging_List,
Sorted => True,
Added_Version => Version);
end;
when Latin_1 =>
-- The parameter is the decimal code for the Latin-1
-- character to generate.
declare
Value : String (1..5);
Len : Natural := 0;
Ch : Character;
begin
ARM_Input.Get_Char (Input_Object, Ch);
while Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char loop
Len := Len + 1;
if Len > Value'Last then
Ada.Text_IO.Put_Line (" ** Latin-1 value too long on line " &
ARM_Input.Line_String (Input_Object));
exit;
end if;
Value(Len) := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Latin-1" record.
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object,
Character'Val(Natural'Value(Value(1..Len))));
Format_Object.Last_Non_Space := True;
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line (" ** Bad Latin-1 value [" &
Value(1..Len) & "] on line " &
ARM_Input.Line_String (Input_Object));
end;
when Unicode =>
-- The parameter is the decimal code for the Uncode
-- character to generate.
declare
Value : String (1..11);
Len : Natural := 0;
Ch : Character;
begin
ARM_Input.Get_Char (Input_Object, Ch);
while Ch /= Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Close_Char loop
Len := Len + 1;
if Len > Value'Last then
Ada.Text_IO.Put_Line (" ** Unicode value too long on line " &
ARM_Input.Line_String (Input_Object));
exit;
end if;
Value(Len) := Ch;
ARM_Input.Get_Char (Input_Object, Ch);
end loop;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Remove the "Unicode" record.
Check_Paragraph;
ARM_Output.Unicode_Character (Output_Object,
ARM_Output.Unicode_Type'Value(Value(1..Len)));
Format_Object.Last_Non_Space := True;
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line (" ** Bad Unicode value [" &
Value(1..Len) & "] on line " &
ARM_Input.Line_String (Input_Object));
end;
when Ceiling =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Ceiling);
Format_Object.Last_Non_Space := True;
when Floor =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Floor);
Format_Object.Last_Non_Space := True;
when Absolute =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '|');
Format_Object.Last_Non_Space := True;
when Log =>
Check_Paragraph;
ARM_Output.Ordinary_Text (Output_Object, "log(");
Format_Object.Last_Non_Space := True;
when Down | Up =>
Ada.Text_IO.Put_Line (" ** Su(b|per)script can't occur directly, line " &
ARM_Input.Line_String (Input_Object));
when New_Column | New_Page | RM_New_Page | Soft_Page |
No_Prefix | No_Para_Num | Keep_with_Next | Leading | Trailing |
Thin_Line | Thick_Line | Table_Last |
Index_List |
Syntax_Summary | Syntax_XRef | Glossary_List |
Attribute_List | Pragma_List | Implementation_Defined_List |
Package_List | Type_List | Subprogram_List |
Exception_List | Object_List |
Intro_Name | Syntax_Name | Resolution_Name |
Legality_Name | Static_Name | Link_Name | Run_Name |
Bounded_Name | Erroneous_Name | Req_Name |
Doc_Name | Metrics_Name | Permission_Name | Advice_Name |
Notes_Name | Single_Note_Name | Examples_Name |
Meta_Name | Inconsistent83_Name |
Incompatible83_Name | Extend83_Name | Wording83_Name |
Inconsistent95_Name |
Incompatible95_Name | Extend95_Name | Wording95_Name |
Inconsistent2005_Name |
Incompatible2005_Name | Extend2005_Name | Wording2005_Name |
Inconsistent2012_Name |
Incompatible2012_Name | Extend2012_Name | Wording2012_Name |
Syntax_Title | Resolution_Title | Legality_Title |
Static_Title | Link_Title | Run_Title | Bounded_Title |
Erroneous_Title | Req_Title | Doc_Title | Metrics_Title |
Permission_Title | Advice_Title | Notes_Title |
Single_Note_Title |
Examples_Title | Meta_Title | Inconsistent83_Title |
Incompatible83_Title | Extend83_Title | Wording83_Title |
Inconsistent95_Title |
Incompatible95_Title | Extend95_Title | Wording95_Title |
Inconsistent2005_Title |
Incompatible2005_Title | Extend2005_Title | Wording2005_Title |
Inconsistent2012_Title |
Incompatible2012_Title | Extend2012_Title | Wording2012_Title |
EM_Dash | EN_Dash | LT | LE | GT | GE | NE | PI |
Times | PorM | Single_Quote | Thin_Space | Left_Quote |
Right_Quote | Left_Double_Quote | Right_Double_Quote |
Left_Quote_Pair | Right_Quote_Pair | Small_Dotless_I |
Capital_Dotted_I =>
-- These commands must not have a parameter.
Ada.Text_IO.Put_Line (" ** Parameter for " &
Ada.Strings.Fixed.Trim (Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right) &
", line " & ARM_Input.Line_String (Input_Object));
when Unknown =>
Ada.Text_IO.Put_Line (" ?? Unknown command (skipped) - " &
Ada.Strings.Fixed.Trim (Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end case;
end Process_Command_with_Parameter;
procedure Process_Command_without_Parameter (Name : in ARM_Input.Command_Name_Type) is
-- Process the start of a command without a parameter. The name
-- of the command is Name.
procedure Put_Name (Kind : Paragraph_Type) is
begin
Check_Paragraph;
ARM_Output.Ordinary_Text (Output_Object,
Data.Paragraph_Kind_Name(Kind).Str(1..Data.Paragraph_Kind_Name(Kind).Length));
Format_Object.Last_Non_Space := True;
end Put_Name;
procedure Put_Title (Kind : Paragraph_Type) is
begin
Check_Paragraph;
ARM_Output.Ordinary_Text (Output_Object,
Paragraph_Kind_Title(Kind).Str(1..Paragraph_Kind_Title(Kind).Length));
Format_Object.Last_Non_Space := True;
end Put_Title;
procedure Format_Text (Text : in String;
Text_Name : in String) is
-- Note: We use the state of the surrounding call.
Input_Object : Arm_String.String_Input_Type;
Real_Include_Annotations : Boolean := Format_Object.Include_Annotations;
begin
-- Don't show annotations here:
Format_Object.Include_Annotations := False;
Arm_String.Open (Input_Object, Text, Text_Name);
-- Open the input object using a string for input.
Real_Process (Format_Object, Format_State, Input_Object, Output_Object);
Arm_String.Close (Input_Object);
Format_Object.Include_Annotations := Real_Include_Annotations;
end Format_Text;
procedure DB_Report is new ARM_Database.Report (Format_Text);
procedure Syn_Report is new ARM_Syntax.Report (Format_Text);
procedure Syn_XRef is new ARM_Syntax.XRef (Format_Text);
begin
case Command (Name) is
when Comment =>
null; -- Harmless, but still junk.
when No_Prefix =>
Format_Object.No_Prefix := True;
when No_Para_Num =>
Format_Object.No_Para_Num := True;
when Keep_with_Next =>
Format_Object.Keep_with_Next := True;
when Leading =>
Format_Object.Space_After := ARM_Output.Narrow;
when Trailing =>
Format_Object.Space_After := ARM_Output.Wide;
when New_Page =>
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
when RM_New_Page =>
if not Format_Object.Include_Annotations then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
-- else do nothing.
end if;
when Soft_Page =>
Check_Paragraph;
ARM_Output.New_Page (Output_Object, ARM_Output.Soft_Page);
when New_Column =>
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Column (Output_Object);
when Thin_Line =>
Check_End_Paragraph;
ARM_Output.Separator_Line (Output_Object, Is_Thin => True);
when Thick_Line =>
Check_End_Paragraph;
ARM_Output.Separator_Line (Output_Object, Is_Thin => False);
when Table_Last =>
if Format_Object.Next_Paragraph_Format_Type = In_Table then
-- If in a table, ends the second last row.
ARM_Output.Table_Marker (Output_Object, ARM_Output.End_Row_Next_is_Last);
-- Eat the following LF, if any, to avoid confusing
-- row ends:
declare
Ch : Character;
begin
ARM_Input.Get_Char (Input_Object, Ch);
if Ch /= Ascii.LF then
ARM_Input.Replace_Char (Input_Object);
end if;
end;
else
Ada.Text_IO.Put_Line (" ** @Last command not in table, line " & ARM_Input.Line_String (Input_Object));
end if;
when Index_List =>
-- Generate the index body.
Check_End_Paragraph;
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 3);
ARM_Index.Generate_Index_Body (Output_Object,
Use_Paragraphs => Format_Object.Number_Paragraphs);
ARM_Output.Set_Columns (Output_Object, Number_of_Columns => 1);
when Syntax_Summary =>
--Ada.Text_IO.Put_Line ("%% Generate Syntax summary");
Syn_Report;
when Syntax_XRef =>
--Ada.Text_IO.Put_Line ("%% Generate Syntax xref");
Syn_XRef;
when Glossary_List =>
DB_Report (Format_Object.Glossary_DB,
ARM_Database.Normal_Indexed_List,
Sorted => True);
when Attribute_List =>
DB_Report (Format_Object.Attr_DB,
ARM_Database.Hanging_List,
Sorted => True,
No_Deleted_Paragraph_Messages => True);
when Pragma_List =>
DB_Report (Format_Object.Pragma_DB,
ARM_Database.Normal_List,
Sorted => True);
when Implementation_Defined_List =>
DB_Report (Format_Object.Impdef_DB,
ARM_Database.Bullet_List,
Sorted => True);
when Package_List =>
Write_Subindex (Format_Object.Package_Index,
Format_Object,
Output_Object,
Minimize_Lines => False);
when Type_List =>
Write_Subindex (Format_Object.Type_Index,
Format_Object,
Output_Object,
Minimize_Lines => False);
when Subprogram_List =>
Write_Subindex (Format_Object.Subprogram_Index,
Format_Object,
Output_Object,
Minimize_Lines => True);
when Exception_List =>
Write_Subindex (Format_Object.Exception_Index,
Format_Object,
Output_Object,
Minimize_Lines => False);
when Object_List =>
Write_Subindex (Format_Object.Object_Index,
Format_Object,
Output_Object,
Minimize_Lines => True);
when Text_Begin | Text_End | Redundant | Part | Bold | Italic |
Roman | Swiss | Fixed | Roman_Italic | Shrink | Grow |
Black | Red | Green | Blue |
Keyword | Non_Terminal | Non_Terminal_Format |
Example_Text | Example_Comment |
Up | Down | Tab_Clear | Tab_Set |
New_Page_for_Version | RM_New_Page_for_Version |
Not_ISO_RM_New_Page_for_Version |
ISO_Only_RM_New_Page_for_Version |
New_Column_for_Version |
Table | Picture_Alone | Picture_Inline |
Defn | RootDefn | PDefn | Defn2 | RootDefn2 | PDefn2 |
Index_See | Index_See_Also | See_Other | See_Also |
Index_Root_Unit | Index_Child_Unit | Index_Subprogram_Child_Unit |
Index_Type | Index_Subtype |
Index_Subprogram | Index_Exception | Index_Object |
Index_Package | Index_Other | Index_Check |
Index_Attr | Index_Pragma | Index_Aspect |
Syntax_Rule | Syntax_Term | Syntax_Term_Undefined | Syntax_Prefix |
Added_Syntax_Rule | Deleted_Syntax_Rule |
To_Glossary | To_Glossary_Also |
Change_To_Glossary | Change_To_Glossary_Also |
Implementation_Defined |
Prefix_Type | Reset_Prefix_Type | Attribute | Attribute_Leading |
Pragma_Syntax | Added_Pragma_Syntax | Deleted_Pragma_Syntax |
Labeled_Section | Labeled_Section_No_Break |
Labeled_Clause | Labeled_Subclause | Labeled_Subsubclause |
Labeled_Revised_Section | Labeled_Revised_Clause |
Labeled_Revised_Subclause | Labeled_Revised_Subsubclause |
Labeled_Added_Section | Labeled_Added_Clause |
Labeled_Added_Subclause | Labeled_Added_Subsubclause |
Labeled_Deleted_Clause |
Labeled_Deleted_Subclause | Labeled_Deleted_Subsubclause |
Labeled_Annex | Labeled_Revised_Annex | Labeled_Added_Annex |
Labeled_Informative_Annex | Labeled_Revised_Informative_Annex |
Labeled_Added_Informative_Annex |
Labeled_Normative_Annex | Labeled_Revised_Normative_Annex |
Labeled_Added_Normative_Annex |
Unnumbered_Section | Subheading | Added_Subheading | Heading |
Center | Right |
Preface_Section | Ref_Section | Ref_Section_Number | Ref_Section_by_Number |
Local_Target | Local_Link | URL_Link | AI_Link |
Change | Change_Reference | Change_Note |
Change_Added | Change_Deleted |
Change_Implementation_Defined |
Change_Implementation_Advice |
Change_Documentation_Requirement |
Change_Aspect_Description |
Added_Implementation_Advice_List |
Added_Documentation_Requirements_List |
Added_Aspect_Description_List |
Change_Attribute |
Change_Prefix_Type |
Latin_1 | Unicode | Ceiling | Floor | Absolute | Log =>
-- These commands must have a parameter.
Ada.Text_IO.Put_Line (" ** Failed to find parameter for " &
Ada.Strings.Fixed.Trim (Name, Ada.Strings.Right) &
", line " & ARM_Input.Line_String (Input_Object));
when Change_Param_Old | Change_Param_New | Change_Added_Param | Change_Deleted_Param =>
-- These can't get here; they represent the parameters of
-- "Change" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Change parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Table_Param_Caption | Table_Param_Header | Table_Param_Body =>
-- These can't get here; they represent the parameters of
-- "Table" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Table parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Syntax_Rule_RHS =>
-- This can't get here; it represents the second parameter of
-- "Syn" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Syntax parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Glossary_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ToGlossary" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Glossary parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Attribute_Text_Param =>
-- This can't get here; it represents a parameter of
-- "Attribute" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Attribute parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Impdef_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ChgImpldef" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Impdef parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Impladv_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ChgImpladv" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** Impladv parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Docreq_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ChgDocreq" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** DocReq parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_AspectDesc_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ChgAspectDesc" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** AspectDesc parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Change_Prefix_Text_Param =>
-- This can't get here; it represents a parameter of
-- "ChgPrefixType" and can't be generated explicitly.
Ada.Text_IO.Put_Line (" ** ChgPrefix parameter command?? on line " & ARM_Input.Line_String (Input_Object));
when Intro_Name =>
Put_Name(Introduction);
when Syntax_Name =>
Put_Name(Syntax);
when Resolution_Name =>
Put_Name(Resolution);
when Legality_Name =>
Put_Name(Legality);
when Static_Name =>
Put_Name(Static_Semantics);
when Link_Name =>
Put_Name(Link_Time);
when Run_Name =>
Put_Name(Run_Time);
when Bounded_Name =>
Put_Name(Bounded_Errors);
when Erroneous_Name =>
Put_Name(Erroneous);
when Req_Name =>
Put_Name(Requirements);
when Doc_Name =>
Put_Name(Documentation);
when Metrics_Name =>
Put_Name(Metrics);
when Permission_Name =>
Put_Name(Permissions);
when Advice_Name =>
Put_Name(Advice);
when Notes_Name =>
Put_Name(Notes);
when Single_Note_Name =>
Put_Name(Single_Note);
when Examples_Name =>
Put_Name(Examples);
when Meta_Name =>
Put_Name(Language_Design);
when Inconsistent83_Name =>
Put_Name(Ada83_Inconsistencies);
when Incompatible83_Name =>
Put_Name(Ada83_Incompatibilities);
when Extend83_Name =>
Put_Name(Ada83_Extensions);
when Wording83_Name =>
Put_Name(Ada83_Wording);
when Inconsistent95_Name =>
Put_Name(Ada95_Inconsistencies);
when Incompatible95_Name =>
Put_Name(Ada95_Incompatibilities);
when Extend95_Name =>
Put_Name(Ada95_Extensions);
when Wording95_Name =>
Put_Name(Ada95_Wording);
when Inconsistent2005_Name =>
Put_Name(Ada2005_Inconsistencies);
when Incompatible2005_Name =>
Put_Name(Ada2005_Incompatibilities);
when Extend2005_Name =>
Put_Name(Ada2005_Extensions);
when Wording2005_Name =>
Put_Name(Ada2005_Wording);
when Inconsistent2012_Name =>
Put_Name(Ada2012_Inconsistencies);
when Incompatible2012_Name =>
Put_Name(Ada2012_Incompatibilities);
when Extend2012_Name =>
Put_Name(Ada2012_Extensions);
when Wording2012_Name =>
Put_Name(Ada2012_Wording);
when Syntax_Title =>
Put_Title(Syntax);
when Resolution_Title =>
Put_Title(Resolution);
when Legality_Title =>
Put_Title(Legality);
when Static_Title =>
Put_Title(Static_Semantics);
when Link_Title =>
Put_Title(Link_Time);
when Run_Title =>
Put_Title(Run_Time);
when Bounded_Title =>
Put_Title(Bounded_Errors);
when Erroneous_Title =>
Put_Title(Erroneous);
when Req_Title =>
Put_Title(Requirements);
when Doc_Title =>
Put_Title(Documentation);
when Metrics_Title =>
Put_Title(Metrics);
when Permission_Title =>
Put_Title(Permissions);
when Advice_Title =>
Put_Title(Advice);
when Notes_Title =>
Put_Title(Notes);
when Single_Note_Title =>
Put_Title(Single_Note);
when Examples_Title =>
Put_Title(Examples);
when Meta_Title =>
Put_Title(Language_Design);
when Inconsistent83_Title =>
Put_Title(Ada83_Inconsistencies);
when Incompatible83_Title =>
Put_Title(Ada83_Incompatibilities);
when Extend83_Title =>
Put_Title(Ada83_Extensions);
when Wording83_Title =>
Put_Title(Ada83_Wording);
when Inconsistent95_Title =>
Put_Title(Ada95_Inconsistencies);
when Incompatible95_Title =>
Put_Title(Ada95_Incompatibilities);
when Extend95_Title =>
Put_Title(Ada95_Extensions);
when Wording95_Title =>
Put_Title(Ada95_Wording);
when Inconsistent2005_Title =>
Put_Title(Ada2005_Inconsistencies);
when Incompatible2005_Title =>
Put_Title(Ada2005_Incompatibilities);
when Extend2005_Title =>
Put_Title(Ada2005_Extensions);
when Wording2005_Title =>
Put_Title(Ada2005_Wording);
when Inconsistent2012_Title =>
Put_Title(Ada2012_Inconsistencies);
when Incompatible2012_Title =>
Put_Title(Ada2012_Incompatibilities);
when Extend2012_Title =>
Put_Title(Ada2012_Extensions);
when Wording2012_Title =>
Put_Title(Ada2012_Wording);
when EM_Dash =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.EM_Dash);
Format_Object.Last_Non_Space := True;
when EN_Dash =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.EN_Dash);
Format_Object.Last_Non_Space := True;
when LE =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.LEQ);
Format_Object.Last_Non_Space := True;
when LT =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '<');
Format_Object.Last_Non_Space := True;
when GE =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.GEQ);
Format_Object.Last_Non_Space := True;
when GT =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '>');
Format_Object.Last_Non_Space := True;
when NE =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.NEQ);
Format_Object.Last_Non_Space := True;
when PI =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.PI);
Format_Object.Last_Non_Space := True;
when Times =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, Character'Val(183)); -- Middle Dot.
Format_Object.Last_Non_Space := True;
when PorM =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, Character'Val(177)); -- Plus or Minus character.
Format_Object.Last_Non_Space := True;
when Single_Quote =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '''); -- Single quote.
Format_Object.Last_Non_Space := True;
when Thin_Space =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Thin_Space);
Format_Object.Last_Non_Space := True;
when Small_Dotless_I =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Small_Dotless_I);
Format_Object.Last_Non_Space := True;
when Capital_Dotted_I =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Capital_Dotted_I);
Format_Object.Last_Non_Space := True;
when Left_Quote =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Quote);
Format_Object.Last_Non_Space := True;
when Right_Quote =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote);
Format_Object.Last_Non_Space := True;
when Left_Double_Quote =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Double_Quote);
Format_Object.Last_Non_Space := True;
when Right_Double_Quote =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Double_Quote);
Format_Object.Last_Non_Space := True;
when Left_Quote_Pair =>
Check_Paragraph;
-- Was: To match the Ada 95 standard:
--ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Quote);
--ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Quote);
ARM_Output.Special_Character (Output_Object, ARM_Output.Left_Double_Quote);
Format_Object.Last_Non_Space := True;
when Right_Quote_Pair =>
Check_Paragraph;
-- Was: To match the Ada 95 standard:
--ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote);
--ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Quote);
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Double_Quote);
Format_Object.Last_Non_Space := True;
when Unknown =>
Ada.Text_IO.Put_Line (" ?? Unknown command (skipped) - " &
Ada.Strings.Fixed.Trim (Name, Ada.Strings.Right) &
" on line " & ARM_Input.Line_String (Input_Object));
end case;
end Process_Command_without_Parameter;
procedure Handle_End_of_Command is
-- Unstack and handle the end of Commands.
procedure Finish_and_DB_Entry (DB : in out ARM_Database.Database_Type) is
-- Close the text parameter for a number of commands
-- (impdef, chgimpdef, chgimpladv, chgdocreg)
-- and insert the resulting string into the appropriate DB.
Text_Buffer : String (1..ARM_Input.MAX_RECORDING_SIZE);
Text_Buffer_Len : Natural;
function DB_Clause_String return String is
use type ARM_Contents.Section_Number_Type;
begin
if Format_Object.Clause_Number.Clause = 0 then
if Format_Object.Clause_Number.Section in 0 .. 9 then
return
Character'Val(Character'Pos('0') +
Format_Object.Clause_Number.Section) & "";
elsif Format_Object.Clause_Number.Section in 10 .. 19 then
return "1" &
Character'Val(Character'Pos('0') +
Format_Object.Clause_Number.Section - 10);
elsif Format_Object.Clause_Number.Section in 20 .. 29 then
return "2" &
Character'Val(Character'Pos('0') +
Format_Object.Clause_Number.Section - 20);
elsif Format_Object.Clause_Number.Section = 30 then
return "30";
else --if Format_Object.Clause_Number.Section >= ARM_Contents.ANNEX_START then
return Character'Val (Character'Pos('A') +
(Format_Object.Clause_Number.Section -
ARM_Contents.ANNEX_START)) & "";
end if;
elsif Format_Object.Clause_Number.Subclause = 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.Clause,
Format_Object.Clause_Number);
elsif Format_Object.Clause_Number.Subsubclause = 0 then
return ARM_Contents.Make_Clause_Number (
ARM_Contents.SubClause,
Format_Object.Clause_Number);
else
return ARM_Contents.Make_Clause_Number (
ARM_Contents.SubsubClause,
Format_Object.Clause_Number);
end if;
end DB_Clause_String;
function Sort_Clause_String return String is
Res : String(1..13);
-- Always use the paragraph for sorting:
begin
-- The funny encoding to insure proper sorting.
-- (Otherwise "10" sorts before "2".
Res(1) := Character'Val (Natural(Format_Object.Clause_Number.Section) + 16#30#);
Res(2) := '.';
Res(3) := Character'Val (Format_Object.Clause_Number.Clause + 16#30#);
Res(4) := '.';
Res(5) := Character'Val (Format_Object.Clause_Number.Subclause + 16#30#);
Res(6) := '.';
Res(7) := Character'Val (Format_Object.Clause_Number.Subsubclause + 16#30#);
Res(8) := '(';
Res(9) := Character'Val ((Format_Object.Next_Paragraph / 10) + 16#30#);
Res(10) := Character'Val ((Format_Object.Next_Paragraph mod 10) + 16#30#);
Res(11) := '.';
Res(12) := Character'Val ((Format_Object.Next_Insert_Para mod 10) + 16#30#);
Res(13) := ')';
return Res;
end Sort_Clause_String;
function See_String return String is
begin
case Format_Object.Impdef_Info.Change_Kind is
when ARM_Database.None | ARM_Database.Revised |
ARM_Database.Revised_Inserted_Number =>
if Format_Object.Number_Paragraphs and then
Format_Object.Impdef_Info.Command /= Aspect then
return " See @RefSecbyNum{" & DB_Clause_String & "}(" &
Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) &
").";
else -- No paragraph numbers.
return " See @RefSecbyNum{" & DB_Clause_String & "}.";
end if;
when ARM_Database.Inserted | ARM_Database.Inserted_Normal_Number =>
if Format_Object.Number_Paragraphs and then
Format_Object.Impdef_Info.Command /= Aspect then
return "@Chg{Version=[" & Format_Object.Impdef_Info.Version &
"], New=[ See @RefSecbyNum{" & DB_Clause_String & "}(" &
Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) &
").],Old=[]}";
else -- No paragraph numbers.
return "@Chg{Version=[" & Format_Object.Impdef_Info.Version &
"], New=[ See @RefSecbyNum{" & DB_Clause_String & "}.],Old=[]}";
end if;
when ARM_Database.Deleted |
ARM_Database.Deleted_Inserted_Number |
ARM_Database.Deleted_No_Delete_Message |
ARM_Database.Deleted_Inserted_Number_No_Delete_Message =>
if Format_Object.Number_Paragraphs and then
Format_Object.Impdef_Info.Command /= Aspect then
return "@Chg{Version=[" & Format_Object.Impdef_Info.Version &
"], New=[],Old=[ See @RefSecbyNum{" & DB_Clause_String & "}(" &
Format_Object.Impdef_Info.Paragraph_String (1..Format_Object.Impdef_Info.Paragraph_Len) &
").]}";
else -- No paragraph numbers.
return "@Chg{Version=[" & Format_Object.Impdef_Info.Version &
"], New=[],Old=[ See @RefSecbyNum{" & DB_Clause_String & "}.]}";
end if;
end case;
end See_String;
begin
Arm_Input.Stop_Recording_and_Read_Result
(Input_Object, Text_Buffer, Text_Buffer_Len);
Text_Buffer_Len := Text_Buffer_Len - 1; -- Remove command close character.
if not Format_Object.Impdef_Info.Add_to_DB then
null; -- Don't add to the DB
elsif Format_Object.Impdef_Info.Command = Aspect then
if Format_Object.Impdef_Info.Initial_Version >= '4' then
-- ** Horrible hack: We treat the aspect as inserted
-- if the initial version is greater than 4 (this is
-- what we need in the RM and AARM). This
-- should depend on other parameters, and ideally
-- be determined inside of the DB_Report code.
ARM_Database.Insert (DB,
Sort_Key => Format_Object.Impdef_Info.Aspect_Name(1..Format_Object.Impdef_Info.Aspect_Name_Len),
Hang_Item => "@Chg{Version=[" & Format_Object.Impdef_Info.Initial_Version &
"],New=[" & Format_Object.Impdef_Info.Aspect_Name(1..Format_Object.Impdef_Info.Aspect_Name_Len) &
"],Old=[]}",
Text => Text_Buffer(1..Text_Buffer_Len) &
See_String,
Change_Kind => Format_Object.Impdef_Info.Change_Kind,
Version => Format_Object.Impdef_Info.Version,
Initial_Version => Format_Object.Impdef_Info.Initial_Version);
else -- Normal
ARM_Database.Insert (DB,
Sort_Key => Format_Object.Impdef_Info.Aspect_Name(1..Format_Object.Impdef_Info.Aspect_Name_Len),
Hang_Item => Format_Object.Impdef_Info.Aspect_Name(1..Format_Object.Impdef_Info.Aspect_Name_Len),
Text => Text_Buffer(1..Text_Buffer_Len) &
See_String,
Change_Kind => Format_Object.Impdef_Info.Change_Kind,
Version => Format_Object.Impdef_Info.Version,
Initial_Version => Format_Object.Impdef_Info.Initial_Version);
end if;
else
ARM_Database.Insert (DB,
Sort_Key => Sort_Clause_String,
Hang_Item => "",
Text => Text_Buffer(1..Text_Buffer_Len) &
See_String,
Change_Kind => Format_Object.Impdef_Info.Change_Kind,
Version => Format_Object.Impdef_Info.Version,
Initial_Version => Format_Object.Impdef_Info.Initial_Version);
end if;
-- Finish the text processing:
if Format_Object.Impdef_Info.Add_to_DB and
Format_Object.Include_Annotations then
-- End the annotation:
Check_End_Paragraph;
if Format_Object.Next_Paragraph_Subhead_Type /=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph then
Format_Object.Last_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph;
-- else still in same subhead, leave alone. (If
-- we didn't do this, we'd output the subhead
-- multiple times).
end if;
Format_Object.Next_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph;
Format_Object.Next_Paragraph_Format_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format;
Format_Object.Paragraph_Tab_Stops :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops;
-- else nothing started, nothing to finish.
end if;
-- Clear the Impdef information:
Format_Object.Impdef_Info := (Command => None);
end Finish_and_DB_Entry;
begin
case Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command is
when Redundant =>
if Format_Object.Include_Annotations then
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, ']');
-- else ignored.
end if;
when Bold | Italic | Roman | Swiss | Fixed | Roman_Italic |
Shrink | Grow | Up | Down |
Black | Red | Green | Blue |
Keyword | Non_Terminal | Non_Terminal_Format |
Example_Text | Example_Comment =>
-- Formatting commands; revert to the previous (saved)
-- version:
Check_Paragraph;
Format_Object.Text_Format :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Text_Format;
ARM_Output.Text_Format (Output_Object,
Format => Format_Object.Text_Format);
when Subheading | Heading =>
-- Restore the format.
Check_Paragraph;
ARM_Output.Text_Format (Output_Object,
Format => ARM_Output.NORMAL_FORMAT);
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Check_End_Paragraph;
when Added_Subheading =>
-- Restore the format.
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- The new text was ignored.
null; -- Nothing to do (we nulled out the text before we got here).
elsif Disposition = ARM_Output.None then
-- Display the text normally.
Check_Paragraph;
ARM_Output.Text_Format (Output_Object,
Format => ARM_Output.NORMAL_FORMAT);
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Check_End_Paragraph;
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
Check_Paragraph;
ARM_Output.Text_Format (Output_Object,
Format => ARM_Output.NORMAL_FORMAT);
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Check_End_Paragraph;
end if;
end;
when Center | Right =>
-- Close the paragraph.
Check_End_Paragraph;
when New_Page_for_Version =>
-- The version parameter is stored in Change_Version on
-- the stack.
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version
= Format_Object.Change_Version then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
-- else do nothing.
end if;
when RM_New_Page_for_Version =>
-- The version parameter is stored in Change_Version on
-- the stack.
if not Format_Object.Include_Annotations and then
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version
= Format_Object.Change_Version then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
-- else do nothing.
end if;
when Not_ISO_RM_New_Page_for_Version =>
-- The version parameter is stored in Change_Version on
-- the stack.
if not Format_Object.Include_Annotations and then
not Format_Object.Include_ISO and then
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version
= Format_Object.Change_Version then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
-- else do nothing.
end if;
when ISO_Only_RM_New_Page_for_Version =>
-- The version parameter is stored in Change_Version on
-- the stack.
if not Format_Object.Include_Annotations and then
Format_Object.Include_ISO and then
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version
= Format_Object.Change_Version then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Page (Output_Object, ARM_Output.Any_Page);
-- else do nothing.
end if;
when New_Column_for_Version =>
-- The version parameter is stored in Change_Version on
-- the stack.
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version
= Format_Object.Change_Version then
Check_End_Paragraph; -- End any paragraph that we're in.
ARM_Output.New_Column (Output_Object);
-- else do nothing.
end if;
when Table_Param_Caption =>
ARM_Output.Table_Marker (Output_Object,
ARM_Output.End_Caption);
Format_Object.Last_Non_Space := False;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Unstack the "Caption" parameter.
--Ada.Text_IO.Put_Line (" &Unstack (Tab Cap)");
-- Check and handle the following "Headers" parameter:
declare
Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Headers" & (8..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Ch);
if Ch /= ' ' then -- There is a parameter.
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Table_Param_Header,
Close_Ch => Ch);
-- No processing needed here.
-- else no parameter. Weird.
end if;
return; -- We've already done the unstacking.
end;
when Table_Param_Header =>
ARM_Output.Table_Marker (Output_Object,
ARM_Output.End_Header);
Format_Object.Last_Non_Space := False;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Unstack the "Header" parameter.
--Ada.Text_IO.Put_Line (" &Unstack (Tab Head)");
-- Check and handle the following "Body" parameter:
declare
Ch : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Body" & (5..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Ch);
if Ch /= ' ' then -- There is a parameter.
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Table_Param_Body,
Close_Ch => Ch);
-- No processing needed here.
-- else no parameter. Weird.
end if;
return; -- We've already done the unstacking.
end;
when Table_Param_Body =>
-- Close the table:
ARM_Output.Table_Marker (Output_Object,
ARM_Output.End_Table);
Format_Object.Last_Non_Space := False;
-- Reset the paragraph format (and skip over the parameter records):
Format_Object.Last_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Old_Last_Subhead_Paragraph;
Format_Object.Next_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Old_Next_Subhead_Paragraph;
Format_Object.Next_Paragraph_Format_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Old_Next_Paragraph_Format;
Format_Object.Paragraph_Tab_Stops :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Old_Tab_Stops;
Format_Object.In_Paragraph := False; -- End fake paragraph.
Format_Object.No_Start_Paragraph := False;
when Syntax_Rule_RHS =>
-- Send the production to the syntax manager.
-- Other processing has already been handled.
declare
Text_Buffer : String (1..ARM_Input.MAX_RECORDING_SIZE);
Text_Buffer_Len : Natural;
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
-- Calculate Disposition:
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = Syntax_Rule then
Disposition := ARM_Output.None; -- Normal text.
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = Added_Syntax_Rule then
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
else -- Deleted_Syntax_Rule
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
end if;
if Disposition = Do_Not_Display_Text then
-- The text was ignored and skipped.
-- Set the Non-terminal to empty:
Format_Object.Syntax_NT_Len := 0;
Format_Object.Syntax_Tab_Len := 0;
else
Arm_Input.Stop_Recording_and_Read_Result
(Input_Object, Text_Buffer, Text_Buffer_Len);
Text_Buffer_Len := Text_Buffer_Len - 1; -- Remove command close character.
if Disposition = ARM_Output.None then
-- Display the text normally.
ARM_Syntax.Insert_Rule (For_Clause => Clause_String (Format_Object),
Rule => "@ntf{" & Format_Object.Syntax_NT(1..Format_Object.Syntax_NT_Len) &
" ::=} " & Text_Buffer(1..Text_Buffer_Len),
Tabset => Format_Object.Syntax_Tab(1..Format_Object.Syntax_Tab_Len));
elsif Disposition = ARM_Output.Deletion then
ARM_Syntax.Insert_Rule (For_Clause => Clause_String (Format_Object),
Rule => "@ntf{" & Format_Object.Syntax_NT(1..Format_Object.Syntax_NT_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version &
"],New=[],Old=[ ::=]}} " & Text_Buffer(1..Text_Buffer_Len),
Tabset => Format_Object.Syntax_Tab(1..Format_Object.Syntax_Tab_Len));
else -- Insertion.
ARM_Syntax.Insert_Rule (For_Clause => Clause_String (Format_Object),
Rule => "@ntf{" & Format_Object.Syntax_NT(1..Format_Object.Syntax_NT_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version &
"],New=[ ::=],Old=[]}} " & Text_Buffer(1..Text_Buffer_Len),
Tabset => Format_Object.Syntax_Tab(1..Format_Object.Syntax_Tab_Len));
end if;
-- Note: The LHS non-terminals aren't linked as usual.
Check_End_Paragraph; -- End the paragraph, so the
-- next rule gets its own.
-- Reset the paragraph format:
Format_Object.Last_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph;
Format_Object.Next_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph;
Format_Object.Next_Paragraph_Format_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format;
Format_Object.Paragraph_Tab_Stops :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops;
-- Set the Non-terminal to empty:
Format_Object.Syntax_NT_Len := 0;
Format_Object.Syntax_Tab_Len := 0;
end if;
end;
when Syntax_Prefix =>
-- Reset the style:
Check_Paragraph;
Format_Object.Text_Format.Italic := False;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
when Glossary_Text_Param =>
-- Save the glossary entry in the Glossary database.
if not Format_Object.Glossary_Info.Active then
Ada.Text_IO.Put_Line (" ** Not in glossary command at end of glossary command!? on line " & ARM_Input.Line_String (Input_Object));
-- else OK.
end if;
declare
use type ARM_Database.Paragraph_Change_Kind_Type;
Text_Buffer : String (1..ARM_Input.MAX_RECORDING_SIZE);
Text_Buffer_Len : Natural;
begin
Arm_Input.Stop_Recording_and_Read_Result
(Input_Object, Text_Buffer, Text_Buffer_Len);
Text_Buffer_Len := Text_Buffer_Len - 1; -- Remove command close character.
if Format_Object.Glossary_Info.Add_to_Glossary then
if Format_Object.Glossary_Info.Change_Kind = ARM_Database.Inserted then
ARM_Database.Insert (Format_Object.Glossary_DB,
Sort_Key => Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len),
Hang_Item => "",
Text => "@chg{Version=[" & Format_Object.Glossary_Info.Version & "],New=[@b{" &
Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len) &
".}],Old=[]} " & Text_Buffer(1..Text_Buffer_Len),
Change_Kind => Format_Object.Glossary_Info.Change_Kind,
Version => Format_Object.Glossary_Info.Version,
Initial_Version => Format_Object.Glossary_Info.Version);
elsif Format_Object.Glossary_Info.Change_Kind = ARM_Database.Deleted then
ARM_Database.Insert (Format_Object.Glossary_DB,
Sort_Key => Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len),
Hang_Item => "",
Text => "@chg{Version=[" & Format_Object.Glossary_Info.Version & "],New=[],Old=[@b{" &
Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len) &
".}]} " & Text_Buffer(1..Text_Buffer_Len),
Change_Kind => Format_Object.Glossary_Info.Change_Kind,
Version => Format_Object.Glossary_Info.Version);
elsif Format_Object.Glossary_Info.Change_Kind = ARM_Database.None then
ARM_Database.Insert (Format_Object.Glossary_DB,
Sort_Key => Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len),
Hang_Item => "",
Text => "@b{" & Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len) &
".} " & Text_Buffer(1..Text_Buffer_Len),
Change_Kind => ARM_Database.None);
else
ARM_Database.Insert (Format_Object.Glossary_DB,
Sort_Key => Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len),
Hang_Item => "",
Text => "@b{" & Format_Object.Glossary_Info.Term(1..Format_Object.Glossary_Info.Term_Len) &
".} " & Text_Buffer(1..Text_Buffer_Len),
Change_Kind => Format_Object.Glossary_Info.Change_Kind,
Version => Format_Object.Glossary_Info.Version);
end if;
end if;
end;
-- Finish the text processing:
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = To_Glossary_Also or else
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Command = Change_To_Glossary_Also then
null; -- Normal text, no special handling needed.
else
if Format_Object.Glossary_Info.Displayed then
-- End the annotation.
Check_End_Paragraph;
Format_Object.Last_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Last_Subhead_Paragraph;
Format_Object.Next_Paragraph_Subhead_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Subhead_Paragraph;
Format_Object.Next_Paragraph_Format_Type :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Next_Paragraph_Format;
Format_Object.Paragraph_Tab_Stops :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Old_Tab_Stops;
else
null; -- No text, no special handling needed.
end if;
end if;
-- Remove glossary information as the command is finished:
Format_Object.Glossary_Info :=
(Active => False,
Change_Kind => ARM_Database.None);
when Attribute_Text_Param =>
declare
Text_Buffer : String (1..ARM_Input.MAX_RECORDING_SIZE);
Text_Buffer_Len : Natural;
function Sort_Key return String is
-- Generate a Sort Key so that these sort
-- as they did in Ada 95.
begin
if Format_Object.Attr_Prefix_Len > 2 and then
Format_Object.Attr_Prefix(2) = ''' then
-- Class-wide prefix. For some reason, this
-- sorts before the main item in the Ada 95 RM.
-- (And this continues in later RMs.)
return Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len) &
''' & Character'Pred(Format_Object.Attr_Prefix(1)) &
"'Class";
-- Sort by name, then by prefix.
else
return Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len) &
''' & Format_Object.Attr_Prefix(1..Format_Object.Attr_Prefix_Len);
-- Sort by name, then by prefix.
end if;
-- Note: Ada 2005 sorted E'Identity and T'Identity
-- backwards from Ada 95. This will fix that.
end Sort_Key;
function ChgRef_Command (Kind : in ARM_Database.Paragraph_Change_Kind_Type;
Version : in Character;
Initial_Version : in Character) return String is
-- Careful: This assumes this is being used for
-- the attribute index, which has always existed.
-- Use the annex initial version rather than '0'
-- to determine whether it is inserted or not for
-- other listings.
begin
case Kind is
when ARM_Database.None =>
return "";
when ARM_Database.Inserted | ARM_Database.Inserted_Normal_Number =>
if Initial_Version > '0' then -- Not original.
return "@Chgref{Version=[" & Version &
"],Kind=[Added]}";
else
return "@Chgref{Version=[" & Version &
"],Kind=[AddedNormal]}";
end if;
when ARM_Database.Deleted |
ARM_Database.Deleted_Inserted_Number |
ARM_Database.Deleted_No_Delete_Message |
ARM_Database.Deleted_Inserted_Number_No_Delete_Message =>
if Initial_Version > '0' then -- Not original.
return "@Chgref{Version=[" & Version &
"],Kind=[DeletedAdded]}";
else
return "@Chgref{Version=[" & Version &
"],Kind=[Deleted]}";
end if;
when ARM_Database.Revised | ARM_Database.Revised_Inserted_Number =>
if Initial_Version > '0' then -- Not original.
return "@Chgref{Version=[" & Version &
"],Kind=[RevisedAdded]}";
else
return "@Chgref{Version=[" & Version &
"],Kind=[Revised]}";
end if;
end case;
end ChgRef_Command;
procedure Write_to_DB (Prefix_Kind, Text_Kind :
in ARM_Database.Paragraph_Change_Kind_Type;
Prefix_Version, Text_Version,
Initial_Version : in Character) is
-- Write the item to the DB; use Prefix_Kind and
-- Text_Kind for the change kind.
begin
if Format_Object.Attr_Leading then
ARM_Database.Insert (Format_Object.Attr_DB,
Sort_Key => Sort_Key,
Hang_Item =>
Format_Object.Attr_Prefix(1..Format_Object.Attr_Prefix_Len) &
''' & Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len),
Text => "For " & Format_Object.Prefix_Text(1..Format_Object.Prefix_Text_Len) &
":" & Ascii.LF & Ascii.LF &
ChgRef_Command (Text_Kind, Text_Version, Initial_Version) &
"@leading@noprefix@;" & Text_Buffer(1..Text_Buffer_Len) &
" See @RefSecbyNum{" & Clause_String(Format_Object) & "}.",
Change_Kind => Prefix_Kind,
Version => Prefix_Version,
Initial_Version => Initial_Version);
else -- not leading:
ARM_Database.Insert (Format_Object.Attr_DB,
Sort_Key => Sort_Key,
Hang_Item =>
Format_Object.Attr_Prefix(1..Format_Object.Attr_Prefix_Len) &
''' & Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len),
Text => "For " & Format_Object.Prefix_Text(1..Format_Object.Prefix_Text_Len) &
":" & Ascii.LF & Ascii.LF &
ChgRef_Command (Text_Kind, Text_Version, Initial_Version) &
"@noprefix@;" & Text_Buffer(1..Text_Buffer_Len) &
" See @RefSecbyNum{" & Clause_String(Format_Object) & "}.",
Change_Kind => Prefix_Kind,
Version => Prefix_Version,
Initial_Version => Initial_Version);
end if;
end Write_to_DB;
use type ARM_Database.Paragraph_Change_Kind_Type;
begin
Arm_Input.Stop_Recording_and_Read_Result
(Input_Object, Text_Buffer, Text_Buffer_Len);
Text_Buffer_Len := Text_Buffer_Len - 1; -- Remove command close character.
--Ada.Text_IO.Put_Line ("&& Attr: " & Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len) &
-- "; Prefix kind=" & ARM_Database.Paragraph_Change_Kind_Type'Image(Format_Object.Attr_Prefix_Change_Kind) &
-- "; Attr chg kind=" & ARM_Database.Paragraph_Change_Kind_Type'Image(Format_Object.Attr_Change_Kind) &
-- "; Attr Prefix Vers=" & Format_Object.Attr_Prefix_Version & "; Attr Text Vers=" & Format_Object.Attr_Version &
-- "; Attr Init Vers=" & Format_Object.Attr_Initial_Version);
-- How the prefix text is handled depends only on
-- the Initial_Version and what version we're generating.
-- The Kind and Version of the prefix or item is
-- irrelevant (it's needed mainly for the paragraph
-- revision number). We assume that all attributes
-- are inserted for their Initial_Version (since it's
-- unlikely that we'd delete an attribute).
if Format_Object.Attr_Initial_Version = '0' then
-- Initial version, not inserted.
--Ada.Text_IO.Put_Line (" Attr: Normal initial version");
-- Normal reference:
Write_to_DB (Prefix_Kind => Format_Object.Attr_Prefix_Change_Kind,
Text_Kind => Format_Object.Attr_Change_Kind,
Prefix_Version => Format_Object.Attr_Prefix_Version,
Text_Version => Format_Object.Attr_Version,
Initial_Version => '0');
else
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
PVersion : Character := Format_Object.Attr_Prefix_Version;
PKind : ARM_Database.Paragraph_Change_Kind_Type :=
Format_Object.Attr_Prefix_Change_Kind;
begin
if PVersion < Format_Object.Attr_Initial_Version then
-- This usually happens when the prefix used
-- @PrefixType; in that case, the
-- Initial_Version is really want we want.
-- And in that case, the prefix paragraph number
-- is always inserted (since we can't get here
-- if the Initial_Version is '0').
PVersion := Format_Object.Attr_Initial_Version;
PKind := ARM_Database.Inserted;
end if;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_Object.Attr_Initial_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
null; -- Do *not* put this into the DB.
--Ada.Text_IO.Put_Line (" Attr: Ignore");
elsif Disposition = ARM_Output.None then
--Ada.Text_IO.Put_Line (" Attr: Normal");
-- Normal reference:
Write_to_DB (Prefix_Kind => PKind,
Text_Kind => Format_Object.Attr_Change_Kind,
Prefix_Version => PVersion,
Text_Version => Format_Object.Attr_Version,
Initial_Version => Format_Object.Attr_Initial_Version);
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
-- Write inserted text:
-- We need to mark everything with
-- the kind and version of the *entire* insertion,
-- because the entire thing is an
-- insertion. (So we ignore the prefix kind and version).
--Ada.Text_IO.Put_Line (" Attr: Inserted version:" & Format_Object.Attr_Initial_Version);
if Format_Object.Attr_Leading then
ARM_Database.Insert (Format_Object.Attr_DB,
Sort_Key => Sort_Key,
Hang_Item =>
"@ChgAdded{Version=[" & Format_Object.Attr_Initial_Version & "],Text=[" &
Format_Object.Attr_Prefix(1..Format_Object.Attr_Prefix_Len) &
''' & Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len) & "]}",
Text =>
"@ChgAdded{Version=[" & Format_Object.Attr_Initial_Version & "],Text=[" &
"For " & Format_Object.Prefix_Text(1..Format_Object.Prefix_Text_Len) &
":]}" & Ascii.LF & Ascii.LF &
ChgRef_Command (Format_Object.Attr_Change_Kind, Format_Object.Attr_Version, Format_Object.Attr_Initial_Version) &
"@leading@noprefix@;" & Text_Buffer(1..Text_Buffer_Len) &
" See @RefSecbyNum{" & Clause_String(Format_Object) & "}.",
Change_Kind => PKind,
Version => PVersion,
Initial_Version => Format_Object.Attr_Initial_Version);
else -- not leading:
ARM_Database.Insert (Format_Object.Attr_DB,
Sort_Key => Sort_Key,
Hang_Item =>
"@ChgAdded{Version=[" & Format_Object.Attr_Initial_Version & "],Text=[" &
Format_Object.Attr_Prefix(1..Format_Object.Attr_Prefix_Len) &
''' & Format_Object.Attr_Name(1..Format_Object.Attr_Name_Len) & "]}",
Text =>
"@ChgAdded{Version=[" & Format_Object.Attr_Initial_Version & "],Text=[" &
"For " & Format_Object.Prefix_Text(1..Format_Object.Prefix_Text_Len) &
":]}" & Ascii.LF & Ascii.LF &
ChgRef_Command (Format_Object.Attr_Change_Kind, Format_Object.Attr_Version, Format_Object.Attr_Initial_Version) &
"@noprefix@;" & Text_Buffer(1..Text_Buffer_Len) &
" See @RefSecbyNum{" & Clause_String(Format_Object) & "}.",
Change_Kind => PKind,
Version => PVersion,
Initial_Version => Format_Object.Attr_Initial_Version);
end if;
end if;
end;
end if;
end;
when Pragma_Syntax | Added_Pragma_Syntax | Deleted_Pragma_Syntax =>
-- Note: Pragma_Syntax is not recorded in the syntax summary.
declare
Text_Buffer : String (1..ARM_Input.MAX_RECORDING_SIZE);
Text_Buffer_Len : Natural;
function My_Sort return String is
-- Find and return the @prag argument.
begin
for I in 1 .. Text_Buffer_Len - 7 loop
if Text_Buffer(I) = '@' and then
(Text_Buffer(I+1) = 'p' or else Text_Buffer(I+1) = 'P') and then
(Text_Buffer(I+2) = 'r' or else Text_Buffer(I+2) = 'R') and then
(Text_Buffer(I+3) = 'a' or else Text_Buffer(I+3) = 'A') and then
(Text_Buffer(I+4) = 'g' or else Text_Buffer(I+4) = 'G') and then
ARM_Input.Is_Open_Char (Text_Buffer(I+5)) then
-- Found @prag.
for J in I+6 .. Text_Buffer_Len loop
if Text_Buffer(J) = ARM_Input.Get_Close_Char (Text_Buffer(I+5)) then
return Text_Buffer(I+6 .. J-1);
end if;
end loop;
Ada.Text_IO.Put_Line ("** Can't find argument for @prag: " & Text_Buffer(1..Text_Buffer_Len) &
" on line " & ARM_Input.Line_String (Input_Object));
return ""; -- Never found the end of the argument.
-- else not @prag, keep looking.
end if;
end loop;
-- If we get here, we never found "@prag"
Ada.Text_IO.Put_Line ("** Funny pragma format: " & Text_Buffer(1..Text_Buffer_Len) &
" on line " & ARM_Input.Line_String (Input_Object));
return ""; -- Gotta return something.
end My_Sort;
begin
Arm_Input.Stop_Recording_and_Read_Result
(Input_Object, Text_Buffer, Text_Buffer_Len);
Text_Buffer_Len := Text_Buffer_Len - 1; -- Remove command close character.
-- Ordinary text processing is fine for the local text.
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Pragma_Syntax then
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => Text_Buffer(1..Text_Buffer_Len) &
" @em See @RefSecbyNum{" & Clause_String(Format_Object) & "}.");
elsif Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Added_Pragma_Syntax then
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
null; -- Not in old versions, omit from Annex.
elsif Disposition = ARM_Output.None then
-- Normal reference:
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],Kind=[Added]}" &
Text_Buffer(1..Text_Buffer_Len) &
" @em See @RefSecbyNum{" & Clause_String(Format_Object) & "}.");
-- Note: We still need the @ChgRef in order
-- to get the paragraph numbers right.
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],Kind=[Added]}" &
Text_Buffer(1..Text_Buffer_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],New=[" &
" @em See @RefSecbyNum<" & Clause_String(Format_Object) & ">.],Old=[]}");
-- Note: Text includes any needed @Chg commands.
end if;
end;
else --if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Command = Deleted_Pragma_Syntax then
declare
Add_Disposition : ARM_Output.Change_Type;
Del_Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
function Para_Kind return String is
begin
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version = '0' and then
Add_Disposition /= ARM_Output.Insertion then
return "Deleted";
else
return "DeletedAdded";
end if;
end Para_Kind;
begin
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version,
Operation => ARM_Output.Deletion,
Text_Kind => Del_Disposition);
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version = '0' then
Add_Disposition := ARM_Output.None;
else
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Add_Disposition);
end if;
if Del_Disposition = Do_Not_Display_Text then
--Ada.Text_IO.Put_Line ("%% Deleted pragma completely omitted");
if Add_Disposition /= Do_Not_Display_Text
and then Format_Object.Number_Paragraphs then
-- If this was in older editions, then
-- we need a deletion message (and also
-- to get the paragraph numbers right).
-- But don't need this if there are no
-- paragraph numbers (then there is no
-- deleted message).
--Ada.Text_IO.Put_Line (" ... but need a deletion message");
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],Kind=[" & Para_Kind & "]}@ ");
else
null; -- Not at all in this version, omit from Annex.
end if;
elsif Del_Disposition = ARM_Output.None then
--Ada.Text_IO.Put_Line ("%% Deleted pragma normal format");
-- Is the initial item inserted or normal?
if Add_Disposition = ARM_Output.Insertion then
--Ada.Text_IO.Put_Line ("... but inserted");
-- Inserted reference:
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version &
"],Kind=[Added]}" &
Text_Buffer(1..Text_Buffer_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version &
"],New=[" &
" @em See @RefSecbyNum<" & Clause_String(Format_Object) & ">.],Old=[]}");
else -- Anything else.
-- Normal reference:
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version = '0' then
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => Text_Buffer(1..Text_Buffer_Len) &
" @em See @RefSecbyNum{" & Clause_String(Format_Object) & "}.");
else
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version &
"],Kind=[Added]}" &
Text_Buffer(1..Text_Buffer_Len) &
" @em See @RefSecbyNum{" & Clause_String(Format_Object) & "}.");
-- Note: We still need the @ChgRef in order
-- to get the paragraph numbers right.
end if;
end if;
elsif Del_Disposition = ARM_Output.Insertion then
raise Program_Error; -- An insertion inside of a deletion command!
else -- Deletion.
--Ada.Text_IO.Put_Line ("%% Deleted pragma deleted text");
-- Is the initial item inserted or normal?
if Add_Disposition = ARM_Output.Insertion then
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],Kind=[DeletedAdded]}" &
Text_Buffer(1..Text_Buffer_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Prev_Change_Version &
"],New=[" &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],New=[],Old=[" &
" @em See @RefSecbyNum<" & Clause_String(Format_Object) & ">.]}],Old=[]}");
else -- Anything else.
-- Just a deleted reference:
ARM_Database.Insert (Format_Object.Pragma_DB,
Sort_Key => My_Sort,
Hang_Item => "",
Text => "@ChgRef{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],Kind=[" & Para_Kind & "]}" &
Text_Buffer(1..Text_Buffer_Len) &
"@Chg{Version=[" & Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr).Change_Version &
"],New=[],Old=[" &
" @em See @RefSecbyNum<" & Clause_String(Format_Object) & ">.]}");
-- Note: We still need the @ChgRef in order
-- to get the paragraph numbers right and for the deleted paragraph message.
end if;
end if;
end;
end if;
end;
when Implementation_Defined | Change_Impdef_Text_Param =>
-- Save the implementation-defined entry in the database.
Finish_and_DB_Entry (Format_Object.Impdef_DB);
when Change_Impladv_Text_Param =>
-- Save the implementation advice entry in the database.
Finish_and_DB_Entry (Format_Object.Impladv_DB);
when Change_Docreq_Text_Param =>
-- Save the documentation requirement entry in the database.
Finish_and_DB_Entry (Format_Object.Docreq_DB);
when Change_AspectDesc_Text_Param =>
-- Save the documentation requirement entry in the database.
Finish_and_DB_Entry (Format_Object.Aspect_DB);
when Prefix_Type | Change_Prefix_Text_Param =>
-- Copy the text into the Format_Object.Prefix_Text string.
ARM_Input.Stop_Recording_and_Read_Result (
Input_Object,
Format_Object.Prefix_Text,
Format_Object.Prefix_Text_Len);
Format_Object.Prefix_Text_Len :=
Format_Object.Prefix_Text_Len - 1; -- Remove command close character.
when Change_Param_Old =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version >
Format_Object.Change_Version then
-- The new text was ignored, use the old only.
null; -- Nothing special to do.
else
case Format_Object.Changes is
when ARM_Format.Old_Only =>
null; -- Nothing special to do.
when ARM_Format.New_Only =>
null; -- Nothing to do (we nulled out the text before we got here).
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version <
Format_Object.Base_Change_Version then
-- Old enough that only the new text is shown.
null; -- Nothing to do (we nulled out the text before we got here).
else
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text then
-- Non-empty text. Restore the previous
-- insertion state.
Format_Object.Text_Format.Change :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Change;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Change_Version;
Format_Object.Text_Format.Added_Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Added_Change_Version;
Check_Paragraph; -- We have to be in a paragraph
-- in correct code, but this could happen
-- if the user ended the paragraph by mistake
-- (we've already generated an error in that case).
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
-- else no text.
end if;
end if;
end case;
end if;
Format_Object.In_Change :=
Arm_Output."/=" (Format_Object.Text_Format.Change, ARM_Output.None);
when Change_Param_New =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version >
Format_Object.Change_Version then
-- The new text was ignored.
null; -- Nothing to do (we nulled out the text before we got here).
else
case Format_Object.Changes is
when ARM_Format.Old_Only =>
null; -- Nothing to do (we nulled out the text before we got here).
when ARM_Format.New_Only =>
null; -- Nothing special to do.
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version <
Format_Object.Base_Change_Version then
-- Old enough that only the new text is shown.
null; -- Nothing special to do.
else
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text then
-- Non-empty text. Restore the previous
-- insertion state.
Format_Object.Text_Format.Change :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Change;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Change_Version;
Format_Object.Text_Format.Added_Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Prev_Added_Change_Version;
Check_Paragraph; -- We have to be in a paragraph
-- in correct code, but this could happen
-- if the user ended the paragraph by mistake
-- (we've already generated an error in that case).
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
-- else no text.
end if;
end if;
end case;
end if;
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
-- Unstack the "New" parameter.
--Ada.Text_IO.Put_Line (" &Unstack (Chg New)");
-- Check and handle the following "Old" parameter:
declare
Ch, Ch2 : Character;
begin
ARM_Input.Check_Parameter_Name (Input_Object,
Param_Name => "Old" & (4..ARM_Input.Command_Name_Type'Last => ' '),
Is_First => False,
Param_Close_Bracket => Ch);
if Ch /= ' ' then -- There is a parameter.
-- Stack the parameter so we can process the end:
Set_Nesting_for_Parameter
(Command => Change_Param_Old,
Close_Ch => Ch);
-- Now, handle the parameter:
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version >
Format_Object.Change_Version then
-- The new text was ignored, show the old only.
null; -- Nothing special to do.
else
case Format_Object.Changes is
when ARM_Format.Old_Only =>
null; -- Nothing special to do.
when ARM_Format.New_Only =>
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
when ARM_Format.Show_Changes |
ARM_Format.New_Changes =>
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version <
Format_Object.Base_Change_Version then
-- Old enough that only the new text is shown.
-- Skip the text:
ARM_Input.Skip_until_Close_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
else
ARM_Input.Get_Char (Input_Object, Ch2);
ARM_Input.Replace_Char (Input_Object);
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text :=
Ch /= Ch2;
if Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Was_Text then
-- Non-empty text; calculate new change state: (current is deletion)
Check_Paragraph; -- Output the paragraph headers before changing the state.
-- This can only matter for a deletion without
-- an insertion; otherwise, we're already in a paragraph.
case Format_Object.Text_Format.Change is
when ARM_Output.Deletion | ARM_Output.None =>
Format_Object.Text_Format.Change := ARM_Output.Deletion;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
Format_Object.Text_Format.Added_Version := '0';
when ARM_Output.Insertion =>
Format_Object.Text_Format.Change := ARM_Output.Both;
Format_Object.Text_Format.Added_Version :=
Format_Object.Text_Format.Version;
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
when ARM_Output.Both =>
Format_Object.Text_Format.Change := ARM_Output.Both;
-- Added_Version is unchanged.
Format_Object.Text_Format.Version :=
Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version;
end case;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
if Format_Object.Changes = ARM_Format.New_Changes then
ARM_Output.Ordinary_Character (Output_Object, ' ');
-- Skip the text (we're not going to output it):
ARM_Input.Skip_until_Close_Char (Input_Object, Ch);
ARM_Input.Replace_Char (Input_Object); -- Let the normal termination clean this up.
-- else if Format_Object.Changes = ARM_Format.Show_Changes then
-- Nothing else needed.
end if;
-- else no text, so don't emit a change area.
end if;
end if;
end case;
end if;
Format_Object.In_Change := True;
-- else no parameter. Weird.
end if;
return; -- We've already done the unstacking.
end;
when Change_Added_Param =>
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Format_Object.In_Change := False;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version,
Operation => ARM_Output.Insertion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- The new text was ignored.
null; -- Nothing to do (we nulled out the text before we got here).
elsif Disposition = ARM_Output.None then
-- Display the text normally.
null; -- Nothing special to do.
elsif Disposition = ARM_Output.Deletion then
raise Program_Error; -- A deletion inside of an insertion command!
else -- Insertion.
-- Reset the state to normal:
Format_Object.Text_Format.Change := ARM_Output.None;
Format_Object.Text_Format.Version := '0';
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- We have to be in a paragraph
-- in correct code, but this could happen
-- if the user ended the paragraph by mistake
-- (we've already generated an error in that case).
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
end if;
end;
when Change_Deleted_Param =>
declare
Disposition : ARM_Output.Change_Type;
use type ARM_Output.Change_Type;
begin
Format_Object.In_Change := False;
Calc_Change_Disposition (
Format_Object => Format_Object,
Version => Format_State.Nesting_Stack(Format_State.Nesting_Stack_Ptr-1).Change_Version,
Operation => ARM_Output.Deletion,
Text_Kind => Disposition);
if Disposition = Do_Not_Display_Text then
-- The old text was ignored.
null; -- Nothing to do (we nulled out the text before we got here).
elsif Disposition = ARM_Output.None then
-- Display the text normally.
null; -- Nothing special to do.
elsif Disposition = ARM_Output.Insertion then
raise Program_Error; -- An insertion inside of a deletion command!
else -- Insertion.
-- Reset the state to normal:
Format_Object.Text_Format.Change := ARM_Output.None;
Format_Object.Text_Format.Version := '0';
Format_Object.Text_Format.Added_Version := '0';
Check_Paragraph; -- We have to be in a paragraph
-- in correct code, but this could happen
-- if the user ended the paragraph by mistake
-- (we've already generated an error in that case).
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
end if;
end;
when Ceiling =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Ceiling);
Format_Object.Last_Non_Space := True;
when Floor =>
Check_Paragraph;
ARM_Output.Special_Character (Output_Object, ARM_Output.Right_Floor);
Format_Object.Last_Non_Space := True;
when Absolute =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '|');
Format_Object.Last_Non_Space := True;
when Log =>
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, ')');
Format_Object.Last_Non_Space := True;
when others =>
-- No special handling needed.
null;
end case;
--Ada.Text_IO.Put_Line (" &Unstack (Normal)");
Format_State.Nesting_Stack_Ptr := Format_State.Nesting_Stack_Ptr - 1;
end Handle_End_of_Command;
procedure Process_Special is
-- Process a special command/macro/tab.
-- These all start with '@'.
-- @xxxx is a command. It may have parameters delimited by
-- (), {}, [], or <>. There does not appear to be an escape, so
-- we don't have to worry about '}' being used in {} brackets,
-- for example. (Must be a pain to write, though.)
Command_Name : ARM_Input.Command_Name_Type;
Ch : Character;
use type ARM_Output.Size_Type;
begin
ARM_Input.Get_Char (Input_Object, Ch);
if Ch = '\' then
-- This represents a tab, or the end of centered text.
-- (According to <NAME>, from the Scribe manual).
if Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_1 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_2 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_3 or else
Format_Object.Next_Paragraph_Format_Type = Hanging_Indented_4 then
-- Instead of a tab, just use this to mark the end
-- of the hanging portion:
Check_Paragraph;
if Format_Object.In_Change then
-- Close all formatting:
declare
Closed_Formatting : ARM_Output.Format_Type :=
ARM_Output.NORMAL_FORMAT;
begin
Closed_Formatting.Font := Format_Object.Text_Format.Font; -- No clear default for these.
Closed_Formatting.Size := Format_Object.Text_Format.Size;
ARM_Output.Text_Format (Output_Object,
Closed_Formatting);
end;
end if;
ARM_Output.End_Hang_Item (Output_Object);
if Format_Object.In_Change then
-- Reset to the normal case:
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
end if;
elsif Format_Object.Next_Paragraph_Format_Type = In_Table then
-- If in a table, ends a item.
ARM_Output.Table_Marker (Output_Object, ARM_Output.End_Item);
-- elsif centered text: TBD.
elsif ARM_Output."="(Format_Object.Paragraph_Tab_Stops, ARM_Output.NO_TABS) then
Ada.Text_IO.Put_Line (" ** Tab, but no tab stops set on line " &
ARM_Input.Line_String (Input_Object));
else
Check_Paragraph;
ARM_Output.Tab (Output_Object);
end if;
return; -- We're done here.
elsif Ch = '=' then
-- This marks the start of centered text.
-- (According to <NAME>, from the Scribe manual).
-- We're not implementing this; we're just going to replace
-- the handful of uses.
-- We're done here.
Ada.Text_IO.Put_Line (" ** Centered text unimplemented (skipped) on line " &
ARM_Input.Line_String (Input_Object));
return;
elsif Ch = '^' then
-- This represents setting at tab stop at the current location.
-- Neither HTML nor RTF supports such a thing, so these should
-- all have been replaced by conventional tab stops.
Ada.Text_IO.Put_Line (" && Cursor tab stop unimplemented (skipped) on line " &
ARM_Input.Line_String (Input_Object));
return;
elsif Ch = '@' then
-- This represents @ in the text. We're done here.
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, '@');
return;
elsif Ch = ' ' then
-- This represents a hard space in the text. We're done here.
Check_Paragraph;
ARM_Output.Hard_Space (Output_Object);
return;
elsif Ch = ';' then
-- This seems to be an end of command (or substitution) marker.
-- For instance, it is used in Section 1:
-- .. the distinction between @ResolutionName@;s and ...
-- This converts to:
-- .. the distinction between Name Resolution Rules and ...
-- Without it, the 's' would append to the command name, and
-- we would get the wrong command. Thus, it itself does nothing
-- at all, so we're done here.
return;
elsif Ch = '-' then
-- This represents a subscript. It has an argument.
ARM_Input.Get_Char (Input_Object, Ch);
if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
Set_Nesting_for_Command
(Name => '-' & (2..ARM_Input.Command_Name_Type'Last => ' '),
Kind => Normal,
Param_Ch => Ch);
Check_Paragraph;
Format_Object.Text_Format.Size :=
Format_Object.Text_Format.Size - 2;
Format_Object.Text_Format.Location := ARM_Output.Subscript;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
else -- No parameter. Weird.
ARM_Input.Replace_Char (Input_Object);
Ada.Text_IO.Put_Line (" ** Failed to find parameter for subscript, line " & ARM_Input.Line_String (Input_Object));
end if;
return;
elsif Ch = '+' then
-- This represents a superscript. It has an argument.
ARM_Input.Get_Char (Input_Object, Ch);
if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
Set_Nesting_for_Command
(Name => '+' & (2..ARM_Input.Command_Name_Type'Last => ' '),
Kind => Normal,
Param_Ch => Ch);
Check_Paragraph;
Format_Object.Text_Format.Size :=
Format_Object.Text_Format.Size - 2;
Format_Object.Text_Format.Location := ARM_Output.Superscript;
ARM_Output.Text_Format (Output_Object,
Format_Object.Text_Format);
else -- No parameter. Weird.
ARM_Input.Replace_Char (Input_Object);
Ada.Text_IO.Put_Line (" ** Failed to find parameter for superscript, line " & ARM_Input.Line_String (Input_Object));
end if;
return;
elsif Ch = ':' then
-- According to Tucker, the Scribe manual says:
-- @: After a ".", it forces the "." to be interpreted as a
-- sentence-ending period rather than as an initial-ending
-- period. E.g.: You are better than I.@: F. Stone is
-- even better. Without the @:, the period after "I"
-- would be interpreted as the period signifying an
-- initial.
--
-- Besides not making much sense, this certainly does nothing
-- for us.
return;
elsif Ch = '*' then
-- According to Tucker, the Scribe manual says:
-- @* This forces a line break, without starting a new
-- paragraph.
-- Tucker thinks this is "<BR>" in HTML.
if Format_Object.In_Paragraph then
ARM_Output.Line_Break (Output_Object);
Format_Object.Last_Non_Space := False;
-- else why start a paragraph with a line break??
end if;
return;
elsif Ch = '|' then
-- According to Tucker, the Scribe manual says:
-- @| This marks a place within a word where a line break
-- may be inserted, *without* inserting a hyphen. It is
-- effectively a zero-length "word". You can use it to add
-- spaces between words that disappear if the line gets
-- broken there. For example:
-- This is @| a sentence with two spaces between "is" and "a".
-- The extra space will disappear if the line is broken
-- between "is" and "a".
--
-- However, this appears to be used mainly to insert potential
-- line breaks into large words, and we use and implement it
-- that way.
if Format_Object.In_Paragraph then
ARM_Output.Soft_Line_Break (Output_Object);
Format_Object.Last_Non_Space := False;
-- else don't care about non-required breaks between paragraphs.
end if;
return;
elsif Ch = '!' then
-- This marks a place within a word where a line break
-- may be inserted, inserting a hyphen.
if Format_Object.In_Paragraph then
ARM_Output.Soft_Hyphen_Break (Output_Object);
Format_Object.Last_Non_Space := False;
-- else don't care about non-required breaks between paragraphs.
end if;
return;
elsif Ch = Ascii.LF then
-- Stand alone '@'.
-- I now believe this is an error, perhaps a hard space where
-- the trailing blank was dropped. It originally appeared in
-- Infosys.MSS.
Ada.Text_IO.Put_Line("** Stand-alone '@' on line " & ARM_Input.Line_String (Input_Object));
return;
end if;
ARM_Input.Replace_Char (Input_Object);
ARM_Input.Get_Name (Input_Object, Command_Name);
--Ada.Text_IO.Put_Line("!!Command=" & Ada.Strings.Fixed.Trim(Command_Name, Ada.Strings.Both));
ARM_Input.Get_Char (Input_Object, Ch);
if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
Set_Nesting_for_Command
(Name => Ada.Characters.Handling.To_Lower (Command_Name),
Kind => Normal,
Param_Ch => Ch);
Process_Command_with_Parameter;
else
ARM_Input.Replace_Char (Input_Object);
Process_Command_without_Parameter (Command_Name);
end if;
end Process_Special;
procedure Lookahead_for_End_of_Paragraph is
-- Look at the command following to see if it would
-- end the paragraph. If not, generate a Line_Break.
-- In any case, process the command (we don't allow more than
-- one call to Replace_Char).
-- We can assume that we are in a paragraph.
Command_Name : ARM_Input.Command_Name_Type;
Ch : Character;
begin
ARM_Input.Get_Char (Input_Object, Ch);
if Ch not in 'A' .. 'Z' and then Ch not in 'a' .. 'z' then
-- Not a named command, these never end a paragraph:
ARM_Input.Replace_Char (Input_Object);
ARM_Output.Line_Break (Output_Object);
Format_Object.Last_Non_Space := False;
Process_Special;
else -- Named command.
ARM_Input.Replace_Char (Input_Object);
ARM_Input.Get_Name (Input_Object, Command_Name);
case Command (Command_Name) is
when Text_Begin | Text_End | New_Page | New_Column | RM_New_Page |
Thin_Line | Thick_Line | Table | Picture_Alone |
To_Glossary | Change_To_Glossary |
Implementation_Defined |
Change_Implementation_Defined |
Change_Implementation_Advice |
Change_Documentation_Requirement |
Labeled_Section |
Labeled_Section_No_Break |
Labeled_Clause | Labeled_Subclause | Labeled_Subsubclause |
Labeled_Revised_Section | Labeled_Revised_Clause |
Labeled_Revised_Subclause | Labeled_Revised_Subsubclause |
Labeled_Added_Section | Labeled_Added_Clause |
Labeled_Added_Subclause | Labeled_Added_Subsubclause |
Labeled_Deleted_Clause |
Labeled_Deleted_Subclause | Labeled_Deleted_Subsubclause |
Preface_Section |
Labeled_Annex | Labeled_Revised_Annex | Labeled_Added_Annex |
Labeled_Informative_Annex |
Labeled_Revised_Informative_Annex | Labeled_Added_Informative_Annex |
Labeled_Normative_Annex |
Labeled_Revised_Normative_Annex | Labeled_Added_Normative_Annex |
Unnumbered_Section | Subheading | Heading | Center | Right =>
-- Ends a paragraph. No line break needed here (or
-- we'd end up with two).
null;
when others =>
-- Does not end a paragraph. Put in the soft break.
ARM_Output.Line_Break (Output_Object);
Format_Object.Last_Non_Space := False;
end case;
-- Now, process the command:
ARM_Input.Get_Char (Input_Object, Ch);
if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
Set_Nesting_for_Command
(Name => Ada.Characters.Handling.To_Lower (Command_Name),
Kind => Normal,
Param_Ch => Ch);
Process_Command_with_Parameter;
else
ARM_Input.Replace_Char (Input_Object);
Process_Command_without_Parameter (Command_Name);
end if;
end if;
end Lookahead_for_End_of_Paragraph;
begin
Reading_Loop: loop
declare
Char : Character;
begin
ARM_Input.Get_Char (Input_Object, Char);
--Ada.Text_IO.Put_Line("!!Char=" & Char & " Nesting=" & Natural'Image(Format_State.Nesting_Stack_Ptr));
case Char is
when '@' =>
Process_Special;
when Ascii.LF =>
ARM_Input.Get_Char (Input_Object, Char);
if Char /= Ascii.LF then
-- Soft line break.
if Format_Object.Next_Paragraph_Format_Type = Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Child_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Indented_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Production then
-- These formats preserves all line breaks, but a
-- "soft" break does not end a paragraph.
if Char /= '@' or else (not Format_Object.In_Paragraph) then
-- Not a paragraph end coming up:
if Format_Object.In_Paragraph then
ARM_Output.Line_Break (Output_Object);
Format_Object.Last_Non_Space := False;
-- else not in paragraph, we don't need to preserve
-- the break.
end if;
ARM_Input.Replace_Char (Input_Object);
else
-- A command following, and we're in a paragraph.
-- If that command ends the paragraph, then
-- we don't want a soft break here (else we'd
-- end up with an extra blank line at the end).
-- Otherwise, we do.
Lookahead_for_End_of_Paragraph;
end if;
elsif Format_Object.Next_Paragraph_Format_Type = In_Table then
-- If in a table, ends a row.
ARM_Output.Table_Marker (Output_Object, ARM_Output.End_Row);
ARM_Input.Replace_Char (Input_Object);
Format_Object.Last_Non_Space := False;
-- There should be nothing above the table at
-- this point. Complain about other commands
-- (this is a signficant aid to building tables):
declare
Start_Depth : Natural := 1;
begin
--Find the table:
for I in reverse 1 .. Format_State.Nesting_Stack_Ptr loop
if Format_State.Nesting_Stack(I).Command = Table then
Start_Depth := I;
exit;
end if;
end loop;
if Format_State.Nesting_Stack(Start_Depth+1).Command /= Table_Param_Body then
Ada.Text_IO.Put_Line (" ** Wrong command on top of table, line " & ARM_Input.Line_String (Input_Object));
Ada.Text_IO.Put_Line (" Command=" & Format_State.Nesting_Stack(Start_Depth+1).Name & " Class=" &
Data.Command_Type'Image(Format_State.Nesting_Stack(Start_Depth+1).Command));
elsif Format_State.Nesting_Stack_Ptr /= Start_Depth+1 then
Ada.Text_IO.Put_Line (" ** Unfinished commands detected at end of row, line " & ARM_Input.Line_String (Input_Object));
end if;
for I in reverse Start_Depth+2 .. Format_State.Nesting_Stack_Ptr loop
Ada.Text_IO.Put_Line (" Open command=" &
Format_State.Nesting_Stack(I).Name & " Class=" &
Data.Command_Type'Image(Format_State.Nesting_Stack(I).Command));
end loop;
end;
else -- Normal paragraph:
-- Output a space if the last character was
-- not a space and the next character is
-- not a space. Eliminate any leading blanks
-- added for formatting:
if Format_Object.In_Paragraph and then
Format_Object.Last_Non_Space then
ARM_Output.Ordinary_Character (Output_Object, ' ');
Format_Object.Last_Non_Space := False;
end if;
-- Skip any leading spaces for the next paragraph:
while Char = ' ' loop
ARM_Input.Get_Char (Input_Object, Char);
end loop;
ARM_Input.Replace_Char (Input_Object);
end if;
else -- Hard paragraph break. Only one, no matter
-- how many blank lines there are:
while Char = Ascii.LF loop
ARM_Input.Get_Char (Input_Object, Char);
end loop;
if Format_Object.Next_Paragraph_Format_Type = Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Child_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Indented_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Production then
null; -- In these formats, blanks remain.
else
-- Also remove any leading blanks from the next
-- paragraph:
while Char = ' ' loop
ARM_Input.Get_Char (Input_Object, Char);
end loop;
end if;
ARM_Input.Replace_Char (Input_Object);
Check_End_Paragraph; -- End the paragraph.
end if;
when ' ' =>
if Format_Object.Next_Paragraph_Format_Type = Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Child_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Indented_Example_Text or else
Format_Object.Next_Paragraph_Format_Type = Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Display or else
Format_Object.Next_Paragraph_Format_Type = Syntax_Production then
-- Spaces are significant these formats.
Check_Paragraph;
ARM_Output.Hard_Space (Output_Object);
else
if Format_Object.In_Paragraph then
if Format_Object.No_Start_Paragraph then
-- Not really in a paragraph.
Ada.Text_IO.Put_Line ("Attempt to write into a deleted paragraph, on line " & ARM_Input.Line_String (Input_Object));
-- We'll probably crash soon.
null;
else
ARM_Output.Ordinary_Character (Output_Object, ' ');
end if;
-- else we never want to start a paragraph with a space.
end if;
end if;
Format_Object.Last_Non_Space := False;
when Ascii.SUB =>
-- End of file.
exit Reading_Loop;
when others =>
if Format_State.Nesting_Stack_Ptr /= 0 and then
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char /= ' ' and then
Format_State.Nesting_Stack (Format_State.Nesting_Stack_Ptr).Close_Char = Char then
-- Closing a command, remove it from the stack.
Handle_End_of_Command;
else
Check_Paragraph;
ARM_Output.Ordinary_Character (Output_Object, Char);
null; -- Ordinary characters, output them.
Format_Object.Last_Non_Space := True;
end if;
end case;
end;
end loop Reading_Loop;
exception
when ARM_Output.Not_Valid_Error =>
Ada.Text_IO.Put_Line ("** Output validity error processing line " & ARM_Input.Line_String (Input_Object));
raise;
end Real_Process;
procedure Process (Format_Object : in out Format_Type;
File_Name : in String;
Output_Object : in out ARM_Output.Output_Type'Class;
Section_Name : in String;
Section_Number : in ARM_Contents.Section_Number_Type;
Starts_New_Section : in Boolean) is
-- Process the contents for File_Name, writing the results to
-- Output_Object. (Output_Object uses dispatching calls to provide
-- the correct formatting). Section_Name is the name of the section
-- for this file. Starts_New_Section is True if the file starts
-- a new section. Section_Number is the number (or letter) of the
-- section. Values > 20 represent annex letters (21 => A, 22 => B, etc.)
Input_Object : Arm_File.File_Input_Type;
Format_State : Format_State_Type;
begin
Ada.Text_IO.Put_Line ("-- Processing " & File_Name);
begin
Arm_File.Open (Input_Object, File_Name);
exception
when others =>
Ada.Text_IO.Put_Line ("** Unable to open file " & File_Name);
raise;
end;
if Starts_New_Section then
Format_Object.Clause_Number := (Section => Section_Number,
Clause => 0, Subclause => 0, Subsubclause => 0);
declare
use type ARM_Contents.Section_Number_Type;
begin
if Section_Number = 0 then -- No title at all.
ARM_Output.Section (Output_Object,
Section_Title => "",
Section_Name => Section_Name);
elsif Section_Number < ARM_Contents.ANNEX_START then
ARM_Output.Section (Output_Object,
Section_Title => Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Title (ARM_Contents.Section,
(Section => Section_Number, others => 0)), Ada.Strings.Right),
Section_Name => Section_Name);
else
-- We don't have a way to tell between the three kinds of annexes, so we try them all:
begin
ARM_Output.Section (Output_Object,
Section_Title => Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Title (ARM_Contents.Normative_Annex,
(Section => Section_Number, others => 0)), Ada.Strings.Right),
Section_Name => Section_Name);
exception
when ARM_Contents.Not_Found_Error =>
begin
ARM_Output.Section (Output_Object,
Section_Title => Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Title (ARM_Contents.Informative_Annex,
(Section => Section_Number, others => 0)), Ada.Strings.Right),
Section_Name => Section_Name);
exception
when ARM_Contents.Not_Found_Error =>
ARM_Output.Section (Output_Object,
Section_Title => Ada.Strings.Fixed.Trim (
ARM_Contents.Lookup_Title (ARM_Contents.Plain_Annex,
(Section => Section_Number, others => 0)), Ada.Strings.Right),
Section_Name => Section_Name);
-- If this fails, too, we just propagate to the outer handler.
end;
end;
end if;
exception
when ARM_Contents.Not_Found_Error =>
Ada.Text_IO.Put_Line ("** Unable to find section title, line " & ARM_File.Line_String (Input_Object));
end;
Format_Object.Next_Note := 1;
Format_Object.Next_Paragraph := 1;
Format_Object.Next_Insert_Para := 1;
Format_Object.Next_AARM_Sub := 'a';
Format_Object.Next_Enumerated_Num := 1;
Format_Object.Enumerated_Level := 0;
Format_Object.Text_Format := ARM_Output.NORMAL_FORMAT;
Format_Object.No_Prefix := False;
Format_Object.No_Para_Num := False;
Format_Object.Keep_with_Next := False;
Format_Object.Space_After := ARM_Output.Normal;
Format_Object.No_Breaks := False;
Format_Object.In_Change := False;
Format_Object.Last_Non_Space := False;
Format_Object.Next_Paragraph_Change_Kind := ARM_Database.None;
Format_Object.Style := ARM_Output.Normal; -- The default.
Format_Object.Indent := 0; -- No indent to start.
Format_Object.In_Paragraph := False;
Format_Object.No_Start_Paragraph := False;
end if;
Real_Process (Format_Object, Format_State, Input_Object, Output_Object);
-- Reached end of the file/input object.
-- Kill any open paragraph:
if Format_Object.In_Paragraph and then (not Format_Object.No_Start_Paragraph) then
ARM_Output.End_Paragraph (Output_Object);
Format_Object.In_Paragraph := False;
Format_Object.No_Start_Paragraph := False;
end if;
Ada.Text_IO.Put_Line (" Lines processed: " &
ARM_File.Line_String (Input_Object));
Arm_File.Close (Input_Object);
if Format_State.Nesting_Stack_Ptr /= 0 then
Ada.Text_IO.Put_Line (" ** Unfinished commands detected.");
for I in reverse 1 .. Format_State.Nesting_Stack_Ptr loop
Ada.Text_IO.Put_Line (" Open command=" &
Format_State.Nesting_Stack(I).Name);
end loop;
end if;
end Process;
procedure Format (Format_Object : in out Format_Type;
Text : in String;
Output_Object : in out ARM_Output.Output_Type'Class;
Text_Name : in String;
No_Annotations : in Boolean) is
-- Format the contents of Text, writing the results to
-- Output_Object. (Output_Object uses dispatching calls to provide
-- the correct formatting). Text is assumed to be a component of
-- a larger section. Text_Name is an identifying name for error messages.
-- If No_Annotations is true, we don't want any annotations even if we
-- are generating a document with annotations.
Input_Object : Arm_String.String_Input_Type;
Format_State : Format_State_Type;
Real_Include_Annotations : Boolean := Format_Object.Include_Annotations;
begin
if No_Annotations then
Format_Object.Include_Annotations := False;
end if;
Arm_String.Open (Input_Object, Text, Text_Name);
-- Open the input object using a string for input.
Real_Process (Format_Object, Format_State, Input_Object, Output_Object);
Arm_String.Close (Input_Object);
Format_Object.Include_Annotations := Real_Include_Annotations;
if Format_State.Nesting_Stack_Ptr /= 0 then
Ada.Text_IO.Put_Line (" ** Unfinished commands detected.");
end if;
end Format;
end ARM_Format;
|
source/strings/a-sgecin.adb | ytomino/drake | 33 | 27718 | with Ada.Strings.Naked_Maps.Case_Folding;
function Ada.Strings.Generic_Equal_Case_Insensitive (Left, Right : String_Type)
return Boolean
is
Mapping : constant not null Naked_Maps.Character_Mapping_Access :=
Naked_Maps.Case_Folding.Case_Folding_Map;
Left_Last : Natural := Left'First - 1;
Right_Last : Natural := Right'First - 1;
begin
while Left_Last < Left'Last and then Right_Last < Right'Last loop
declare
Left_Index : constant Positive := Left_Last + 1;
Left_Code : Wide_Wide_Character;
Left_Is_Illegal_Sequence : Boolean;
Right_Index : constant Positive := Right_Last + 1;
Right_Code : Wide_Wide_Character;
Right_Is_Illegal_Sequence : Boolean;
begin
Get (
Left (Left_Index .. Left'Last),
Left_Last,
Left_Code,
Left_Is_Illegal_Sequence);
Get (
Right (Right_Index .. Right'Last),
Right_Last,
Right_Code,
Right_Is_Illegal_Sequence);
if not Left_Is_Illegal_Sequence then
if not Right_Is_Illegal_Sequence then
-- Left and Right are legal
Left_Code := Naked_Maps.Value (Mapping.all, Left_Code);
Right_Code := Naked_Maps.Value (Mapping.all, Right_Code);
if Left_Code /= Right_Code then
return False;
end if;
else
-- Left is legal, Right is illegal
return False;
end if;
else
if not Right_Is_Illegal_Sequence then
-- Left is illegal, Right is legal
return False;
else
-- Left and Right are illegal
if Left (Left_Index .. Left_Last) /=
Right (Right_Index .. Right_Last)
then
return False;
end if;
end if;
end if;
end;
end loop;
return (Left_Last >= Left'Last) and then (Right_Last >= Right'Last);
end Ada.Strings.Generic_Equal_Case_Insensitive;
|
testb1.asm | thr0m3l/easy-xv6 | 0 | 94178 | <reponame>thr0m3l/easy-xv6
_testb1: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "fcntl.h"
#include "stat.h"
#include "types.h"
#include "user.h"
int main(int argc, char *argv[]) {
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc push -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 56 push %esi
e: 53 push %ebx
f: 51 push %ecx
10: 83 ec 18 sub $0x18,%esp
13: 8b 71 04 mov 0x4(%ecx),%esi
struct number *n = malloc(sizeof(struct number));
16: 6a 08 push $0x8
18: e8 b3 06 00 00 call 6d0 <malloc>
n->num1 = atoi(argv[2]);
1d: 5a pop %edx
1e: ff 76 08 push 0x8(%esi)
struct number *n = malloc(sizeof(struct number));
21: 89 c3 mov %eax,%ebx
n->num1 = atoi(argv[2]);
23: e8 58 02 00 00 call 280 <atoi>
28: 89 03 mov %eax,(%ebx)
n->num2 = atoi(argv[3]);
2a: 59 pop %ecx
2b: ff 76 0c push 0xc(%esi)
2e: e8 4d 02 00 00 call 280 <atoi>
char *c = argv[1];
char choice = c[0];
if (choice == 'p') {
33: 83 c4 10 add $0x10,%esp
n->num2 = atoi(argv[3]);
36: 89 43 04 mov %eax,0x4(%ebx)
char choice = c[0];
39: 8b 46 04 mov 0x4(%esi),%eax
3c: 0f b6 00 movzbl (%eax),%eax
if (choice == 'p') {
3f: 3c 70 cmp $0x70,%al
41: 74 3c je 7f <main+0x7f>
printf(1, "%d\n", mult(n));
} else if (choice == 'd') {
43: 3c 64 cmp $0x64,%al
45: 74 43 je 8a <main+0x8a>
printf(1, "%d\n", div(n));
} else if (choice == 'm') {
47: 3c 6d cmp $0x6d,%al
49: 74 16 je 61 <main+0x61>
printf(1, "%d\n", mod(n));
} else {
printf(1, "Not valid instruction\n");
4b: 50 push %eax
4c: 50 push %eax
4d: 68 cc 07 00 00 push $0x7cc
52: 6a 01 push $0x1
54: e8 47 04 00 00 call 4a0 <printf>
59: 83 c4 10 add $0x10,%esp
}
exit();
5c: e8 b2 02 00 00 call 313 <exit>
printf(1, "%d\n", mod(n));
61: 83 ec 0c sub $0xc,%esp
64: 53 push %ebx
65: e8 71 03 00 00 call 3db <mod>
printf(1, "%d\n", div(n));
6a: 83 c4 0c add $0xc,%esp
6d: 50 push %eax
6e: 68 c8 07 00 00 push $0x7c8
73: 6a 01 push $0x1
75: e8 26 04 00 00 call 4a0 <printf>
7a: 83 c4 10 add $0x10,%esp
7d: eb dd jmp 5c <main+0x5c>
printf(1, "%d\n", mult(n));
7f: 83 ec 0c sub $0xc,%esp
82: 53 push %ebx
83: e8 43 03 00 00 call 3cb <mult>
88: eb e0 jmp 6a <main+0x6a>
printf(1, "%d\n", div(n));
8a: 83 ec 0c sub $0xc,%esp
8d: 53 push %ebx
8e: e8 40 03 00 00 call 3d3 <div>
93: eb d5 jmp 6a <main+0x6a>
95: 66 90 xchg %ax,%ax
97: 66 90 xchg %ax,%ax
99: 66 90 xchg %ax,%ax
9b: 66 90 xchg %ax,%ax
9d: 66 90 xchg %ax,%ax
9f: 90 nop
000000a0 <strcpy>:
#include "stat.h"
#include "types.h"
#include "user.h"
#include "x86.h"
char *strcpy(char *s, const char *t) {
a0: 55 push %ebp
char *os;
os = s;
while ((*s++ = *t++) != 0)
a1: 31 c0 xor %eax,%eax
char *strcpy(char *s, const char *t) {
a3: 89 e5 mov %esp,%ebp
a5: 53 push %ebx
a6: 8b 4d 08 mov 0x8(%ebp),%ecx
a9: 8b 5d 0c mov 0xc(%ebp),%ebx
ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while ((*s++ = *t++) != 0)
b0: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
b4: 88 14 01 mov %dl,(%ecx,%eax,1)
b7: 83 c0 01 add $0x1,%eax
ba: 84 d2 test %dl,%dl
bc: 75 f2 jne b0 <strcpy+0x10>
;
return os;
}
be: 8b 5d fc mov -0x4(%ebp),%ebx
c1: 89 c8 mov %ecx,%eax
c3: c9 leave
c4: c3 ret
c5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000000d0 <strcmp>:
int strcmp(const char *p, const char *q) {
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 53 push %ebx
d4: 8b 55 08 mov 0x8(%ebp),%edx
d7: 8b 4d 0c mov 0xc(%ebp),%ecx
while (*p && *p == *q)
da: 0f b6 02 movzbl (%edx),%eax
dd: 84 c0 test %al,%al
df: 75 17 jne f8 <strcmp+0x28>
e1: eb 3a jmp 11d <strcmp+0x4d>
e3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e7: 90 nop
e8: 0f b6 42 01 movzbl 0x1(%edx),%eax
p++, q++;
ec: 83 c2 01 add $0x1,%edx
ef: 8d 59 01 lea 0x1(%ecx),%ebx
while (*p && *p == *q)
f2: 84 c0 test %al,%al
f4: 74 1a je 110 <strcmp+0x40>
p++, q++;
f6: 89 d9 mov %ebx,%ecx
while (*p && *p == *q)
f8: 0f b6 19 movzbl (%ecx),%ebx
fb: 38 c3 cmp %al,%bl
fd: 74 e9 je e8 <strcmp+0x18>
return (uchar)*p - (uchar)*q;
ff: 29 d8 sub %ebx,%eax
}
101: 8b 5d fc mov -0x4(%ebp),%ebx
104: c9 leave
105: c3 ret
106: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
10d: 8d 76 00 lea 0x0(%esi),%esi
return (uchar)*p - (uchar)*q;
110: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
114: 31 c0 xor %eax,%eax
116: 29 d8 sub %ebx,%eax
}
118: 8b 5d fc mov -0x4(%ebp),%ebx
11b: c9 leave
11c: c3 ret
return (uchar)*p - (uchar)*q;
11d: 0f b6 19 movzbl (%ecx),%ebx
120: 31 c0 xor %eax,%eax
122: eb db jmp ff <strcmp+0x2f>
124: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
12b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
12f: 90 nop
00000130 <strlen>:
uint strlen(const char *s) {
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for (n = 0; s[n]; n++)
136: 80 3a 00 cmpb $0x0,(%edx)
139: 74 15 je 150 <strlen+0x20>
13b: 31 c0 xor %eax,%eax
13d: 8d 76 00 lea 0x0(%esi),%esi
140: 83 c0 01 add $0x1,%eax
143: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
147: 89 c1 mov %eax,%ecx
149: 75 f5 jne 140 <strlen+0x10>
;
return n;
}
14b: 89 c8 mov %ecx,%eax
14d: 5d pop %ebp
14e: c3 ret
14f: 90 nop
for (n = 0; s[n]; n++)
150: 31 c9 xor %ecx,%ecx
}
152: 5d pop %ebp
153: 89 c8 mov %ecx,%eax
155: c3 ret
156: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
15d: 8d 76 00 lea 0x0(%esi),%esi
00000160 <memset>:
void *memset(void *dst, int c, uint n) {
160: 55 push %ebp
161: 89 e5 mov %esp,%ebp
163: 57 push %edi
164: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
167: 8b 4d 10 mov 0x10(%ebp),%ecx
16a: 8b 45 0c mov 0xc(%ebp),%eax
16d: 89 d7 mov %edx,%edi
16f: fc cld
170: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
172: 8b 7d fc mov -0x4(%ebp),%edi
175: 89 d0 mov %edx,%eax
177: c9 leave
178: c3 ret
179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000180 <strchr>:
char *strchr(const char *s, char c) {
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 8b 45 08 mov 0x8(%ebp),%eax
186: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
18a: 0f b6 10 movzbl (%eax),%edx
18d: 84 d2 test %dl,%dl
18f: 75 12 jne 1a3 <strchr+0x23>
191: eb 1d jmp 1b0 <strchr+0x30>
193: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
197: 90 nop
198: 0f b6 50 01 movzbl 0x1(%eax),%edx
19c: 83 c0 01 add $0x1,%eax
19f: 84 d2 test %dl,%dl
1a1: 74 0d je 1b0 <strchr+0x30>
if (*s == c)
1a3: 38 d1 cmp %dl,%cl
1a5: 75 f1 jne 198 <strchr+0x18>
return (char *)s;
return 0;
}
1a7: 5d pop %ebp
1a8: c3 ret
1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
1b0: 31 c0 xor %eax,%eax
}
1b2: 5d pop %ebp
1b3: c3 ret
1b4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1bf: 90 nop
000001c0 <gets>:
char *gets(char *buf, int max) {
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 57 push %edi
1c4: 56 push %esi
int i, cc;
char c;
for (i = 0; i + 1 < max;) {
cc = read(0, &c, 1);
1c5: 8d 7d e7 lea -0x19(%ebp),%edi
char *gets(char *buf, int max) {
1c8: 53 push %ebx
for (i = 0; i + 1 < max;) {
1c9: 31 db xor %ebx,%ebx
char *gets(char *buf, int max) {
1cb: 83 ec 1c sub $0x1c,%esp
for (i = 0; i + 1 < max;) {
1ce: eb 27 jmp 1f7 <gets+0x37>
cc = read(0, &c, 1);
1d0: 83 ec 04 sub $0x4,%esp
1d3: 6a 01 push $0x1
1d5: 57 push %edi
1d6: 6a 00 push $0x0
1d8: e8 4e 01 00 00 call 32b <read>
if (cc < 1)
1dd: 83 c4 10 add $0x10,%esp
1e0: 85 c0 test %eax,%eax
1e2: 7e 1d jle 201 <gets+0x41>
break;
buf[i++] = c;
1e4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1e8: 8b 55 08 mov 0x8(%ebp),%edx
1eb: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if (c == '\n' || c == '\r')
1ef: 3c 0a cmp $0xa,%al
1f1: 74 1d je 210 <gets+0x50>
1f3: 3c 0d cmp $0xd,%al
1f5: 74 19 je 210 <gets+0x50>
for (i = 0; i + 1 < max;) {
1f7: 89 de mov %ebx,%esi
1f9: 83 c3 01 add $0x1,%ebx
1fc: 3b 5d 0c cmp 0xc(%ebp),%ebx
1ff: 7c cf jl 1d0 <gets+0x10>
break;
}
buf[i] = '\0';
201: 8b 45 08 mov 0x8(%ebp),%eax
204: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
208: 8d 65 f4 lea -0xc(%ebp),%esp
20b: 5b pop %ebx
20c: 5e pop %esi
20d: 5f pop %edi
20e: 5d pop %ebp
20f: c3 ret
buf[i] = '\0';
210: 8b 45 08 mov 0x8(%ebp),%eax
213: 89 de mov %ebx,%esi
215: c6 04 30 00 movb $0x0,(%eax,%esi,1)
}
219: 8d 65 f4 lea -0xc(%ebp),%esp
21c: 5b pop %ebx
21d: 5e pop %esi
21e: 5f pop %edi
21f: 5d pop %ebp
220: c3 ret
221: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
228: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
22f: 90 nop
00000230 <stat>:
int stat(const char *n, struct stat *st) {
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 56 push %esi
234: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
235: 83 ec 08 sub $0x8,%esp
238: 6a 00 push $0x0
23a: ff 75 08 push 0x8(%ebp)
23d: e8 11 01 00 00 call 353 <open>
if (fd < 0)
242: 83 c4 10 add $0x10,%esp
245: 85 c0 test %eax,%eax
247: 78 27 js 270 <stat+0x40>
return -1;
r = fstat(fd, st);
249: 83 ec 08 sub $0x8,%esp
24c: ff 75 0c push 0xc(%ebp)
24f: 89 c3 mov %eax,%ebx
251: 50 push %eax
252: e8 14 01 00 00 call 36b <fstat>
close(fd);
257: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
25a: 89 c6 mov %eax,%esi
close(fd);
25c: e8 da 00 00 00 call 33b <close>
return r;
261: 83 c4 10 add $0x10,%esp
}
264: 8d 65 f8 lea -0x8(%ebp),%esp
267: 89 f0 mov %esi,%eax
269: 5b pop %ebx
26a: 5e pop %esi
26b: 5d pop %ebp
26c: c3 ret
26d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
270: be ff ff ff ff mov $0xffffffff,%esi
275: eb ed jmp 264 <stat+0x34>
277: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
27e: 66 90 xchg %ax,%ax
00000280 <atoi>:
int atoi(const char *s) {
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 56 push %esi
284: be 01 00 00 00 mov $0x1,%esi
289: 8b 4d 08 mov 0x8(%ebp),%ecx
28c: 53 push %ebx
i = 0;
sign = 1;
val = 0;
nbr = 0;
if (s[0] == '-') {
28d: 0f b6 11 movzbl (%ecx),%edx
290: 80 fa 2d cmp $0x2d,%dl
293: 75 0c jne 2a1 <atoi+0x21>
sign = -1;
s++;
}
i = 0;
while (s[i] >= '0' && s[i] <= '9' && s[i] != '\0') {
295: 0f b6 51 01 movzbl 0x1(%ecx),%edx
sign = -1;
299: be ff ff ff ff mov $0xffffffff,%esi
s++;
29e: 83 c1 01 add $0x1,%ecx
while (s[i] >= '0' && s[i] <= '9' && s[i] != '\0') {
2a1: 8d 5a d0 lea -0x30(%edx),%ebx
2a4: 80 fb 09 cmp $0x9,%bl
2a7: 77 2f ja 2d8 <atoi+0x58>
2a9: 83 c1 01 add $0x1,%ecx
val = 0;
2ac: 31 db xor %ebx,%ebx
2ae: 66 90 xchg %ax,%ax
nbr = (int)(s[i] - '0');
2b0: 83 ea 30 sub $0x30,%edx
val = (val * 10) + nbr;
2b3: 8d 1c 9b lea (%ebx,%ebx,4),%ebx
while (s[i] >= '0' && s[i] <= '9' && s[i] != '\0') {
2b6: 83 c1 01 add $0x1,%ecx
nbr = (int)(s[i] - '0');
2b9: 0f be d2 movsbl %dl,%edx
val = (val * 10) + nbr;
2bc: 8d 1c 5a lea (%edx,%ebx,2),%ebx
while (s[i] >= '0' && s[i] <= '9' && s[i] != '\0') {
2bf: 0f b6 51 ff movzbl -0x1(%ecx),%edx
2c3: 8d 42 d0 lea -0x30(%edx),%eax
2c6: 3c 09 cmp $0x9,%al
2c8: 76 e6 jbe 2b0 <atoi+0x30>
i++;
}
i++;
return (val * sign);
2ca: 89 f0 mov %esi,%eax
2cc: 0f af c3 imul %ebx,%eax
}
2cf: 5b pop %ebx
2d0: 5e pop %esi
2d1: 5d pop %ebp
2d2: c3 ret
2d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2d7: 90 nop
2d8: 5b pop %ebx
while (s[i] >= '0' && s[i] <= '9' && s[i] != '\0') {
2d9: 31 c0 xor %eax,%eax
}
2db: 5e pop %esi
2dc: 5d pop %ebp
2dd: c3 ret
2de: 66 90 xchg %ax,%ax
000002e0 <memmove>:
void *memmove(void *vdst, const void *vsrc, int n) {
2e0: 55 push %ebp
2e1: 89 e5 mov %esp,%ebp
2e3: 57 push %edi
2e4: 8b 45 10 mov 0x10(%ebp),%eax
2e7: 8b 55 08 mov 0x8(%ebp),%edx
2ea: 56 push %esi
2eb: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while (n-- > 0)
2ee: 85 c0 test %eax,%eax
2f0: 7e 13 jle 305 <memmove+0x25>
2f2: 01 d0 add %edx,%eax
dst = vdst;
2f4: 89 d7 mov %edx,%edi
2f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
2fd: 8d 76 00 lea 0x0(%esi),%esi
*dst++ = *src++;
300: a4 movsb %ds:(%esi),%es:(%edi)
while (n-- > 0)
301: 39 f8 cmp %edi,%eax
303: 75 fb jne 300 <memmove+0x20>
return vdst;
}
305: 5e pop %esi
306: 89 d0 mov %edx,%eax
308: 5f pop %edi
309: 5d pop %ebp
30a: c3 ret
0000030b <fork>:
SYSCALL(fork)
30b: b8 01 00 00 00 mov $0x1,%eax
310: cd 40 int $0x40
312: c3 ret
00000313 <exit>:
SYSCALL(exit)
313: b8 02 00 00 00 mov $0x2,%eax
318: cd 40 int $0x40
31a: c3 ret
0000031b <wait>:
SYSCALL(wait)
31b: b8 03 00 00 00 mov $0x3,%eax
320: cd 40 int $0x40
322: c3 ret
00000323 <pipe>:
SYSCALL(pipe)
323: b8 04 00 00 00 mov $0x4,%eax
328: cd 40 int $0x40
32a: c3 ret
0000032b <read>:
SYSCALL(read)
32b: b8 05 00 00 00 mov $0x5,%eax
330: cd 40 int $0x40
332: c3 ret
00000333 <write>:
SYSCALL(write)
333: b8 10 00 00 00 mov $0x10,%eax
338: cd 40 int $0x40
33a: c3 ret
0000033b <close>:
SYSCALL(close)
33b: b8 15 00 00 00 mov $0x15,%eax
340: cd 40 int $0x40
342: c3 ret
00000343 <kill>:
SYSCALL(kill)
343: b8 06 00 00 00 mov $0x6,%eax
348: cd 40 int $0x40
34a: c3 ret
0000034b <exec>:
SYSCALL(exec)
34b: b8 07 00 00 00 mov $0x7,%eax
350: cd 40 int $0x40
352: c3 ret
00000353 <open>:
SYSCALL(open)
353: b8 0f 00 00 00 mov $0xf,%eax
358: cd 40 int $0x40
35a: c3 ret
0000035b <mknod>:
SYSCALL(mknod)
35b: b8 11 00 00 00 mov $0x11,%eax
360: cd 40 int $0x40
362: c3 ret
00000363 <unlink>:
SYSCALL(unlink)
363: b8 12 00 00 00 mov $0x12,%eax
368: cd 40 int $0x40
36a: c3 ret
0000036b <fstat>:
SYSCALL(fstat)
36b: b8 08 00 00 00 mov $0x8,%eax
370: cd 40 int $0x40
372: c3 ret
00000373 <link>:
SYSCALL(link)
373: b8 13 00 00 00 mov $0x13,%eax
378: cd 40 int $0x40
37a: c3 ret
0000037b <mkdir>:
SYSCALL(mkdir)
37b: b8 14 00 00 00 mov $0x14,%eax
380: cd 40 int $0x40
382: c3 ret
00000383 <chdir>:
SYSCALL(chdir)
383: b8 09 00 00 00 mov $0x9,%eax
388: cd 40 int $0x40
38a: c3 ret
0000038b <dup>:
SYSCALL(dup)
38b: b8 0a 00 00 00 mov $0xa,%eax
390: cd 40 int $0x40
392: c3 ret
00000393 <getpid>:
SYSCALL(getpid)
393: b8 0b 00 00 00 mov $0xb,%eax
398: cd 40 int $0x40
39a: c3 ret
0000039b <sbrk>:
SYSCALL(sbrk)
39b: b8 0c 00 00 00 mov $0xc,%eax
3a0: cd 40 int $0x40
3a2: c3 ret
000003a3 <sleep>:
SYSCALL(sleep)
3a3: b8 0d 00 00 00 mov $0xd,%eax
3a8: cd 40 int $0x40
3aa: c3 ret
000003ab <uptime>:
SYSCALL(uptime)
3ab: b8 0e 00 00 00 mov $0xe,%eax
3b0: cd 40 int $0x40
3b2: c3 ret
000003b3 <shutdown>:
#SYSCALL(dup)
#SYSCALL(getpid)
#SYSCALL(sbrk)
#SYSCALL(sleep)
#SYSCALL(uptime)
SYSCALL(shutdown)
3b3: b8 16 00 00 00 mov $0x16,%eax
3b8: cd 40 int $0x40
3ba: c3 ret
000003bb <incr>:
SYSCALL(incr)
3bb: b8 17 00 00 00 mov $0x17,%eax
3c0: cd 40 int $0x40
3c2: c3 ret
000003c3 <add>:
SYSCALL(add)
3c3: b8 18 00 00 00 mov $0x18,%eax
3c8: cd 40 int $0x40
3ca: c3 ret
000003cb <mult>:
SYSCALL(mult)
3cb: b8 19 00 00 00 mov $0x19,%eax
3d0: cd 40 int $0x40
3d2: c3 ret
000003d3 <div>:
SYSCALL(div)
3d3: b8 1a 00 00 00 mov $0x1a,%eax
3d8: cd 40 int $0x40
3da: c3 ret
000003db <mod>:
SYSCALL(mod)
3db: b8 1b 00 00 00 mov $0x1b,%eax
3e0: cd 40 int $0x40
3e2: c3 ret
3e3: 66 90 xchg %ax,%ax
3e5: 66 90 xchg %ax,%ax
3e7: 66 90 xchg %ax,%ax
3e9: 66 90 xchg %ax,%ax
3eb: 66 90 xchg %ax,%ax
3ed: 66 90 xchg %ax,%ax
3ef: 90 nop
000003f0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 57 push %edi
3f4: 56 push %esi
3f5: 53 push %ebx
3f6: 83 ec 3c sub $0x3c,%esp
3f9: 89 4d c4 mov %ecx,-0x3c(%ebp)
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
3fc: 89 d1 mov %edx,%ecx
{
3fe: 89 45 b8 mov %eax,-0x48(%ebp)
if(sgn && xx < 0){
401: 85 d2 test %edx,%edx
403: 0f 89 7f 00 00 00 jns 488 <printint+0x98>
409: f6 45 08 01 testb $0x1,0x8(%ebp)
40d: 74 79 je 488 <printint+0x98>
neg = 1;
40f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
x = -xx;
416: f7 d9 neg %ecx
} else {
x = xx;
}
i = 0;
418: 31 db xor %ebx,%ebx
41a: 8d 75 d7 lea -0x29(%ebp),%esi
41d: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
420: 89 c8 mov %ecx,%eax
422: 31 d2 xor %edx,%edx
424: 89 cf mov %ecx,%edi
426: f7 75 c4 divl -0x3c(%ebp)
429: 0f b6 92 44 08 00 00 movzbl 0x844(%edx),%edx
430: 89 45 c0 mov %eax,-0x40(%ebp)
433: 89 d8 mov %ebx,%eax
435: 8d 5b 01 lea 0x1(%ebx),%ebx
}while((x /= base) != 0);
438: 8b 4d c0 mov -0x40(%ebp),%ecx
buf[i++] = digits[x % base];
43b: 88 14 1e mov %dl,(%esi,%ebx,1)
}while((x /= base) != 0);
43e: 39 7d c4 cmp %edi,-0x3c(%ebp)
441: 76 dd jbe 420 <printint+0x30>
if(neg)
443: 8b 4d bc mov -0x44(%ebp),%ecx
446: 85 c9 test %ecx,%ecx
448: 74 0c je 456 <printint+0x66>
buf[i++] = '-';
44a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
buf[i++] = digits[x % base];
44f: 89 d8 mov %ebx,%eax
buf[i++] = '-';
451: ba 2d 00 00 00 mov $0x2d,%edx
while(--i >= 0)
456: 8b 7d b8 mov -0x48(%ebp),%edi
459: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
45d: eb 07 jmp 466 <printint+0x76>
45f: 90 nop
putc(fd, buf[i]);
460: 0f b6 13 movzbl (%ebx),%edx
463: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
466: 83 ec 04 sub $0x4,%esp
469: 88 55 d7 mov %dl,-0x29(%ebp)
46c: 6a 01 push $0x1
46e: 56 push %esi
46f: 57 push %edi
470: e8 be fe ff ff call 333 <write>
while(--i >= 0)
475: 83 c4 10 add $0x10,%esp
478: 39 de cmp %ebx,%esi
47a: 75 e4 jne 460 <printint+0x70>
}
47c: 8d 65 f4 lea -0xc(%ebp),%esp
47f: 5b pop %ebx
480: 5e pop %esi
481: 5f pop %edi
482: 5d pop %ebp
483: c3 ret
484: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
488: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
48f: eb 87 jmp 418 <printint+0x28>
491: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
498: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
49f: 90 nop
000004a0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
4a0: 55 push %ebp
4a1: 89 e5 mov %esp,%ebp
4a3: 57 push %edi
4a4: 56 push %esi
4a5: 53 push %ebx
4a6: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4a9: 8b 5d 0c mov 0xc(%ebp),%ebx
{
4ac: 8b 75 08 mov 0x8(%ebp),%esi
for(i = 0; fmt[i]; i++){
4af: 0f b6 13 movzbl (%ebx),%edx
4b2: 84 d2 test %dl,%dl
4b4: 74 6a je 520 <printf+0x80>
ap = (uint*)(void*)&fmt + 1;
4b6: 8d 45 10 lea 0x10(%ebp),%eax
4b9: 83 c3 01 add $0x1,%ebx
write(fd, &c, 1);
4bc: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
4bf: 31 c9 xor %ecx,%ecx
ap = (uint*)(void*)&fmt + 1;
4c1: 89 45 d0 mov %eax,-0x30(%ebp)
4c4: eb 36 jmp 4fc <printf+0x5c>
4c6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4cd: 8d 76 00 lea 0x0(%esi),%esi
4d0: 89 4d d4 mov %ecx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
4d3: b9 25 00 00 00 mov $0x25,%ecx
if(c == '%'){
4d8: 83 f8 25 cmp $0x25,%eax
4db: 74 15 je 4f2 <printf+0x52>
write(fd, &c, 1);
4dd: 83 ec 04 sub $0x4,%esp
4e0: 88 55 e7 mov %dl,-0x19(%ebp)
4e3: 6a 01 push $0x1
4e5: 57 push %edi
4e6: 56 push %esi
4e7: e8 47 fe ff ff call 333 <write>
4ec: 8b 4d d4 mov -0x2c(%ebp),%ecx
} else {
putc(fd, c);
4ef: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4f2: 0f b6 13 movzbl (%ebx),%edx
4f5: 83 c3 01 add $0x1,%ebx
4f8: 84 d2 test %dl,%dl
4fa: 74 24 je 520 <printf+0x80>
c = fmt[i] & 0xff;
4fc: 0f b6 c2 movzbl %dl,%eax
if(state == 0){
4ff: 85 c9 test %ecx,%ecx
501: 74 cd je 4d0 <printf+0x30>
}
} else if(state == '%'){
503: 83 f9 25 cmp $0x25,%ecx
506: 75 ea jne 4f2 <printf+0x52>
if(c == 'd'){
508: 83 f8 25 cmp $0x25,%eax
50b: 0f 84 07 01 00 00 je 618 <printf+0x178>
511: 83 e8 63 sub $0x63,%eax
514: 83 f8 15 cmp $0x15,%eax
517: 77 17 ja 530 <printf+0x90>
519: ff 24 85 ec 07 00 00 jmp *0x7ec(,%eax,4)
putc(fd, c);
}
state = 0;
}
}
}
520: 8d 65 f4 lea -0xc(%ebp),%esp
523: 5b pop %ebx
524: 5e pop %esi
525: 5f pop %edi
526: 5d pop %ebp
527: c3 ret
528: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
52f: 90 nop
write(fd, &c, 1);
530: 83 ec 04 sub $0x4,%esp
533: 88 55 d4 mov %dl,-0x2c(%ebp)
536: 6a 01 push $0x1
538: 57 push %edi
539: 56 push %esi
53a: c6 45 e7 25 movb $0x25,-0x19(%ebp)
53e: e8 f0 fd ff ff call 333 <write>
putc(fd, c);
543: 0f b6 55 d4 movzbl -0x2c(%ebp),%edx
write(fd, &c, 1);
547: 83 c4 0c add $0xc,%esp
54a: 88 55 e7 mov %dl,-0x19(%ebp)
54d: 6a 01 push $0x1
54f: 57 push %edi
550: 56 push %esi
551: e8 dd fd ff ff call 333 <write>
putc(fd, c);
556: 83 c4 10 add $0x10,%esp
state = 0;
559: 31 c9 xor %ecx,%ecx
55b: eb 95 jmp 4f2 <printf+0x52>
55d: 8d 76 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
560: 83 ec 0c sub $0xc,%esp
563: b9 10 00 00 00 mov $0x10,%ecx
568: 6a 00 push $0x0
56a: 8b 45 d0 mov -0x30(%ebp),%eax
56d: 8b 10 mov (%eax),%edx
56f: 89 f0 mov %esi,%eax
571: e8 7a fe ff ff call 3f0 <printint>
ap++;
576: 83 45 d0 04 addl $0x4,-0x30(%ebp)
57a: 83 c4 10 add $0x10,%esp
state = 0;
57d: 31 c9 xor %ecx,%ecx
57f: e9 6e ff ff ff jmp 4f2 <printf+0x52>
584: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
588: 8b 45 d0 mov -0x30(%ebp),%eax
58b: 8b 10 mov (%eax),%edx
ap++;
58d: 83 c0 04 add $0x4,%eax
590: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
593: 85 d2 test %edx,%edx
595: 0f 84 8d 00 00 00 je 628 <printf+0x188>
while(*s != 0){
59b: 0f b6 02 movzbl (%edx),%eax
state = 0;
59e: 31 c9 xor %ecx,%ecx
while(*s != 0){
5a0: 84 c0 test %al,%al
5a2: 0f 84 4a ff ff ff je 4f2 <printf+0x52>
5a8: 89 5d d4 mov %ebx,-0x2c(%ebp)
5ab: 89 d3 mov %edx,%ebx
5ad: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
5b0: 83 ec 04 sub $0x4,%esp
s++;
5b3: 83 c3 01 add $0x1,%ebx
5b6: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
5b9: 6a 01 push $0x1
5bb: 57 push %edi
5bc: 56 push %esi
5bd: e8 71 fd ff ff call 333 <write>
while(*s != 0){
5c2: 0f b6 03 movzbl (%ebx),%eax
5c5: 83 c4 10 add $0x10,%esp
5c8: 84 c0 test %al,%al
5ca: 75 e4 jne 5b0 <printf+0x110>
state = 0;
5cc: 8b 5d d4 mov -0x2c(%ebp),%ebx
5cf: 31 c9 xor %ecx,%ecx
5d1: e9 1c ff ff ff jmp 4f2 <printf+0x52>
5d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5dd: 8d 76 00 lea 0x0(%esi),%esi
printint(fd, *ap, 10, 1);
5e0: 83 ec 0c sub $0xc,%esp
5e3: b9 0a 00 00 00 mov $0xa,%ecx
5e8: 6a 01 push $0x1
5ea: e9 7b ff ff ff jmp 56a <printf+0xca>
5ef: 90 nop
putc(fd, *ap);
5f0: 8b 45 d0 mov -0x30(%ebp),%eax
write(fd, &c, 1);
5f3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5f6: 8b 00 mov (%eax),%eax
write(fd, &c, 1);
5f8: 6a 01 push $0x1
5fa: 57 push %edi
5fb: 56 push %esi
putc(fd, *ap);
5fc: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
5ff: e8 2f fd ff ff call 333 <write>
ap++;
604: 83 45 d0 04 addl $0x4,-0x30(%ebp)
608: 83 c4 10 add $0x10,%esp
state = 0;
60b: 31 c9 xor %ecx,%ecx
60d: e9 e0 fe ff ff jmp 4f2 <printf+0x52>
612: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
putc(fd, c);
618: 88 55 e7 mov %dl,-0x19(%ebp)
write(fd, &c, 1);
61b: 83 ec 04 sub $0x4,%esp
61e: e9 2a ff ff ff jmp 54d <printf+0xad>
623: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
627: 90 nop
s = "(null)";
628: ba e3 07 00 00 mov $0x7e3,%edx
while(*s != 0){
62d: 89 5d d4 mov %ebx,-0x2c(%ebp)
630: b8 28 00 00 00 mov $0x28,%eax
635: 89 d3 mov %edx,%ebx
637: e9 74 ff ff ff jmp 5b0 <printf+0x110>
63c: 66 90 xchg %ax,%ax
63e: 66 90 xchg %ax,%ax
00000640 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
640: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
641: a1 08 0b 00 00 mov 0xb08,%eax
{
646: 89 e5 mov %esp,%ebp
648: 57 push %edi
649: 56 push %esi
64a: 53 push %ebx
64b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
64e: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
651: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
658: 89 c2 mov %eax,%edx
65a: 8b 00 mov (%eax),%eax
65c: 39 ca cmp %ecx,%edx
65e: 73 30 jae 690 <free+0x50>
660: 39 c1 cmp %eax,%ecx
662: 72 04 jb 668 <free+0x28>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
664: 39 c2 cmp %eax,%edx
666: 72 f0 jb 658 <free+0x18>
break;
if(bp + bp->s.size == p->s.ptr){
668: 8b 73 fc mov -0x4(%ebx),%esi
66b: 8d 3c f1 lea (%ecx,%esi,8),%edi
66e: 39 f8 cmp %edi,%eax
670: 74 30 je 6a2 <free+0x62>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
672: 89 43 f8 mov %eax,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
675: 8b 42 04 mov 0x4(%edx),%eax
678: 8d 34 c2 lea (%edx,%eax,8),%esi
67b: 39 f1 cmp %esi,%ecx
67d: 74 3a je 6b9 <free+0x79>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
67f: 89 0a mov %ecx,(%edx)
} else
p->s.ptr = bp;
freep = p;
}
681: 5b pop %ebx
freep = p;
682: 89 15 08 0b 00 00 mov %edx,0xb08
}
688: 5e pop %esi
689: 5f pop %edi
68a: 5d pop %ebp
68b: c3 ret
68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
690: 39 c2 cmp %eax,%edx
692: 72 c4 jb 658 <free+0x18>
694: 39 c1 cmp %eax,%ecx
696: 73 c0 jae 658 <free+0x18>
if(bp + bp->s.size == p->s.ptr){
698: 8b 73 fc mov -0x4(%ebx),%esi
69b: 8d 3c f1 lea (%ecx,%esi,8),%edi
69e: 39 f8 cmp %edi,%eax
6a0: 75 d0 jne 672 <free+0x32>
bp->s.size += p->s.ptr->s.size;
6a2: 03 70 04 add 0x4(%eax),%esi
6a5: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6a8: 8b 02 mov (%edx),%eax
6aa: 8b 00 mov (%eax),%eax
6ac: 89 43 f8 mov %eax,-0x8(%ebx)
if(p + p->s.size == bp){
6af: 8b 42 04 mov 0x4(%edx),%eax
6b2: 8d 34 c2 lea (%edx,%eax,8),%esi
6b5: 39 f1 cmp %esi,%ecx
6b7: 75 c6 jne 67f <free+0x3f>
p->s.size += bp->s.size;
6b9: 03 43 fc add -0x4(%ebx),%eax
freep = p;
6bc: 89 15 08 0b 00 00 mov %edx,0xb08
p->s.size += bp->s.size;
6c2: 89 42 04 mov %eax,0x4(%edx)
p->s.ptr = bp->s.ptr;
6c5: 8b 4b f8 mov -0x8(%ebx),%ecx
6c8: 89 0a mov %ecx,(%edx)
}
6ca: 5b pop %ebx
6cb: 5e pop %esi
6cc: 5f pop %edi
6cd: 5d pop %ebp
6ce: c3 ret
6cf: 90 nop
000006d0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
6d0: 55 push %ebp
6d1: 89 e5 mov %esp,%ebp
6d3: 57 push %edi
6d4: 56 push %esi
6d5: 53 push %ebx
6d6: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6d9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
6dc: 8b 3d 08 0b 00 00 mov 0xb08,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6e2: 8d 70 07 lea 0x7(%eax),%esi
6e5: c1 ee 03 shr $0x3,%esi
6e8: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
6eb: 85 ff test %edi,%edi
6ed: 0f 84 9d 00 00 00 je 790 <malloc+0xc0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6f3: 8b 17 mov (%edi),%edx
if(p->s.size >= nunits){
6f5: 8b 4a 04 mov 0x4(%edx),%ecx
6f8: 39 f1 cmp %esi,%ecx
6fa: 73 6a jae 766 <malloc+0x96>
6fc: bb 00 10 00 00 mov $0x1000,%ebx
701: 39 de cmp %ebx,%esi
703: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
706: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
70d: 89 45 e4 mov %eax,-0x1c(%ebp)
710: eb 17 jmp 729 <malloc+0x59>
712: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
718: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
71a: 8b 48 04 mov 0x4(%eax),%ecx
71d: 39 f1 cmp %esi,%ecx
71f: 73 4f jae 770 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
721: 8b 3d 08 0b 00 00 mov 0xb08,%edi
727: 89 c2 mov %eax,%edx
729: 39 d7 cmp %edx,%edi
72b: 75 eb jne 718 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
72d: 83 ec 0c sub $0xc,%esp
730: ff 75 e4 push -0x1c(%ebp)
733: e8 63 fc ff ff call 39b <sbrk>
if(p == (char*)-1)
738: 83 c4 10 add $0x10,%esp
73b: 83 f8 ff cmp $0xffffffff,%eax
73e: 74 1c je 75c <malloc+0x8c>
hp->s.size = nu;
740: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
743: 83 ec 0c sub $0xc,%esp
746: 83 c0 08 add $0x8,%eax
749: 50 push %eax
74a: e8 f1 fe ff ff call 640 <free>
return freep;
74f: 8b 15 08 0b 00 00 mov 0xb08,%edx
if((p = morecore(nunits)) == 0)
755: 83 c4 10 add $0x10,%esp
758: 85 d2 test %edx,%edx
75a: 75 bc jne 718 <malloc+0x48>
return 0;
}
}
75c: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
75f: 31 c0 xor %eax,%eax
}
761: 5b pop %ebx
762: 5e pop %esi
763: 5f pop %edi
764: 5d pop %ebp
765: c3 ret
if(p->s.size >= nunits){
766: 89 d0 mov %edx,%eax
768: 89 fa mov %edi,%edx
76a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
770: 39 ce cmp %ecx,%esi
772: 74 4c je 7c0 <malloc+0xf0>
p->s.size -= nunits;
774: 29 f1 sub %esi,%ecx
776: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
779: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
77c: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
77f: 89 15 08 0b 00 00 mov %edx,0xb08
}
785: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
788: 83 c0 08 add $0x8,%eax
}
78b: 5b pop %ebx
78c: 5e pop %esi
78d: 5f pop %edi
78e: 5d pop %ebp
78f: c3 ret
base.s.ptr = freep = prevp = &base;
790: c7 05 08 0b 00 00 0c movl $0xb0c,0xb08
797: 0b 00 00
base.s.size = 0;
79a: bf 0c 0b 00 00 mov $0xb0c,%edi
base.s.ptr = freep = prevp = &base;
79f: c7 05 0c 0b 00 00 0c movl $0xb0c,0xb0c
7a6: 0b 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7a9: 89 fa mov %edi,%edx
base.s.size = 0;
7ab: c7 05 10 0b 00 00 00 movl $0x0,0xb10
7b2: 00 00 00
if(p->s.size >= nunits){
7b5: e9 42 ff ff ff jmp 6fc <malloc+0x2c>
7ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
7c0: 8b 08 mov (%eax),%ecx
7c2: 89 0a mov %ecx,(%edx)
7c4: eb b9 jmp 77f <malloc+0xaf>
|
oeis/172/A172510.asm | neoneye/loda-programs | 11 | 20647 | <filename>oeis/172/A172510.asm
; A172510: a(n) = binomial(n + 4, 4) * 8^n.
; 1,40,960,17920,286720,4128768,55050240,692060160,8304721920,95965675520,1074815565824,11725260718080,125069447659520,1308418837053440,13458022323978240,136374626216312832,1363746262163128320,13477021884906209280,131775325096860712960,1276139990411703746560,12250943907952355966976,116675656266212913971200,1103115295607831186636800,10359691471795284187545600,96690453736755985750425600,897287410677095547763949568,8282653021634728133205688320,76077701828348613964259655680
mov $1,8
pow $1,$0
mov $2,$0
add $2,4
bin $2,$0
mul $1,$2
mov $0,$1
|
libsrc/_DEVELOPMENT/math/float/am9511/c/sccz80/cam32_sccz80_log10.asm | ahjelm/z88dk | 640 | 244504 |
SECTION code_fp_am9511
PUBLIC cam32_sccz80_log10
EXTERN asm_am9511_log10_fastcall
defc cam32_sccz80_log10 = asm_am9511_log10_fastcall
|
tools/tck-api/src/main/resources/FeatureResults.g4 | fickludd/openCypher | 0 | 4932 | <reponame>fickludd/openCypher<filename>tools/tck-api/src/main/resources/FeatureResults.g4<gh_stars>0
/*
* Copyright (c) 2015-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* 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.
*
* Attribution Notice under the terms of the Apache License 2.0
*
* This work was created by the collective efforts of the openCypher community.
* Without limiting the terms of Section 6, any Derivative Work that is not
* approved by the public consensus process of the openCypher Implementers Group
* should not be described as “Cypher” (and Cypher® is a registered trademark of
* Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
* proposals for change that have been documented or implemented should only be
* described as "implementation extensions to Cypher" or as "proposed changes to
* Cypher that are not yet approved by the openCypher community".
*/
grammar FeatureResults;
value : node
| relationship
| path
| integer
| floatingPoint
| string
| bool
| nullValue
| list
| map
;
node : nodeDesc ;
nodeDesc : '(' (label)* WS? (propertyMap)? ')' ;
relationship : relationshipDesc ;
relationshipDesc : '[' relationshipType WS? (propertyMap)? ']' ;
path : '<' pathBody '>' ;
pathBody : nodeDesc (pathLink)* ;
pathLink : (forwardsRelationship | backwardsRelationship) nodeDesc ;
forwardsRelationship : '-' relationshipDesc '->' ;
backwardsRelationship : '<-' relationshipDesc '-' ;
integer : INTEGER_LITERAL ;
floatingPoint : FLOAT_LITERAL
| INFINITY ;
bool : 'true'
| 'false'
;
nullValue : 'null' ;
list : '[' (listContents)? ']' ;
listContents : listElement (', ' listElement)* ;
listElement : value ;
map : propertyMap ;
propertyMap : '{' (mapContents)? '}' ;
mapContents : keyValuePair (', ' keyValuePair)* ;
keyValuePair: propertyKey ':' WS? propertyValue ;
propertyKey : SYMBOLIC_NAME ;
propertyValue : value ;
relationshipType : ':' relationshipTypeName ;
relationshipTypeName : SYMBOLIC_NAME ;
label : ':' labelName ;
labelName : SYMBOLIC_NAME ;
INTEGER_LITERAL : ('-')? DECIMAL_LITERAL ;
DECIMAL_LITERAL : '0'
| NONZERODIGIT DIGIT*
;
DIGIT : '0'
| NONZERODIGIT
;
NONZERODIGIT : [1-9] ;
INFINITY : '-'? 'Inf' ;
FLOAT_LITERAL : '-'? FLOAT_REPR ;
FLOAT_REPR : DIGIT+ '.' DIGIT+ EXPONENTPART?
| '.' DIGIT+ EXPONENTPART?
| DIGIT EXPONENTPART
| DIGIT+ EXPONENTPART?
;
EXPONENTPART : ('E' | 'e') ('+' | '-')? DIGIT+ ;
SYMBOLIC_NAME : IDENTIFIER ;
WS : ' ' ;
IDENTIFIER : [a-zA-Z0-9$_]+ ;
// The string rule should ideally not include the apostrophes in the parsed value,
// but a lexer rule may not match the empty string, so I haven't found a way
// to define that quite well yet.
string : STRING_LITERAL ;
STRING_LITERAL : '\'' STRING_BODY* '\'' ;
STRING_BODY : '\u0000' .. '\u0026' // \u0027 is the string delimiter character (')
| '\u0028' .. '\u01FF'
| ESCAPED_APOSTROPHE
;
ESCAPED_APOSTROPHE : '\\\'' ;
|
src/event_device.ads | onox/evdev-ada | 2 | 15155 | <reponame>onox/evdev-ada
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Interfaces.C;
private with Ada.Finalization;
package Event_Device is
pragma Pure;
type Unsigned_8 is mod 2 ** 8
with Size => 8;
type Unsigned_16 is mod 2 ** 16
with Size => 16;
function Hex_Image (Value : Unsigned_8) return String;
function Hex_Image (Value : Unsigned_16) return String;
type Device_ID is record
Bus, Vendor, Product, Version : Unsigned_16;
end record
with Convention => C_Pass_By_Copy;
function GUID (ID : Device_ID) return String;
type Axis_Info is record
Value, Minimum, Maximum, Fuzz, Flat, Resolution : Integer;
end record
with Convention => C_Pass_By_Copy;
type Event_Kind is
(Synchronization,
Key,
Relative,
Absolute,
Miscellaneous,
Switch,
LED,
Sound,
Repeat,
Force_Feedback,
Power,
Feedback_Status);
type Synchronization_Kind is (Report, Config, MT_Report, Dropped);
type Key_Info_Kind is
(Button_South,
Button_East,
Button_North,
Button_West,
Button_Trigger_Left_1,
Button_Trigger_Right_1,
Button_Trigger_Left_2,
Button_Trigger_Right_2,
Button_Select,
Button_Start,
Button_Mode,
Button_Thumb_Left,
Button_Thumb_Right);
type Key_Kind is new Key_Info_Kind;
type Relative_Axis_Info_Kind is
(X,
Y,
Z,
Rx,
Ry,
Rz,
Horizontal_Wheel,
Diagonal,
Wheel,
Misc,
Wheel_High_Res,
Horizontal_Wheel_High_Res);
type Relative_Axis_Kind is new Relative_Axis_Info_Kind;
type Absolute_Axis_Info_Kind is
(X,
Y,
Z,
Rx,
Ry,
Rz,
Throttle,
Rudder,
Wheel,
Gas,
Brake,
Hat_0X,
Hat_0Y,
Hat_1X,
Hat_1Y,
Hat_2X,
Hat_2Y,
Hat_3X,
Hat_3Y,
Pressure,
Distance,
Tilt_X,
Tilt_Y,
Tool_Width,
Volume,
Misc,
MT_Slot,
MT_Touch_Major,
MT_Touch_Minor,
MT_Width_Major,
MT_Width_Minor,
MT_Orientation,
MT_Position_X,
MT_Position_Y,
MT_Tool_Type,
MT_Blob_ID,
MT_Tracking_ID,
MT_Pressure,
MT_Distance,
MT_Tool_X,
MT_Tool_Y);
type Absolute_Axis_Kind is new Absolute_Axis_Info_Kind;
type Switch_Kind is
(Lid,
Tablet_Mode,
Headphone_Insert,
Rfkill_all,
Microphone_Insert,
Dock,
Lineout_Insert,
Jack_Physical_Insert,
Video_Out_Insert,
Camera_Lens_Cover,
Keypad_Slide,
Front_Proximity,
Rotate_Lock,
Line_In_Insert,
Mute_Device,
Pen_Inserted,
Machine_Cover);
type Miscellaneous_Kind is (Serial, Pulse_LED, Gesture, Raw, Scan, Timestamp);
type LED_Kind is
(Num_Lock, Caps_Lock, Scroll_Lock, Compose, Kana, Sleep, Suspend, Mute, Misc, Mail, Charging);
type Repeat_Kind is (Repeat_Delay, Repeat_Period);
type Sound_Kind is (Click, Bell, Tone);
type Force_Feedback_Kind is
(Rumble,
Periodic,
Constant_V,
Spring,
Friction,
Damper,
Inertia,
Ramp,
Square,
Triangle,
Sine,
Saw_Up,
Saw_Down,
Custom,
Gain,
Auto_Center);
type Synchronization_Features is array (Synchronization_Kind) of Boolean
with Component_Size => 1;
type Key_Features is array (Key_Kind) of Boolean
with Component_Size => 1;
type Relative_Axis_Features is array (Relative_Axis_Kind) of Boolean
with Component_Size => 1;
type Absolute_Axis_Features is array (Absolute_Axis_Kind) of Boolean
with Component_Size => 1;
type Switch_Features is array (Switch_Kind) of Boolean
with Component_Size => 1;
type Miscellaneous_Features is array (Miscellaneous_Kind) of Boolean
with Component_Size => 1;
type LED_Features is array (LED_Kind) of Boolean
with Component_Size => 1;
type Repeat_Features is array (Repeat_Kind) of Boolean
with Component_Size => 1;
type Sound_Features is array (Sound_Kind) of Boolean
with Component_Size => 1;
type Force_Feedback_Features is array (Force_Feedback_Kind) of Boolean
with Component_Size => 1;
type Device_Properties is record
Pointer : Boolean := False;
Direct : Boolean := False;
Button_Pad : Boolean := False;
Semi_Multi_Touch : Boolean := False;
Top_Button_Pad : Boolean := False;
Pointing_Stick : Boolean := False;
Accelerometer : Boolean := False;
end record;
type Device_Events is record
Synchronization : Boolean := False;
Keys : Boolean := False;
Relative_Axes : Boolean := False;
Absolute_Axes : Boolean := False;
Miscellaneous : Boolean := False;
Switches : Boolean := False;
LEDs : Boolean := False;
Sound : Boolean := False;
Repeat : Boolean := False;
Force_Feedback : Boolean := False;
Power : Boolean := False;
Feedback_Status : Boolean := False;
end record;
----------------------------------------------------------------------------
type Input_Device is tagged limited private;
function Name (Object : Input_Device) return String
with Pre => Object.Is_Open;
function ID (Object : Input_Device) return Device_ID
with Pre => Object.Is_Open;
function Location (Object : Input_Device) return String
with Pre => Object.Is_Open;
function Unique_ID (Object : Input_Device) return String
with Pre => Object.Is_Open;
----------------------------------------------------------------------------
type Key_State is (Released, Pressed);
type Key_Values is array (Key_Kind) of Key_State;
type Relative_Axis_Values is array (Relative_Axis_Kind) of Integer;
type Absolute_Axis_Values is array (Absolute_Axis_Kind) of Integer;
type State is record
Keys : Key_Values := (others => Released);
Relative : Relative_Axis_Values := (others => 0);
Absolute : Absolute_Axis_Values := (others => 0);
Time : Duration := 0.0;
end record;
type Read_Result is (Error, Would_Block, OK);
function Read
(Object : Input_Device;
Value : out State) return Read_Result
with Pre => Object.Is_Open;
-- Read keys, relative, and absolute axes of device and return whether
-- reading was successful
--
-- Resolution of accelerometer and gyro axes:
--
-- Accelerometer No accelerometer
-- ------------- --------
-- X/Y/Z: units/g units/mm
-- Rx/Ry/Rz: units/deg/s units/rad
function Axis (Object : Input_Device; Axis : Absolute_Axis_Kind) return Axis_Info
with Pre => Object.Is_Open;
function Key_Statuses (Object : Input_Device) return Key_Features
with Pre => Object.Is_Open;
function LED_Statuses (Object : Input_Device) return LED_Features
with Pre => Object.Is_Open;
function Sound_Statuses (Object : Input_Device) return Sound_Features
with Pre => Object.Is_Open;
function Switch_Statuses (Object : Input_Device) return Switch_Features
with Pre => Object.Is_Open;
----------------------------------------------------------------------------
function Force_Feedback_Effects (Object : Input_Device) return Natural
with Pre => Object.Is_Open;
-- Return the number of concurrent force-feedback effects that
-- the device supports
type Force_Feedback_Gain is delta 0.01 digits 3 range 0.0 .. 1.0;
type Force_Feedback_Auto_Center is delta 0.01 digits 3 range 0.0 .. 1.0;
procedure Set_Force_Feedback_Gain
(Object : Input_Device;
Value : Force_Feedback_Gain);
procedure Set_Force_Feedback_Auto_Center
(Object : Input_Device;
Value : Force_Feedback_Auto_Center);
type Force_Feedback_Effect_ID is range -1 .. 95
with Size => Interfaces.C.short'Size;
subtype Uploaded_Force_Feedback_Effect_ID is Force_Feedback_Effect_ID
range 0 .. Force_Feedback_Effect_ID'Last;
function Play_Force_Feedback_Effect
(Object : Input_Device;
Identifier : Uploaded_Force_Feedback_Effect_ID;
Count : Natural := 1) return Boolean;
-- Play a force feedback effect and return whether playing is successful
----------------------------------------------------------------------------
function Properties (Object : Input_Device) return Device_Properties
with Pre => Object.Is_Open;
function Events (Object : Input_Device) return Device_Events
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Synchronization_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Key_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Relative_Axis_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Absolute_Axis_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Switch_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Miscellaneous_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return LED_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Repeat_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Sound_Features
with Pre => Object.Is_Open;
function Features (Object : Input_Device) return Force_Feedback_Features
with Pre => Object.Is_Open;
----------------------------------------------------------------------------
function Is_Open (Object : Input_Device) return Boolean;
function Open
(Object : in out Input_Device;
File_Name : String;
Blocking : Boolean := True) return Boolean
with Pre => not Object.Is_Open;
procedure Close (Object : in out Input_Device)
with Pre => Object.Is_Open;
private
type File_Descriptor is new Integer;
type Input_Device is limited new Ada.Finalization.Limited_Controlled with record
FD : File_Descriptor := -1;
Open : Boolean := False;
end record;
overriding procedure Finalize (Object : in out Input_Device);
type Unsigned_64 is mod 2 ** 64
with Size => 64;
for Device_Properties use record
Pointer at 0 range 0 .. 0;
Direct at 0 range 1 .. 1;
Button_Pad at 0 range 2 .. 2;
Semi_Multi_Touch at 0 range 3 .. 3;
Top_Button_Pad at 0 range 4 .. 4;
Pointing_Stick at 0 range 5 .. 5;
Accelerometer at 0 range 6 .. 6;
end record;
for Device_Properties'Size use 32;
for Device_Events use record
Synchronization at 0 range 0 .. 0;
Keys at 0 range 1 .. 1;
Relative_Axes at 0 range 2 .. 2;
Absolute_Axes at 0 range 3 .. 3;
Miscellaneous at 0 range 4 .. 4;
Switches at 0 range 5 .. 5;
LEDs at 0 range 17 .. 17;
Sound at 0 range 18 .. 18;
Repeat at 0 range 20 .. 20;
Force_Feedback at 0 range 21 .. 21;
Power at 0 range 22 .. 22;
Feedback_Status at 0 range 23 .. 23;
end record;
for Device_Events'Size use 32;
for Event_Kind use
(Synchronization => 16#00#,
Key => 16#01#,
Relative => 16#02#,
Absolute => 16#03#,
Miscellaneous => 16#04#,
Switch => 16#05#,
LED => 16#11#,
Sound => 16#12#,
Repeat => 16#14#,
Force_Feedback => 16#15#,
Power => 16#16#,
Feedback_Status => 16#17#);
for Event_Kind'Size use Interfaces.C.unsigned_short'Size;
for Synchronization_Kind use
(Report => 0,
Config => 1,
MT_Report => 2,
Dropped => 3);
for Synchronization_Kind'Size use 16;
-- Representation clause for the *_Info_Kind types are needed
-- because of holes in the representation values
for Key_Info_Kind use
(Button_South => 16#130#,
Button_East => 16#131#,
Button_North => 16#133#,
Button_West => 16#134#,
Button_Trigger_Left_1 => 16#136#,
Button_Trigger_Right_1 => 16#137#,
Button_Trigger_Left_2 => 16#138#,
Button_Trigger_Right_2 => 16#139#,
Button_Select => 16#13A#,
Button_Start => 16#13B#,
Button_Mode => 16#13C#,
Button_Thumb_Left => 16#13D#,
Button_Thumb_Right => 16#13E#);
for Key_Info_Kind'Size use 16;
for Key_Kind'Size use Key_Info_Kind'Size;
for Relative_Axis_Info_Kind use
(X => 16#00#,
Y => 16#01#,
Z => 16#02#,
Rx => 16#03#,
Ry => 16#04#,
Rz => 16#05#,
Horizontal_Wheel => 16#06#,
Diagonal => 16#07#,
Wheel => 16#08#,
Misc => 16#09#,
Wheel_High_Res => 16#0B#,
Horizontal_Wheel_High_Res => 16#0C#);
for Relative_Axis_Info_Kind'Size use 16;
for Relative_Axis_Kind'Size use Relative_Axis_Info_Kind'Size;
for Absolute_Axis_Info_Kind use
(X => 16#00#,
Y => 16#01#,
Z => 16#02#,
Rx => 16#03#,
Ry => 16#04#,
Rz => 16#05#,
Throttle => 16#06#,
Rudder => 16#07#,
Wheel => 16#08#,
Gas => 16#09#,
Brake => 16#0A#,
Hat_0X => 16#10#,
Hat_0Y => 16#11#,
Hat_1X => 16#12#,
Hat_1Y => 16#13#,
Hat_2X => 16#14#,
Hat_2Y => 16#15#,
Hat_3X => 16#16#,
Hat_3Y => 16#17#,
Pressure => 16#18#,
Distance => 16#19#,
Tilt_X => 16#1A#,
Tilt_Y => 16#1B#,
Tool_Width => 16#1C#,
Volume => 16#20#,
Misc => 16#28#,
MT_Slot => 16#2F#,
MT_Touch_Major => 16#30#,
MT_Touch_Minor => 16#31#,
MT_Width_Major => 16#32#,
MT_Width_Minor => 16#33#,
MT_Orientation => 16#34#,
MT_Position_X => 16#35#,
MT_Position_Y => 16#36#,
MT_Tool_Type => 16#37#,
MT_Blob_ID => 16#38#,
MT_Tracking_ID => 16#39#,
MT_Pressure => 16#3A#,
MT_Distance => 16#3B#,
MT_Tool_X => 16#3C#,
MT_Tool_Y => 16#3D#);
for Absolute_Axis_Info_Kind'Size use 64;
for Absolute_Axis_Kind'Size use Absolute_Axis_Info_Kind'Size;
for Switch_Kind use
(Lid => 16#00#,
Tablet_Mode => 16#01#,
Headphone_Insert => 16#02#,
Rfkill_all => 16#03#,
Microphone_Insert => 16#04#,
Dock => 16#05#,
Lineout_Insert => 16#06#,
Jack_Physical_Insert => 16#07#,
Video_Out_Insert => 16#08#,
Camera_Lens_Cover => 16#09#,
Keypad_Slide => 16#0A#,
Front_Proximity => 16#0B#,
Rotate_Lock => 16#0C#,
Line_In_Insert => 16#0D#,
Mute_Device => 16#0E#,
Pen_Inserted => 16#0F#,
Machine_Cover => 16#10#);
for Switch_Kind'Size use 17;
for Miscellaneous_Kind use
(Serial => 16#00#,
Pulse_LED => 16#01#,
Gesture => 16#02#,
Raw => 16#03#,
Scan => 16#04#,
Timestamp => 16#05#);
for Miscellaneous_Kind'Size use 8;
for LED_Kind use
(Num_Lock => 16#00#,
Caps_Lock => 16#01#,
Scroll_Lock => 16#02#,
Compose => 16#03#,
Kana => 16#04#,
Sleep => 16#05#,
Suspend => 16#06#,
Mute => 16#07#,
Misc => 16#08#,
Mail => 16#09#,
Charging => 16#0A#);
for LED_Kind'Size use 16;
for Repeat_Kind use
(Repeat_Delay => 16#00#,
Repeat_Period => 16#01#);
for Repeat_Kind'Size use 2;
for Sound_Kind use
(Click => 16#00#,
Bell => 16#01#,
Tone => 16#02#);
for Sound_Kind'Size use 8;
end Event_Device;
|
source/nodes/program-nodes-procedure_body_declarations.adb | optikos/oasis | 0 | 20698 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Procedure_Body_Declarations is
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access;
Procedure_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Declarations : Program.Element_Vectors.Element_Vector_Access;
Begin_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
Exception_Token : Program.Lexical_Elements.Lexical_Element_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Expressions.Expression_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Procedure_Body_Declaration is
begin
return Result : Procedure_Body_Declaration :=
(Not_Token => Not_Token, Overriding_Token => Overriding_Token,
Procedure_Token => Procedure_Token, Name => Name,
Left_Bracket_Token => Left_Bracket_Token, Parameters => Parameters,
Right_Bracket_Token => Right_Bracket_Token, With_Token => With_Token,
Aspects => Aspects, Is_Token => Is_Token,
Declarations => Declarations, Begin_Token => Begin_Token,
Statements => Statements, Exception_Token => Exception_Token,
Exception_Handlers => Exception_Handlers, End_Token => End_Token,
End_Name => End_Name, Semicolon_Token => Semicolon_Token,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Declarations : Program.Element_Vectors.Element_Vector_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
End_Name : Program.Elements.Expressions.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not : Boolean := False;
Has_Overriding : Boolean := False)
return Implicit_Procedure_Body_Declaration is
begin
return Result : Implicit_Procedure_Body_Declaration :=
(Name => Name, Parameters => Parameters, Aspects => Aspects,
Declarations => Declarations, Statements => Statements,
Exception_Handlers => Exception_Handlers, End_Name => End_Name,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Has_Not => Has_Not,
Has_Overriding => Has_Overriding, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Procedure_Body_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access is
begin
return Self.Name;
end Name;
overriding function Parameters
(Self : Base_Procedure_Body_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is
begin
return Self.Parameters;
end Parameters;
overriding function Aspects
(Self : Base_Procedure_Body_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is
begin
return Self.Aspects;
end Aspects;
overriding function Declarations
(Self : Base_Procedure_Body_Declaration)
return Program.Element_Vectors.Element_Vector_Access is
begin
return Self.Declarations;
end Declarations;
overriding function Statements
(Self : Base_Procedure_Body_Declaration)
return not null Program.Element_Vectors.Element_Vector_Access is
begin
return Self.Statements;
end Statements;
overriding function Exception_Handlers
(Self : Base_Procedure_Body_Declaration)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access is
begin
return Self.Exception_Handlers;
end Exception_Handlers;
overriding function End_Name
(Self : Base_Procedure_Body_Declaration)
return Program.Elements.Expressions.Expression_Access is
begin
return Self.End_Name;
end End_Name;
overriding function Not_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Not_Token;
end Not_Token;
overriding function Overriding_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Overriding_Token;
end Overriding_Token;
overriding function Procedure_Token
(Self : Procedure_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Procedure_Token;
end Procedure_Token;
overriding function Left_Bracket_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token;
end Left_Bracket_Token;
overriding function Right_Bracket_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token;
end Right_Bracket_Token;
overriding function With_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.With_Token;
end With_Token;
overriding function Is_Token
(Self : Procedure_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Is_Token;
end Is_Token;
overriding function Begin_Token
(Self : Procedure_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Begin_Token;
end Begin_Token;
overriding function Exception_Token
(Self : Procedure_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Exception_Token;
end Exception_Token;
overriding function End_Token
(Self : Procedure_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.End_Token;
end End_Token;
overriding function Semicolon_Token
(Self : Procedure_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Has_Not
(Self : Procedure_Body_Declaration)
return Boolean is
begin
return Self.Not_Token.Assigned;
end Has_Not;
overriding function Has_Overriding
(Self : Procedure_Body_Declaration)
return Boolean is
begin
return Self.Overriding_Token.Assigned;
end Has_Overriding;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Procedure_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Procedure_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Procedure_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Not
(Self : Implicit_Procedure_Body_Declaration)
return Boolean is
begin
return Self.Has_Not;
end Has_Not;
overriding function Has_Overriding
(Self : Implicit_Procedure_Body_Declaration)
return Boolean is
begin
return Self.Has_Overriding;
end Has_Overriding;
procedure Initialize
(Self : aliased in out Base_Procedure_Body_Declaration'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
for Item in Self.Parameters.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Aspects.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Declarations.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Statements.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Exception_Handlers.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
if Self.End_Name.Assigned then
Set_Enclosing_Element (Self.End_Name, Self'Unchecked_Access);
end if;
null;
end Initialize;
overriding function Is_Procedure_Body_Declaration_Element
(Self : Base_Procedure_Body_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Procedure_Body_Declaration_Element;
overriding function Is_Declaration_Element
(Self : Base_Procedure_Body_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration_Element;
overriding procedure Visit
(Self : not null access Base_Procedure_Body_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Procedure_Body_Declaration (Self);
end Visit;
overriding function To_Procedure_Body_Declaration_Text
(Self : aliased in out Procedure_Body_Declaration)
return Program.Elements.Procedure_Body_Declarations
.Procedure_Body_Declaration_Text_Access is
begin
return Self'Unchecked_Access;
end To_Procedure_Body_Declaration_Text;
overriding function To_Procedure_Body_Declaration_Text
(Self : aliased in out Implicit_Procedure_Body_Declaration)
return Program.Elements.Procedure_Body_Declarations
.Procedure_Body_Declaration_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Procedure_Body_Declaration_Text;
end Program.Nodes.Procedure_Body_Declarations;
|
Default Firmware/Ocelot_Unmanaged-1.0.1_SourceCode/Ocelot_Unmanaged-1.0.1/src/main/startup_ocelot.a51 | botblox/GigaBlox-Rugged-FW | 1 | 91714 | <filename>Default Firmware/Ocelot_Unmanaged-1.0.1_SourceCode/Ocelot_Unmanaged-1.0.1/src/main/startup_ocelot.a51
$NOMOD51
$INCLUDE(hwconf.inc)
;------------------------------------------------------------------------------
; This file is part of the C51 Compiler package
; Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
;------------------------------------------------------------------------------
; STARTUP.A51: This code is executed after processor reset.
;
; To translate this file use A51 with the following invocation:
;
; A51 STARTUP.A51
;
; To link the modified STARTUP.OBJ file to your application use the following
; BL51 invocation:
;
; BL51 <your object file list>, STARTUP.OBJ <controls>
;
;------------------------------------------------------------------------------
;
; User-defined Power-On Initialization of Memory
;
; With the following EQU statements the initialization of memory
; at processor reset can be defined:
;
; ; the absolute start-address of IDATA memory is always 0
IDATALEN EQU 0FFH ; the length of IDATA memory in bytes.
;
; See hwconf.inc XDATASTART EQU 0000H ; the absolute start-address of XDATA memory
; See hwconf.inc XDATALEN EQU 8000H ; the length of XDATA memory in bytes.
;
PDATASTART EQU 0H ; the absolute start-address of PDATA memory
PDATALEN EQU 0H ; the length of PDATA memory in bytes.
;
; Notes: The IDATA space overlaps physically the DATA and BIT areas of the
; 8051 CPU. At minimum the memory space occupied from the C51
; run-time routines must be set to zero.
;------------------------------------------------------------------------------
;
; Reentrant Stack Initilization
;
; The following EQU statements define the stack pointer for reentrant
; functions and initialized it:
;
; Stack Space for reentrant functions in the SMALL model.
IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1.
;
; Stack Space for reentrant functions in the LARGE model.
XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
;
; Stack Space for reentrant functions in the COMPACT model.
PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1.
;
;------------------------------------------------------------------------------
;
; Page Definition for Using the Compact Model with 64 KByte xdata RAM
;
; The following EQU statements define the xdata page used for pdata
; variables. The EQU PPAGE must conform with the PPAGE control used
; in the linker invocation.
;
PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
;
PPAGE EQU 0 ; define PPAGE number.
;
PPAGE_SFR DATA 0A0H ; SFR that supplies uppermost address byte
; (most 8051 variants use P2 as uppermost address byte)
;
;------------------------------------------------------------------------------
; Standard SFR Symbols
ACC DATA 0E0H
B DATA 0F0H
SP DATA 81H
DPL DATA 82H
DPH DATA 83H
AUXR DATA 8EH
NAME ?C_STARTUP
?C_C51STARTUP SEGMENT CODE
?STACK SEGMENT IDATA
RSEG ?STACK
DS 1
EXTRN CODE (?C_START)
PUBLIC ?C_STARTUP
CSEG AT 0
?C_STARTUP: LJMP STARTUP1
RSEG ?C_C51STARTUP
STARTUP1:
; Mapping before memory and stack inialization
MOV SP,#?STACK-1
call hw_init
IF IDATALEN <> 0
MOV R0,#IDATALEN - 1
CLR A
IDATALOOP: MOV @R0,A
DJNZ R0,IDATALOOP
ENDIF
IF XDATALEN <> 0
STARTUP_XMEM
MOV DPTR,#XDATASTART
MOV R7,#LOW (XDATALEN)
IF (LOW (XDATALEN)) <> 0
MOV R6,#(HIGH (XDATALEN)) +1
ELSE
MOV R6,#HIGH (XDATALEN)
ENDIF
CLR A
XDATALOOP: MOVX @DPTR,A
INC DPTR
DJNZ R7,XDATALOOP
DJNZ R6,XDATALOOP
ENDIF
IF PPAGEENABLE <> 0
MOV PPAGE_SFR,#PPAGE
ENDIF
IF PDATALEN <> 0
MOV R0,#LOW (PDATASTART)
MOV R7,#LOW (PDATALEN)
CLR A
PDATALOOP: MOVX @R0,A
INC R0
DJNZ R7,PDATALOOP
ENDIF
IF IBPSTACK <> 0
EXTRN DATA (?C_IBP)
MOV ?C_IBP,#LOW IBPSTACKTOP
ENDIF
IF XBPSTACK <> 0
EXTRN DATA (?C_XBP)
MOV ?C_XBP,#HIGH XBPSTACKTOP
MOV ?C_XBP+1,#LOW XBPSTACKTOP
ENDIF
IF PBPSTACK <> 0
EXTRN DATA (?C_PBP)
MOV ?C_PBP,#LOW PBPSTACKTOP
ENDIF
MOV SP,#?STACK-1
; This code is required if you use L51_BANK.A51 with Banking Mode 4
; EXTRN CODE (?B_SWITCH0)
; CALL ?B_SWITCH0 ; init bank mechanism to code bank 0
LJMP ?C_START
hw_init:
; Speed up the SI interface by writing to IPU_CFG:SPI_MST_CFG.
MOV RA_DA3, #0
MOV RA_DA2, #0
MOV RA_DA1, #007H
MOV RA_DA0, #0EAH
MOV RA_AD3, #070H
MOV RA_AD2, #0
MOV RA_AD1, #0
MOV RA_AD0_WR, #03CH ; this write start the AHB write! for Ocelot
$IF (BOOT_VIA_SPI = 1)
; Configure registers for loading the internal memory from FLASH. ICPU_CFG:MEMACC
; It is defined in src\config\hwconf.inc
MOV RA_DA3,#HIGH (XDATASTART - 1)
MOV RA_DA2,#LOW (XDATASTART - 1)
MOV RA_DA1, #0
MOV RA_DA0, #0
; MOV RA_AD3, #070H
; MOV RA_AD2, #0
; MOV RA_AD1, #0
MOV RA_AD0_WR, #064H ; this write start the AHB write!ocelot
; Start the actual load, the 8051 will be gated while the load is going on,
; so we can just continue as if nothing had happend (8051 will be released
; once the onchip memory contains the progam). ICPU_CFG:MEMACC_CTRL
MOV RA_DA3, #0
MOV RA_DA2, #0
; MOV RA_DA1, #0
MOV RA_DA0, #001H
; MOV RA_AD3, #070H
; MOV RA_AD2, #0
; MOV RA_AD1, #0
MOV RA_AD0_WR, #060H ; this write start the AHB write!ocelot
$ENDIF
; Errata, clear SFR register 0x8E prior to mapping internal memory.
MOV 8EH, #000H
; Enable mapping of onchip memory, note that we use SFR reg - not the CSR
; counterpart, this means that if the 8051 is reset (without resetting the
; the AHB system), then we will again load from external FLASH!
MOV MMAP, #0AFH ; map all accesses to onchip memory (until 8051 reset)
; MOV RA_DA0, #0AFH
; MOV RA_AD0_WR, #05CH; // this write start the AHB write!
;MOV RA_AD0_RD, #024H; // this write start the AHB read!
;MOV RA_DA0, #08FH; // clear bits 4:5 (of 0xAF)for ferret and jaguar2
;MOV RA_AD0_WR, #024H; // write back register!
ret
END
|
grep.asm | jahzielv/xv6-net | 0 | 172123 | <reponame>jahzielv/xv6-net
_grep: file format elf32-i386
Disassembly of section .text:
00000000 <grep>:
char buf[1024];
int match(char*, char*);
void
grep(char *pattern, int fd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 18 sub $0x18,%esp
int n, m;
char *p, *q;
m = 0;
6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
d: e9 b6 00 00 00 jmp c8 <grep+0xc8>
m += n;
12: 8b 45 ec mov -0x14(%ebp),%eax
15: 01 45 f4 add %eax,-0xc(%ebp)
buf[m] = '\0';
18: 8b 45 f4 mov -0xc(%ebp),%eax
1b: 05 e0 1a 00 00 add $0x1ae0,%eax
20: c6 00 00 movb $0x0,(%eax)
p = buf;
23: c7 45 f0 e0 1a 00 00 movl $0x1ae0,-0x10(%ebp)
while((q = strchr(p, '\n')) != 0){
2a: eb 4a jmp 76 <grep+0x76>
*q = 0;
2c: 8b 45 e8 mov -0x18(%ebp),%eax
2f: c6 00 00 movb $0x0,(%eax)
if(match(pattern, p)){
32: 83 ec 08 sub $0x8,%esp
35: ff 75 f0 pushl -0x10(%ebp)
38: ff 75 08 pushl 0x8(%ebp)
3b: e8 9a 01 00 00 call 1da <match>
40: 83 c4 10 add $0x10,%esp
43: 85 c0 test %eax,%eax
45: 74 26 je 6d <grep+0x6d>
*q = '\n';
47: 8b 45 e8 mov -0x18(%ebp),%eax
4a: c6 00 0a movb $0xa,(%eax)
write(1, p, q+1 - p);
4d: 8b 45 e8 mov -0x18(%ebp),%eax
50: 83 c0 01 add $0x1,%eax
53: 89 c2 mov %eax,%edx
55: 8b 45 f0 mov -0x10(%ebp),%eax
58: 29 c2 sub %eax,%edx
5a: 89 d0 mov %edx,%eax
5c: 83 ec 04 sub $0x4,%esp
5f: 50 push %eax
60: ff 75 f0 pushl -0x10(%ebp)
63: 6a 01 push $0x1
65: e8 73 05 00 00 call 5dd <write>
6a: 83 c4 10 add $0x10,%esp
}
p = q+1;
6d: 8b 45 e8 mov -0x18(%ebp),%eax
70: 83 c0 01 add $0x1,%eax
73: 89 45 f0 mov %eax,-0x10(%ebp)
while((q = strchr(p, '\n')) != 0){
76: 83 ec 08 sub $0x8,%esp
79: 6a 0a push $0xa
7b: ff 75 f0 pushl -0x10(%ebp)
7e: e8 b9 03 00 00 call 43c <strchr>
83: 83 c4 10 add $0x10,%esp
86: 89 45 e8 mov %eax,-0x18(%ebp)
89: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
8d: 75 9d jne 2c <grep+0x2c>
}
if(p == buf)
8f: 81 7d f0 e0 1a 00 00 cmpl $0x1ae0,-0x10(%ebp)
96: 75 07 jne 9f <grep+0x9f>
m = 0;
98: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if(m > 0){
9f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
a3: 7e 23 jle c8 <grep+0xc8>
m -= p - buf;
a5: 8b 45 f0 mov -0x10(%ebp),%eax
a8: ba e0 1a 00 00 mov $0x1ae0,%edx
ad: 29 d0 sub %edx,%eax
af: 29 45 f4 sub %eax,-0xc(%ebp)
memmove(buf, p, m);
b2: 83 ec 04 sub $0x4,%esp
b5: ff 75 f4 pushl -0xc(%ebp)
b8: ff 75 f0 pushl -0x10(%ebp)
bb: 68 e0 1a 00 00 push $0x1ae0
c0: e8 b3 04 00 00 call 578 <memmove>
c5: 83 c4 10 add $0x10,%esp
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
c8: 8b 45 f4 mov -0xc(%ebp),%eax
cb: ba ff 03 00 00 mov $0x3ff,%edx
d0: 29 c2 sub %eax,%edx
d2: 89 d0 mov %edx,%eax
d4: 89 c2 mov %eax,%edx
d6: 8b 45 f4 mov -0xc(%ebp),%eax
d9: 05 e0 1a 00 00 add $0x1ae0,%eax
de: 83 ec 04 sub $0x4,%esp
e1: 52 push %edx
e2: 50 push %eax
e3: ff 75 0c pushl 0xc(%ebp)
e6: e8 ea 04 00 00 call 5d5 <read>
eb: 83 c4 10 add $0x10,%esp
ee: 89 45 ec mov %eax,-0x14(%ebp)
f1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
f5: 0f 8f 17 ff ff ff jg 12 <grep+0x12>
}
}
}
fb: 90 nop
fc: c9 leave
fd: c3 ret
000000fe <main>:
int
main(int argc, char *argv[])
{
fe: 8d 4c 24 04 lea 0x4(%esp),%ecx
102: 83 e4 f0 and $0xfffffff0,%esp
105: ff 71 fc pushl -0x4(%ecx)
108: 55 push %ebp
109: 89 e5 mov %esp,%ebp
10b: 53 push %ebx
10c: 51 push %ecx
10d: 83 ec 10 sub $0x10,%esp
110: 89 cb mov %ecx,%ebx
int fd, i;
char *pattern;
if(argc <= 1){
112: 83 3b 01 cmpl $0x1,(%ebx)
115: 7f 17 jg 12e <main+0x30>
printf(2, "usage: grep pattern [file ...]\n");
117: 83 ec 08 sub $0x8,%esp
11a: 68 40 13 00 00 push $0x1340
11f: 6a 02 push $0x2
121: e8 2a 06 00 00 call 750 <printf>
126: 83 c4 10 add $0x10,%esp
exit();
129: e8 8f 04 00 00 call 5bd <exit>
}
pattern = argv[1];
12e: 8b 43 04 mov 0x4(%ebx),%eax
131: 8b 40 04 mov 0x4(%eax),%eax
134: 89 45 f0 mov %eax,-0x10(%ebp)
if(argc <= 2){
137: 83 3b 02 cmpl $0x2,(%ebx)
13a: 7f 15 jg 151 <main+0x53>
grep(pattern, 0);
13c: 83 ec 08 sub $0x8,%esp
13f: 6a 00 push $0x0
141: ff 75 f0 pushl -0x10(%ebp)
144: e8 b7 fe ff ff call 0 <grep>
149: 83 c4 10 add $0x10,%esp
exit();
14c: e8 6c 04 00 00 call 5bd <exit>
}
for(i = 2; i < argc; i++){
151: c7 45 f4 02 00 00 00 movl $0x2,-0xc(%ebp)
158: eb 74 jmp 1ce <main+0xd0>
if((fd = open(argv[i], 0)) < 0){
15a: 8b 45 f4 mov -0xc(%ebp),%eax
15d: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
164: 8b 43 04 mov 0x4(%ebx),%eax
167: 01 d0 add %edx,%eax
169: 8b 00 mov (%eax),%eax
16b: 83 ec 08 sub $0x8,%esp
16e: 6a 00 push $0x0
170: 50 push %eax
171: e8 87 04 00 00 call 5fd <open>
176: 83 c4 10 add $0x10,%esp
179: 89 45 ec mov %eax,-0x14(%ebp)
17c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
180: 79 29 jns 1ab <main+0xad>
printf(1, "grep: cannot open %s\n", argv[i]);
182: 8b 45 f4 mov -0xc(%ebp),%eax
185: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
18c: 8b 43 04 mov 0x4(%ebx),%eax
18f: 01 d0 add %edx,%eax
191: 8b 00 mov (%eax),%eax
193: 83 ec 04 sub $0x4,%esp
196: 50 push %eax
197: 68 60 13 00 00 push $0x1360
19c: 6a 01 push $0x1
19e: e8 ad 05 00 00 call 750 <printf>
1a3: 83 c4 10 add $0x10,%esp
exit();
1a6: e8 12 04 00 00 call 5bd <exit>
}
grep(pattern, fd);
1ab: 83 ec 08 sub $0x8,%esp
1ae: ff 75 ec pushl -0x14(%ebp)
1b1: ff 75 f0 pushl -0x10(%ebp)
1b4: e8 47 fe ff ff call 0 <grep>
1b9: 83 c4 10 add $0x10,%esp
close(fd);
1bc: 83 ec 0c sub $0xc,%esp
1bf: ff 75 ec pushl -0x14(%ebp)
1c2: e8 1e 04 00 00 call 5e5 <close>
1c7: 83 c4 10 add $0x10,%esp
for(i = 2; i < argc; i++){
1ca: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ce: 8b 45 f4 mov -0xc(%ebp),%eax
1d1: 3b 03 cmp (%ebx),%eax
1d3: 7c 85 jl 15a <main+0x5c>
}
exit();
1d5: e8 e3 03 00 00 call 5bd <exit>
000001da <match>:
int matchhere(char*, char*);
int matchstar(int, char*, char*);
int
match(char *re, char *text)
{
1da: 55 push %ebp
1db: 89 e5 mov %esp,%ebp
1dd: 83 ec 08 sub $0x8,%esp
if(re[0] == '^')
1e0: 8b 45 08 mov 0x8(%ebp),%eax
1e3: 0f b6 00 movzbl (%eax),%eax
1e6: 3c 5e cmp $0x5e,%al
1e8: 75 17 jne 201 <match+0x27>
return matchhere(re+1, text);
1ea: 8b 45 08 mov 0x8(%ebp),%eax
1ed: 83 c0 01 add $0x1,%eax
1f0: 83 ec 08 sub $0x8,%esp
1f3: ff 75 0c pushl 0xc(%ebp)
1f6: 50 push %eax
1f7: e8 38 00 00 00 call 234 <matchhere>
1fc: 83 c4 10 add $0x10,%esp
1ff: eb 31 jmp 232 <match+0x58>
do{ // must look at empty string
if(matchhere(re, text))
201: 83 ec 08 sub $0x8,%esp
204: ff 75 0c pushl 0xc(%ebp)
207: ff 75 08 pushl 0x8(%ebp)
20a: e8 25 00 00 00 call 234 <matchhere>
20f: 83 c4 10 add $0x10,%esp
212: 85 c0 test %eax,%eax
214: 74 07 je 21d <match+0x43>
return 1;
216: b8 01 00 00 00 mov $0x1,%eax
21b: eb 15 jmp 232 <match+0x58>
}while(*text++ != '\0');
21d: 8b 45 0c mov 0xc(%ebp),%eax
220: 8d 50 01 lea 0x1(%eax),%edx
223: 89 55 0c mov %edx,0xc(%ebp)
226: 0f b6 00 movzbl (%eax),%eax
229: 84 c0 test %al,%al
22b: 75 d4 jne 201 <match+0x27>
return 0;
22d: b8 00 00 00 00 mov $0x0,%eax
}
232: c9 leave
233: c3 ret
00000234 <matchhere>:
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
234: 55 push %ebp
235: 89 e5 mov %esp,%ebp
237: 83 ec 08 sub $0x8,%esp
if(re[0] == '\0')
23a: 8b 45 08 mov 0x8(%ebp),%eax
23d: 0f b6 00 movzbl (%eax),%eax
240: 84 c0 test %al,%al
242: 75 0a jne 24e <matchhere+0x1a>
return 1;
244: b8 01 00 00 00 mov $0x1,%eax
249: e9 99 00 00 00 jmp 2e7 <matchhere+0xb3>
if(re[1] == '*')
24e: 8b 45 08 mov 0x8(%ebp),%eax
251: 83 c0 01 add $0x1,%eax
254: 0f b6 00 movzbl (%eax),%eax
257: 3c 2a cmp $0x2a,%al
259: 75 21 jne 27c <matchhere+0x48>
return matchstar(re[0], re+2, text);
25b: 8b 45 08 mov 0x8(%ebp),%eax
25e: 8d 50 02 lea 0x2(%eax),%edx
261: 8b 45 08 mov 0x8(%ebp),%eax
264: 0f b6 00 movzbl (%eax),%eax
267: 0f be c0 movsbl %al,%eax
26a: 83 ec 04 sub $0x4,%esp
26d: ff 75 0c pushl 0xc(%ebp)
270: 52 push %edx
271: 50 push %eax
272: e8 72 00 00 00 call 2e9 <matchstar>
277: 83 c4 10 add $0x10,%esp
27a: eb 6b jmp 2e7 <matchhere+0xb3>
if(re[0] == '$' && re[1] == '\0')
27c: 8b 45 08 mov 0x8(%ebp),%eax
27f: 0f b6 00 movzbl (%eax),%eax
282: 3c 24 cmp $0x24,%al
284: 75 1d jne 2a3 <matchhere+0x6f>
286: 8b 45 08 mov 0x8(%ebp),%eax
289: 83 c0 01 add $0x1,%eax
28c: 0f b6 00 movzbl (%eax),%eax
28f: 84 c0 test %al,%al
291: 75 10 jne 2a3 <matchhere+0x6f>
return *text == '\0';
293: 8b 45 0c mov 0xc(%ebp),%eax
296: 0f b6 00 movzbl (%eax),%eax
299: 84 c0 test %al,%al
29b: 0f 94 c0 sete %al
29e: 0f b6 c0 movzbl %al,%eax
2a1: eb 44 jmp 2e7 <matchhere+0xb3>
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
2a3: 8b 45 0c mov 0xc(%ebp),%eax
2a6: 0f b6 00 movzbl (%eax),%eax
2a9: 84 c0 test %al,%al
2ab: 74 35 je 2e2 <matchhere+0xae>
2ad: 8b 45 08 mov 0x8(%ebp),%eax
2b0: 0f b6 00 movzbl (%eax),%eax
2b3: 3c 2e cmp $0x2e,%al
2b5: 74 10 je 2c7 <matchhere+0x93>
2b7: 8b 45 08 mov 0x8(%ebp),%eax
2ba: 0f b6 10 movzbl (%eax),%edx
2bd: 8b 45 0c mov 0xc(%ebp),%eax
2c0: 0f b6 00 movzbl (%eax),%eax
2c3: 38 c2 cmp %al,%dl
2c5: 75 1b jne 2e2 <matchhere+0xae>
return matchhere(re+1, text+1);
2c7: 8b 45 0c mov 0xc(%ebp),%eax
2ca: 8d 50 01 lea 0x1(%eax),%edx
2cd: 8b 45 08 mov 0x8(%ebp),%eax
2d0: 83 c0 01 add $0x1,%eax
2d3: 83 ec 08 sub $0x8,%esp
2d6: 52 push %edx
2d7: 50 push %eax
2d8: e8 57 ff ff ff call 234 <matchhere>
2dd: 83 c4 10 add $0x10,%esp
2e0: eb 05 jmp 2e7 <matchhere+0xb3>
return 0;
2e2: b8 00 00 00 00 mov $0x0,%eax
}
2e7: c9 leave
2e8: c3 ret
000002e9 <matchstar>:
// matchstar: search for c*re at beginning of text
int matchstar(int c, char *re, char *text)
{
2e9: 55 push %ebp
2ea: 89 e5 mov %esp,%ebp
2ec: 83 ec 08 sub $0x8,%esp
do{ // a * matches zero or more instances
if(matchhere(re, text))
2ef: 83 ec 08 sub $0x8,%esp
2f2: ff 75 10 pushl 0x10(%ebp)
2f5: ff 75 0c pushl 0xc(%ebp)
2f8: e8 37 ff ff ff call 234 <matchhere>
2fd: 83 c4 10 add $0x10,%esp
300: 85 c0 test %eax,%eax
302: 74 07 je 30b <matchstar+0x22>
return 1;
304: b8 01 00 00 00 mov $0x1,%eax
309: eb 29 jmp 334 <matchstar+0x4b>
}while(*text!='\0' && (*text++==c || c=='.'));
30b: 8b 45 10 mov 0x10(%ebp),%eax
30e: 0f b6 00 movzbl (%eax),%eax
311: 84 c0 test %al,%al
313: 74 1a je 32f <matchstar+0x46>
315: 8b 45 10 mov 0x10(%ebp),%eax
318: 8d 50 01 lea 0x1(%eax),%edx
31b: 89 55 10 mov %edx,0x10(%ebp)
31e: 0f b6 00 movzbl (%eax),%eax
321: 0f be c0 movsbl %al,%eax
324: 39 45 08 cmp %eax,0x8(%ebp)
327: 74 c6 je 2ef <matchstar+0x6>
329: 83 7d 08 2e cmpl $0x2e,0x8(%ebp)
32d: 74 c0 je 2ef <matchstar+0x6>
return 0;
32f: b8 00 00 00 00 mov $0x0,%eax
}
334: c9 leave
335: c3 ret
00000336 <stosb>:
asm volatile("outl %0,%w1" : : "a" (data), "d" (port));
}
static inline void
stosb(void *addr, int data, int cnt)
{
336: 55 push %ebp
337: 89 e5 mov %esp,%ebp
339: 57 push %edi
33a: 53 push %ebx
asm volatile("cld; rep stosb" :
33b: 8b 4d 08 mov 0x8(%ebp),%ecx
33e: 8b 55 10 mov 0x10(%ebp),%edx
341: 8b 45 0c mov 0xc(%ebp),%eax
344: 89 cb mov %ecx,%ebx
346: 89 df mov %ebx,%edi
348: 89 d1 mov %edx,%ecx
34a: fc cld
34b: f3 aa rep stos %al,%es:(%edi)
34d: 89 ca mov %ecx,%edx
34f: 89 fb mov %edi,%ebx
351: 89 5d 08 mov %ebx,0x8(%ebp)
354: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
357: 90 nop
358: 5b pop %ebx
359: 5f pop %edi
35a: 5d pop %ebp
35b: c3 ret
0000035c <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
35c: 55 push %ebp
35d: 89 e5 mov %esp,%ebp
35f: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
362: 8b 45 08 mov 0x8(%ebp),%eax
365: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
368: 90 nop
369: 8b 55 0c mov 0xc(%ebp),%edx
36c: 8d 42 01 lea 0x1(%edx),%eax
36f: 89 45 0c mov %eax,0xc(%ebp)
372: 8b 45 08 mov 0x8(%ebp),%eax
375: 8d 48 01 lea 0x1(%eax),%ecx
378: 89 4d 08 mov %ecx,0x8(%ebp)
37b: 0f b6 12 movzbl (%edx),%edx
37e: 88 10 mov %dl,(%eax)
380: 0f b6 00 movzbl (%eax),%eax
383: 84 c0 test %al,%al
385: 75 e2 jne 369 <strcpy+0xd>
;
return os;
387: 8b 45 fc mov -0x4(%ebp),%eax
}
38a: c9 leave
38b: c3 ret
0000038c <strcmp>:
int
strcmp(const char *p, const char *q)
{
38c: 55 push %ebp
38d: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
38f: eb 08 jmp 399 <strcmp+0xd>
p++, q++;
391: 83 45 08 01 addl $0x1,0x8(%ebp)
395: 83 45 0c 01 addl $0x1,0xc(%ebp)
while(*p && *p == *q)
399: 8b 45 08 mov 0x8(%ebp),%eax
39c: 0f b6 00 movzbl (%eax),%eax
39f: 84 c0 test %al,%al
3a1: 74 10 je 3b3 <strcmp+0x27>
3a3: 8b 45 08 mov 0x8(%ebp),%eax
3a6: 0f b6 10 movzbl (%eax),%edx
3a9: 8b 45 0c mov 0xc(%ebp),%eax
3ac: 0f b6 00 movzbl (%eax),%eax
3af: 38 c2 cmp %al,%dl
3b1: 74 de je 391 <strcmp+0x5>
return (uchar)*p - (uchar)*q;
3b3: 8b 45 08 mov 0x8(%ebp),%eax
3b6: 0f b6 00 movzbl (%eax),%eax
3b9: 0f b6 d0 movzbl %al,%edx
3bc: 8b 45 0c mov 0xc(%ebp),%eax
3bf: 0f b6 00 movzbl (%eax),%eax
3c2: 0f b6 c0 movzbl %al,%eax
3c5: 29 c2 sub %eax,%edx
3c7: 89 d0 mov %edx,%eax
}
3c9: 5d pop %ebp
3ca: c3 ret
000003cb <strlen>:
uint
strlen(char *s)
{
3cb: 55 push %ebp
3cc: 89 e5 mov %esp,%ebp
3ce: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
3d1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
3d8: eb 04 jmp 3de <strlen+0x13>
3da: 83 45 fc 01 addl $0x1,-0x4(%ebp)
3de: 8b 55 fc mov -0x4(%ebp),%edx
3e1: 8b 45 08 mov 0x8(%ebp),%eax
3e4: 01 d0 add %edx,%eax
3e6: 0f b6 00 movzbl (%eax),%eax
3e9: 84 c0 test %al,%al
3eb: 75 ed jne 3da <strlen+0xf>
;
return n;
3ed: 8b 45 fc mov -0x4(%ebp),%eax
}
3f0: c9 leave
3f1: c3 ret
000003f2 <strnlen>:
int
strnlen(const char *s, uint size)
{
3f2: 55 push %ebp
3f3: 89 e5 mov %esp,%ebp
3f5: 83 ec 10 sub $0x10,%esp
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
3f8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
3ff: eb 0c jmp 40d <strnlen+0x1b>
n++;
401: 83 45 fc 01 addl $0x1,-0x4(%ebp)
for (n = 0; size > 0 && *s != '\0'; s++, size--)
405: 83 45 08 01 addl $0x1,0x8(%ebp)
409: 83 6d 0c 01 subl $0x1,0xc(%ebp)
40d: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
411: 74 0a je 41d <strnlen+0x2b>
413: 8b 45 08 mov 0x8(%ebp),%eax
416: 0f b6 00 movzbl (%eax),%eax
419: 84 c0 test %al,%al
41b: 75 e4 jne 401 <strnlen+0xf>
return n;
41d: 8b 45 fc mov -0x4(%ebp),%eax
}
420: c9 leave
421: c3 ret
00000422 <memset>:
void*
memset(void *dst, int c, uint n)
{
422: 55 push %ebp
423: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
425: 8b 45 10 mov 0x10(%ebp),%eax
428: 50 push %eax
429: ff 75 0c pushl 0xc(%ebp)
42c: ff 75 08 pushl 0x8(%ebp)
42f: e8 02 ff ff ff call 336 <stosb>
434: 83 c4 0c add $0xc,%esp
return dst;
437: 8b 45 08 mov 0x8(%ebp),%eax
}
43a: c9 leave
43b: c3 ret
0000043c <strchr>:
char*
strchr(const char *s, char c)
{
43c: 55 push %ebp
43d: 89 e5 mov %esp,%ebp
43f: 83 ec 04 sub $0x4,%esp
442: 8b 45 0c mov 0xc(%ebp),%eax
445: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
448: eb 14 jmp 45e <strchr+0x22>
if(*s == c)
44a: 8b 45 08 mov 0x8(%ebp),%eax
44d: 0f b6 00 movzbl (%eax),%eax
450: 38 45 fc cmp %al,-0x4(%ebp)
453: 75 05 jne 45a <strchr+0x1e>
return (char*)s;
455: 8b 45 08 mov 0x8(%ebp),%eax
458: eb 13 jmp 46d <strchr+0x31>
for(; *s; s++)
45a: 83 45 08 01 addl $0x1,0x8(%ebp)
45e: 8b 45 08 mov 0x8(%ebp),%eax
461: 0f b6 00 movzbl (%eax),%eax
464: 84 c0 test %al,%al
466: 75 e2 jne 44a <strchr+0xe>
return 0;
468: b8 00 00 00 00 mov $0x0,%eax
}
46d: c9 leave
46e: c3 ret
0000046f <gets>:
char*
gets(char *buf, int max)
{
46f: 55 push %ebp
470: 89 e5 mov %esp,%ebp
472: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
475: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
47c: eb 42 jmp 4c0 <gets+0x51>
cc = read(0, &c, 1);
47e: 83 ec 04 sub $0x4,%esp
481: 6a 01 push $0x1
483: 8d 45 ef lea -0x11(%ebp),%eax
486: 50 push %eax
487: 6a 00 push $0x0
489: e8 47 01 00 00 call 5d5 <read>
48e: 83 c4 10 add $0x10,%esp
491: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
494: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
498: 7e 33 jle 4cd <gets+0x5e>
break;
buf[i++] = c;
49a: 8b 45 f4 mov -0xc(%ebp),%eax
49d: 8d 50 01 lea 0x1(%eax),%edx
4a0: 89 55 f4 mov %edx,-0xc(%ebp)
4a3: 89 c2 mov %eax,%edx
4a5: 8b 45 08 mov 0x8(%ebp),%eax
4a8: 01 c2 add %eax,%edx
4aa: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4ae: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
4b0: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4b4: 3c 0a cmp $0xa,%al
4b6: 74 16 je 4ce <gets+0x5f>
4b8: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4bc: 3c 0d cmp $0xd,%al
4be: 74 0e je 4ce <gets+0x5f>
for(i=0; i+1 < max; ){
4c0: 8b 45 f4 mov -0xc(%ebp),%eax
4c3: 83 c0 01 add $0x1,%eax
4c6: 39 45 0c cmp %eax,0xc(%ebp)
4c9: 7f b3 jg 47e <gets+0xf>
4cb: eb 01 jmp 4ce <gets+0x5f>
break;
4cd: 90 nop
break;
}
buf[i] = '\0';
4ce: 8b 55 f4 mov -0xc(%ebp),%edx
4d1: 8b 45 08 mov 0x8(%ebp),%eax
4d4: 01 d0 add %edx,%eax
4d6: c6 00 00 movb $0x0,(%eax)
return buf;
4d9: 8b 45 08 mov 0x8(%ebp),%eax
}
4dc: c9 leave
4dd: c3 ret
000004de <stat>:
int
stat(char *n, struct stat *st)
{
4de: 55 push %ebp
4df: 89 e5 mov %esp,%ebp
4e1: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
4e4: 83 ec 08 sub $0x8,%esp
4e7: 6a 00 push $0x0
4e9: ff 75 08 pushl 0x8(%ebp)
4ec: e8 0c 01 00 00 call 5fd <open>
4f1: 83 c4 10 add $0x10,%esp
4f4: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
4f7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4fb: 79 07 jns 504 <stat+0x26>
return -1;
4fd: b8 ff ff ff ff mov $0xffffffff,%eax
502: eb 25 jmp 529 <stat+0x4b>
r = fstat(fd, st);
504: 83 ec 08 sub $0x8,%esp
507: ff 75 0c pushl 0xc(%ebp)
50a: ff 75 f4 pushl -0xc(%ebp)
50d: e8 03 01 00 00 call 615 <fstat>
512: 83 c4 10 add $0x10,%esp
515: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
518: 83 ec 0c sub $0xc,%esp
51b: ff 75 f4 pushl -0xc(%ebp)
51e: e8 c2 00 00 00 call 5e5 <close>
523: 83 c4 10 add $0x10,%esp
return r;
526: 8b 45 f0 mov -0x10(%ebp),%eax
}
529: c9 leave
52a: c3 ret
0000052b <atoi>:
int
atoi(const char *s)
{
52b: 55 push %ebp
52c: 89 e5 mov %esp,%ebp
52e: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
531: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
538: eb 25 jmp 55f <atoi+0x34>
n = n*10 + *s++ - '0';
53a: 8b 55 fc mov -0x4(%ebp),%edx
53d: 89 d0 mov %edx,%eax
53f: c1 e0 02 shl $0x2,%eax
542: 01 d0 add %edx,%eax
544: 01 c0 add %eax,%eax
546: 89 c1 mov %eax,%ecx
548: 8b 45 08 mov 0x8(%ebp),%eax
54b: 8d 50 01 lea 0x1(%eax),%edx
54e: 89 55 08 mov %edx,0x8(%ebp)
551: 0f b6 00 movzbl (%eax),%eax
554: 0f be c0 movsbl %al,%eax
557: 01 c8 add %ecx,%eax
559: 83 e8 30 sub $0x30,%eax
55c: 89 45 fc mov %eax,-0x4(%ebp)
while('0' <= *s && *s <= '9')
55f: 8b 45 08 mov 0x8(%ebp),%eax
562: 0f b6 00 movzbl (%eax),%eax
565: 3c 2f cmp $0x2f,%al
567: 7e 0a jle 573 <atoi+0x48>
569: 8b 45 08 mov 0x8(%ebp),%eax
56c: 0f b6 00 movzbl (%eax),%eax
56f: 3c 39 cmp $0x39,%al
571: 7e c7 jle 53a <atoi+0xf>
return n;
573: 8b 45 fc mov -0x4(%ebp),%eax
}
576: c9 leave
577: c3 ret
00000578 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
578: 55 push %ebp
579: 89 e5 mov %esp,%ebp
57b: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
57e: 8b 45 08 mov 0x8(%ebp),%eax
581: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
584: 8b 45 0c mov 0xc(%ebp),%eax
587: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
58a: eb 17 jmp 5a3 <memmove+0x2b>
*dst++ = *src++;
58c: 8b 55 f8 mov -0x8(%ebp),%edx
58f: 8d 42 01 lea 0x1(%edx),%eax
592: 89 45 f8 mov %eax,-0x8(%ebp)
595: 8b 45 fc mov -0x4(%ebp),%eax
598: 8d 48 01 lea 0x1(%eax),%ecx
59b: 89 4d fc mov %ecx,-0x4(%ebp)
59e: 0f b6 12 movzbl (%edx),%edx
5a1: 88 10 mov %dl,(%eax)
while(n-- > 0)
5a3: 8b 45 10 mov 0x10(%ebp),%eax
5a6: 8d 50 ff lea -0x1(%eax),%edx
5a9: 89 55 10 mov %edx,0x10(%ebp)
5ac: 85 c0 test %eax,%eax
5ae: 7f dc jg 58c <memmove+0x14>
return vdst;
5b0: 8b 45 08 mov 0x8(%ebp),%eax
}
5b3: c9 leave
5b4: c3 ret
000005b5 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
5b5: b8 01 00 00 00 mov $0x1,%eax
5ba: cd 40 int $0x40
5bc: c3 ret
000005bd <exit>:
SYSCALL(exit)
5bd: b8 02 00 00 00 mov $0x2,%eax
5c2: cd 40 int $0x40
5c4: c3 ret
000005c5 <wait>:
SYSCALL(wait)
5c5: b8 03 00 00 00 mov $0x3,%eax
5ca: cd 40 int $0x40
5cc: c3 ret
000005cd <pipe>:
SYSCALL(pipe)
5cd: b8 04 00 00 00 mov $0x4,%eax
5d2: cd 40 int $0x40
5d4: c3 ret
000005d5 <read>:
SYSCALL(read)
5d5: b8 05 00 00 00 mov $0x5,%eax
5da: cd 40 int $0x40
5dc: c3 ret
000005dd <write>:
SYSCALL(write)
5dd: b8 10 00 00 00 mov $0x10,%eax
5e2: cd 40 int $0x40
5e4: c3 ret
000005e5 <close>:
SYSCALL(close)
5e5: b8 15 00 00 00 mov $0x15,%eax
5ea: cd 40 int $0x40
5ec: c3 ret
000005ed <kill>:
SYSCALL(kill)
5ed: b8 06 00 00 00 mov $0x6,%eax
5f2: cd 40 int $0x40
5f4: c3 ret
000005f5 <exec>:
SYSCALL(exec)
5f5: b8 07 00 00 00 mov $0x7,%eax
5fa: cd 40 int $0x40
5fc: c3 ret
000005fd <open>:
SYSCALL(open)
5fd: b8 0f 00 00 00 mov $0xf,%eax
602: cd 40 int $0x40
604: c3 ret
00000605 <mknod>:
SYSCALL(mknod)
605: b8 11 00 00 00 mov $0x11,%eax
60a: cd 40 int $0x40
60c: c3 ret
0000060d <unlink>:
SYSCALL(unlink)
60d: b8 12 00 00 00 mov $0x12,%eax
612: cd 40 int $0x40
614: c3 ret
00000615 <fstat>:
SYSCALL(fstat)
615: b8 08 00 00 00 mov $0x8,%eax
61a: cd 40 int $0x40
61c: c3 ret
0000061d <link>:
SYSCALL(link)
61d: b8 13 00 00 00 mov $0x13,%eax
622: cd 40 int $0x40
624: c3 ret
00000625 <mkdir>:
SYSCALL(mkdir)
625: b8 14 00 00 00 mov $0x14,%eax
62a: cd 40 int $0x40
62c: c3 ret
0000062d <chdir>:
SYSCALL(chdir)
62d: b8 09 00 00 00 mov $0x9,%eax
632: cd 40 int $0x40
634: c3 ret
00000635 <dup>:
SYSCALL(dup)
635: b8 0a 00 00 00 mov $0xa,%eax
63a: cd 40 int $0x40
63c: c3 ret
0000063d <getpid>:
SYSCALL(getpid)
63d: b8 0b 00 00 00 mov $0xb,%eax
642: cd 40 int $0x40
644: c3 ret
00000645 <sbrk>:
SYSCALL(sbrk)
645: b8 0c 00 00 00 mov $0xc,%eax
64a: cd 40 int $0x40
64c: c3 ret
0000064d <sleep>:
SYSCALL(sleep)
64d: b8 0d 00 00 00 mov $0xd,%eax
652: cd 40 int $0x40
654: c3 ret
00000655 <uptime>:
SYSCALL(uptime)
655: b8 0e 00 00 00 mov $0xe,%eax
65a: cd 40 int $0x40
65c: c3 ret
0000065d <select>:
SYSCALL(select)
65d: b8 16 00 00 00 mov $0x16,%eax
662: cd 40 int $0x40
664: c3 ret
00000665 <arp>:
SYSCALL(arp)
665: b8 17 00 00 00 mov $0x17,%eax
66a: cd 40 int $0x40
66c: c3 ret
0000066d <arpserv>:
SYSCALL(arpserv)
66d: b8 18 00 00 00 mov $0x18,%eax
672: cd 40 int $0x40
674: c3 ret
00000675 <arp_receive>:
SYSCALL(arp_receive)
675: b8 19 00 00 00 mov $0x19,%eax
67a: cd 40 int $0x40
67c: c3 ret
0000067d <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
67d: 55 push %ebp
67e: 89 e5 mov %esp,%ebp
680: 83 ec 18 sub $0x18,%esp
683: 8b 45 0c mov 0xc(%ebp),%eax
686: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
689: 83 ec 04 sub $0x4,%esp
68c: 6a 01 push $0x1
68e: 8d 45 f4 lea -0xc(%ebp),%eax
691: 50 push %eax
692: ff 75 08 pushl 0x8(%ebp)
695: e8 43 ff ff ff call 5dd <write>
69a: 83 c4 10 add $0x10,%esp
}
69d: 90 nop
69e: c9 leave
69f: c3 ret
000006a0 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
6a0: 55 push %ebp
6a1: 89 e5 mov %esp,%ebp
6a3: 83 ec 28 sub $0x28,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
6a6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
6ad: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
6b1: 74 17 je 6ca <printint+0x2a>
6b3: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
6b7: 79 11 jns 6ca <printint+0x2a>
neg = 1;
6b9: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
6c0: 8b 45 0c mov 0xc(%ebp),%eax
6c3: f7 d8 neg %eax
6c5: 89 45 ec mov %eax,-0x14(%ebp)
6c8: eb 06 jmp 6d0 <printint+0x30>
} else {
x = xx;
6ca: 8b 45 0c mov 0xc(%ebp),%eax
6cd: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
6d0: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
6d7: 8b 4d 10 mov 0x10(%ebp),%ecx
6da: 8b 45 ec mov -0x14(%ebp),%eax
6dd: ba 00 00 00 00 mov $0x0,%edx
6e2: f7 f1 div %ecx
6e4: 89 d1 mov %edx,%ecx
6e6: 8b 45 f4 mov -0xc(%ebp),%eax
6e9: 8d 50 01 lea 0x1(%eax),%edx
6ec: 89 55 f4 mov %edx,-0xc(%ebp)
6ef: 0f b6 91 90 1a 00 00 movzbl 0x1a90(%ecx),%edx
6f6: 88 54 05 dc mov %dl,-0x24(%ebp,%eax,1)
}while((x /= base) != 0);
6fa: 8b 4d 10 mov 0x10(%ebp),%ecx
6fd: 8b 45 ec mov -0x14(%ebp),%eax
700: ba 00 00 00 00 mov $0x0,%edx
705: f7 f1 div %ecx
707: 89 45 ec mov %eax,-0x14(%ebp)
70a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
70e: 75 c7 jne 6d7 <printint+0x37>
if(neg)
710: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
714: 74 2d je 743 <printint+0xa3>
buf[i++] = '-';
716: 8b 45 f4 mov -0xc(%ebp),%eax
719: 8d 50 01 lea 0x1(%eax),%edx
71c: 89 55 f4 mov %edx,-0xc(%ebp)
71f: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
724: eb 1d jmp 743 <printint+0xa3>
putc(fd, buf[i]);
726: 8d 55 dc lea -0x24(%ebp),%edx
729: 8b 45 f4 mov -0xc(%ebp),%eax
72c: 01 d0 add %edx,%eax
72e: 0f b6 00 movzbl (%eax),%eax
731: 0f be c0 movsbl %al,%eax
734: 83 ec 08 sub $0x8,%esp
737: 50 push %eax
738: ff 75 08 pushl 0x8(%ebp)
73b: e8 3d ff ff ff call 67d <putc>
740: 83 c4 10 add $0x10,%esp
while(--i >= 0)
743: 83 6d f4 01 subl $0x1,-0xc(%ebp)
747: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
74b: 79 d9 jns 726 <printint+0x86>
}
74d: 90 nop
74e: c9 leave
74f: c3 ret
00000750 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
750: 55 push %ebp
751: 89 e5 mov %esp,%ebp
753: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
756: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
75d: 8d 45 0c lea 0xc(%ebp),%eax
760: 83 c0 04 add $0x4,%eax
763: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
766: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
76d: e9 59 01 00 00 jmp 8cb <printf+0x17b>
c = fmt[i] & 0xff;
772: 8b 55 0c mov 0xc(%ebp),%edx
775: 8b 45 f0 mov -0x10(%ebp),%eax
778: 01 d0 add %edx,%eax
77a: 0f b6 00 movzbl (%eax),%eax
77d: 0f be c0 movsbl %al,%eax
780: 25 ff 00 00 00 and $0xff,%eax
785: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
788: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
78c: 75 2c jne 7ba <printf+0x6a>
if(c == '%'){
78e: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
792: 75 0c jne 7a0 <printf+0x50>
state = '%';
794: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
79b: e9 27 01 00 00 jmp 8c7 <printf+0x177>
} else {
putc(fd, c);
7a0: 8b 45 e4 mov -0x1c(%ebp),%eax
7a3: 0f be c0 movsbl %al,%eax
7a6: 83 ec 08 sub $0x8,%esp
7a9: 50 push %eax
7aa: ff 75 08 pushl 0x8(%ebp)
7ad: e8 cb fe ff ff call 67d <putc>
7b2: 83 c4 10 add $0x10,%esp
7b5: e9 0d 01 00 00 jmp 8c7 <printf+0x177>
}
} else if(state == '%'){
7ba: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
7be: 0f 85 03 01 00 00 jne 8c7 <printf+0x177>
if(c == 'd'){
7c4: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
7c8: 75 1e jne 7e8 <printf+0x98>
printint(fd, *ap, 10, 1);
7ca: 8b 45 e8 mov -0x18(%ebp),%eax
7cd: 8b 00 mov (%eax),%eax
7cf: 6a 01 push $0x1
7d1: 6a 0a push $0xa
7d3: 50 push %eax
7d4: ff 75 08 pushl 0x8(%ebp)
7d7: e8 c4 fe ff ff call 6a0 <printint>
7dc: 83 c4 10 add $0x10,%esp
ap++;
7df: 83 45 e8 04 addl $0x4,-0x18(%ebp)
7e3: e9 d8 00 00 00 jmp 8c0 <printf+0x170>
} else if(c == 'x' || c == 'p'){
7e8: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
7ec: 74 06 je 7f4 <printf+0xa4>
7ee: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
7f2: 75 1e jne 812 <printf+0xc2>
printint(fd, *ap, 16, 0);
7f4: 8b 45 e8 mov -0x18(%ebp),%eax
7f7: 8b 00 mov (%eax),%eax
7f9: 6a 00 push $0x0
7fb: 6a 10 push $0x10
7fd: 50 push %eax
7fe: ff 75 08 pushl 0x8(%ebp)
801: e8 9a fe ff ff call 6a0 <printint>
806: 83 c4 10 add $0x10,%esp
ap++;
809: 83 45 e8 04 addl $0x4,-0x18(%ebp)
80d: e9 ae 00 00 00 jmp 8c0 <printf+0x170>
} else if(c == 's'){
812: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
816: 75 43 jne 85b <printf+0x10b>
s = (char*)*ap;
818: 8b 45 e8 mov -0x18(%ebp),%eax
81b: 8b 00 mov (%eax),%eax
81d: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
820: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
824: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
828: 75 25 jne 84f <printf+0xff>
s = "(null)";
82a: c7 45 f4 76 13 00 00 movl $0x1376,-0xc(%ebp)
while(*s != 0){
831: eb 1c jmp 84f <printf+0xff>
putc(fd, *s);
833: 8b 45 f4 mov -0xc(%ebp),%eax
836: 0f b6 00 movzbl (%eax),%eax
839: 0f be c0 movsbl %al,%eax
83c: 83 ec 08 sub $0x8,%esp
83f: 50 push %eax
840: ff 75 08 pushl 0x8(%ebp)
843: e8 35 fe ff ff call 67d <putc>
848: 83 c4 10 add $0x10,%esp
s++;
84b: 83 45 f4 01 addl $0x1,-0xc(%ebp)
while(*s != 0){
84f: 8b 45 f4 mov -0xc(%ebp),%eax
852: 0f b6 00 movzbl (%eax),%eax
855: 84 c0 test %al,%al
857: 75 da jne 833 <printf+0xe3>
859: eb 65 jmp 8c0 <printf+0x170>
}
} else if(c == 'c'){
85b: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
85f: 75 1d jne 87e <printf+0x12e>
putc(fd, *ap);
861: 8b 45 e8 mov -0x18(%ebp),%eax
864: 8b 00 mov (%eax),%eax
866: 0f be c0 movsbl %al,%eax
869: 83 ec 08 sub $0x8,%esp
86c: 50 push %eax
86d: ff 75 08 pushl 0x8(%ebp)
870: e8 08 fe ff ff call 67d <putc>
875: 83 c4 10 add $0x10,%esp
ap++;
878: 83 45 e8 04 addl $0x4,-0x18(%ebp)
87c: eb 42 jmp 8c0 <printf+0x170>
} else if(c == '%'){
87e: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
882: 75 17 jne 89b <printf+0x14b>
putc(fd, c);
884: 8b 45 e4 mov -0x1c(%ebp),%eax
887: 0f be c0 movsbl %al,%eax
88a: 83 ec 08 sub $0x8,%esp
88d: 50 push %eax
88e: ff 75 08 pushl 0x8(%ebp)
891: e8 e7 fd ff ff call 67d <putc>
896: 83 c4 10 add $0x10,%esp
899: eb 25 jmp 8c0 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
89b: 83 ec 08 sub $0x8,%esp
89e: 6a 25 push $0x25
8a0: ff 75 08 pushl 0x8(%ebp)
8a3: e8 d5 fd ff ff call 67d <putc>
8a8: 83 c4 10 add $0x10,%esp
putc(fd, c);
8ab: 8b 45 e4 mov -0x1c(%ebp),%eax
8ae: 0f be c0 movsbl %al,%eax
8b1: 83 ec 08 sub $0x8,%esp
8b4: 50 push %eax
8b5: ff 75 08 pushl 0x8(%ebp)
8b8: e8 c0 fd ff ff call 67d <putc>
8bd: 83 c4 10 add $0x10,%esp
}
state = 0;
8c0: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
for(i = 0; fmt[i]; i++){
8c7: 83 45 f0 01 addl $0x1,-0x10(%ebp)
8cb: 8b 55 0c mov 0xc(%ebp),%edx
8ce: 8b 45 f0 mov -0x10(%ebp),%eax
8d1: 01 d0 add %edx,%eax
8d3: 0f b6 00 movzbl (%eax),%eax
8d6: 84 c0 test %al,%al
8d8: 0f 85 94 fe ff ff jne 772 <printf+0x22>
}
}
}
8de: 90 nop
8df: c9 leave
8e0: c3 ret
000008e1 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
8e1: 55 push %ebp
8e2: 89 e5 mov %esp,%ebp
8e4: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
8e7: 8b 45 08 mov 0x8(%ebp),%eax
8ea: 83 e8 08 sub $0x8,%eax
8ed: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
8f0: a1 c8 1a 00 00 mov 0x1ac8,%eax
8f5: 89 45 fc mov %eax,-0x4(%ebp)
8f8: eb 24 jmp 91e <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
8fa: 8b 45 fc mov -0x4(%ebp),%eax
8fd: 8b 00 mov (%eax),%eax
8ff: 39 45 fc cmp %eax,-0x4(%ebp)
902: 72 12 jb 916 <free+0x35>
904: 8b 45 f8 mov -0x8(%ebp),%eax
907: 3b 45 fc cmp -0x4(%ebp),%eax
90a: 77 24 ja 930 <free+0x4f>
90c: 8b 45 fc mov -0x4(%ebp),%eax
90f: 8b 00 mov (%eax),%eax
911: 39 45 f8 cmp %eax,-0x8(%ebp)
914: 72 1a jb 930 <free+0x4f>
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
916: 8b 45 fc mov -0x4(%ebp),%eax
919: 8b 00 mov (%eax),%eax
91b: 89 45 fc mov %eax,-0x4(%ebp)
91e: 8b 45 f8 mov -0x8(%ebp),%eax
921: 3b 45 fc cmp -0x4(%ebp),%eax
924: 76 d4 jbe 8fa <free+0x19>
926: 8b 45 fc mov -0x4(%ebp),%eax
929: 8b 00 mov (%eax),%eax
92b: 39 45 f8 cmp %eax,-0x8(%ebp)
92e: 73 ca jae 8fa <free+0x19>
break;
if(bp + bp->s.size == p->s.ptr){
930: 8b 45 f8 mov -0x8(%ebp),%eax
933: 8b 40 04 mov 0x4(%eax),%eax
936: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
93d: 8b 45 f8 mov -0x8(%ebp),%eax
940: 01 c2 add %eax,%edx
942: 8b 45 fc mov -0x4(%ebp),%eax
945: 8b 00 mov (%eax),%eax
947: 39 c2 cmp %eax,%edx
949: 75 24 jne 96f <free+0x8e>
bp->s.size += p->s.ptr->s.size;
94b: 8b 45 f8 mov -0x8(%ebp),%eax
94e: 8b 50 04 mov 0x4(%eax),%edx
951: 8b 45 fc mov -0x4(%ebp),%eax
954: 8b 00 mov (%eax),%eax
956: 8b 40 04 mov 0x4(%eax),%eax
959: 01 c2 add %eax,%edx
95b: 8b 45 f8 mov -0x8(%ebp),%eax
95e: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
961: 8b 45 fc mov -0x4(%ebp),%eax
964: 8b 00 mov (%eax),%eax
966: 8b 10 mov (%eax),%edx
968: 8b 45 f8 mov -0x8(%ebp),%eax
96b: 89 10 mov %edx,(%eax)
96d: eb 0a jmp 979 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
96f: 8b 45 fc mov -0x4(%ebp),%eax
972: 8b 10 mov (%eax),%edx
974: 8b 45 f8 mov -0x8(%ebp),%eax
977: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
979: 8b 45 fc mov -0x4(%ebp),%eax
97c: 8b 40 04 mov 0x4(%eax),%eax
97f: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
986: 8b 45 fc mov -0x4(%ebp),%eax
989: 01 d0 add %edx,%eax
98b: 39 45 f8 cmp %eax,-0x8(%ebp)
98e: 75 20 jne 9b0 <free+0xcf>
p->s.size += bp->s.size;
990: 8b 45 fc mov -0x4(%ebp),%eax
993: 8b 50 04 mov 0x4(%eax),%edx
996: 8b 45 f8 mov -0x8(%ebp),%eax
999: 8b 40 04 mov 0x4(%eax),%eax
99c: 01 c2 add %eax,%edx
99e: 8b 45 fc mov -0x4(%ebp),%eax
9a1: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
9a4: 8b 45 f8 mov -0x8(%ebp),%eax
9a7: 8b 10 mov (%eax),%edx
9a9: 8b 45 fc mov -0x4(%ebp),%eax
9ac: 89 10 mov %edx,(%eax)
9ae: eb 08 jmp 9b8 <free+0xd7>
} else
p->s.ptr = bp;
9b0: 8b 45 fc mov -0x4(%ebp),%eax
9b3: 8b 55 f8 mov -0x8(%ebp),%edx
9b6: 89 10 mov %edx,(%eax)
freep = p;
9b8: 8b 45 fc mov -0x4(%ebp),%eax
9bb: a3 c8 1a 00 00 mov %eax,0x1ac8
}
9c0: 90 nop
9c1: c9 leave
9c2: c3 ret
000009c3 <morecore>:
static Header*
morecore(uint nu)
{
9c3: 55 push %ebp
9c4: 89 e5 mov %esp,%ebp
9c6: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
9c9: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
9d0: 77 07 ja 9d9 <morecore+0x16>
nu = 4096;
9d2: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
9d9: 8b 45 08 mov 0x8(%ebp),%eax
9dc: c1 e0 03 shl $0x3,%eax
9df: 83 ec 0c sub $0xc,%esp
9e2: 50 push %eax
9e3: e8 5d fc ff ff call 645 <sbrk>
9e8: 83 c4 10 add $0x10,%esp
9eb: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
9ee: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
9f2: 75 07 jne 9fb <morecore+0x38>
return 0;
9f4: b8 00 00 00 00 mov $0x0,%eax
9f9: eb 26 jmp a21 <morecore+0x5e>
hp = (Header*)p;
9fb: 8b 45 f4 mov -0xc(%ebp),%eax
9fe: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
a01: 8b 45 f0 mov -0x10(%ebp),%eax
a04: 8b 55 08 mov 0x8(%ebp),%edx
a07: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
a0a: 8b 45 f0 mov -0x10(%ebp),%eax
a0d: 83 c0 08 add $0x8,%eax
a10: 83 ec 0c sub $0xc,%esp
a13: 50 push %eax
a14: e8 c8 fe ff ff call 8e1 <free>
a19: 83 c4 10 add $0x10,%esp
return freep;
a1c: a1 c8 1a 00 00 mov 0x1ac8,%eax
}
a21: c9 leave
a22: c3 ret
00000a23 <malloc>:
void*
malloc(uint nbytes)
{
a23: 55 push %ebp
a24: 89 e5 mov %esp,%ebp
a26: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
a29: 8b 45 08 mov 0x8(%ebp),%eax
a2c: 83 c0 07 add $0x7,%eax
a2f: c1 e8 03 shr $0x3,%eax
a32: 83 c0 01 add $0x1,%eax
a35: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
a38: a1 c8 1a 00 00 mov 0x1ac8,%eax
a3d: 89 45 f0 mov %eax,-0x10(%ebp)
a40: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
a44: 75 23 jne a69 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
a46: c7 45 f0 c0 1a 00 00 movl $0x1ac0,-0x10(%ebp)
a4d: 8b 45 f0 mov -0x10(%ebp),%eax
a50: a3 c8 1a 00 00 mov %eax,0x1ac8
a55: a1 c8 1a 00 00 mov 0x1ac8,%eax
a5a: a3 c0 1a 00 00 mov %eax,0x1ac0
base.s.size = 0;
a5f: c7 05 c4 1a 00 00 00 movl $0x0,0x1ac4
a66: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
a69: 8b 45 f0 mov -0x10(%ebp),%eax
a6c: 8b 00 mov (%eax),%eax
a6e: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
a71: 8b 45 f4 mov -0xc(%ebp),%eax
a74: 8b 40 04 mov 0x4(%eax),%eax
a77: 39 45 ec cmp %eax,-0x14(%ebp)
a7a: 77 4d ja ac9 <malloc+0xa6>
if(p->s.size == nunits)
a7c: 8b 45 f4 mov -0xc(%ebp),%eax
a7f: 8b 40 04 mov 0x4(%eax),%eax
a82: 39 45 ec cmp %eax,-0x14(%ebp)
a85: 75 0c jne a93 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
a87: 8b 45 f4 mov -0xc(%ebp),%eax
a8a: 8b 10 mov (%eax),%edx
a8c: 8b 45 f0 mov -0x10(%ebp),%eax
a8f: 89 10 mov %edx,(%eax)
a91: eb 26 jmp ab9 <malloc+0x96>
else {
p->s.size -= nunits;
a93: 8b 45 f4 mov -0xc(%ebp),%eax
a96: 8b 40 04 mov 0x4(%eax),%eax
a99: 2b 45 ec sub -0x14(%ebp),%eax
a9c: 89 c2 mov %eax,%edx
a9e: 8b 45 f4 mov -0xc(%ebp),%eax
aa1: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
aa4: 8b 45 f4 mov -0xc(%ebp),%eax
aa7: 8b 40 04 mov 0x4(%eax),%eax
aaa: c1 e0 03 shl $0x3,%eax
aad: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
ab0: 8b 45 f4 mov -0xc(%ebp),%eax
ab3: 8b 55 ec mov -0x14(%ebp),%edx
ab6: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
ab9: 8b 45 f0 mov -0x10(%ebp),%eax
abc: a3 c8 1a 00 00 mov %eax,0x1ac8
return (void*)(p + 1);
ac1: 8b 45 f4 mov -0xc(%ebp),%eax
ac4: 83 c0 08 add $0x8,%eax
ac7: eb 3b jmp b04 <malloc+0xe1>
}
if(p == freep)
ac9: a1 c8 1a 00 00 mov 0x1ac8,%eax
ace: 39 45 f4 cmp %eax,-0xc(%ebp)
ad1: 75 1e jne af1 <malloc+0xce>
if((p = morecore(nunits)) == 0)
ad3: 83 ec 0c sub $0xc,%esp
ad6: ff 75 ec pushl -0x14(%ebp)
ad9: e8 e5 fe ff ff call 9c3 <morecore>
ade: 83 c4 10 add $0x10,%esp
ae1: 89 45 f4 mov %eax,-0xc(%ebp)
ae4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
ae8: 75 07 jne af1 <malloc+0xce>
return 0;
aea: b8 00 00 00 00 mov $0x0,%eax
aef: eb 13 jmp b04 <malloc+0xe1>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
af1: 8b 45 f4 mov -0xc(%ebp),%eax
af4: 89 45 f0 mov %eax,-0x10(%ebp)
af7: 8b 45 f4 mov -0xc(%ebp),%eax
afa: 8b 00 mov (%eax),%eax
afc: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
aff: e9 6d ff ff ff jmp a71 <malloc+0x4e>
}
}
b04: c9 leave
b05: c3 ret
00000b06 <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
b06: 55 push %ebp
b07: 89 e5 mov %esp,%ebp
b09: 53 push %ebx
b0a: 83 ec 14 sub $0x14,%esp
b0d: 8b 45 10 mov 0x10(%ebp),%eax
b10: 89 45 f0 mov %eax,-0x10(%ebp)
b13: 8b 45 14 mov 0x14(%ebp),%eax
b16: 89 45 f4 mov %eax,-0xc(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base)
b19: 8b 45 18 mov 0x18(%ebp),%eax
b1c: ba 00 00 00 00 mov $0x0,%edx
b21: 39 55 f4 cmp %edx,-0xc(%ebp)
b24: 72 55 jb b7b <printnum+0x75>
b26: 39 55 f4 cmp %edx,-0xc(%ebp)
b29: 77 05 ja b30 <printnum+0x2a>
b2b: 39 45 f0 cmp %eax,-0x10(%ebp)
b2e: 72 4b jb b7b <printnum+0x75>
printnum(putch, putdat, num / base, base, width - 1, padc);
b30: 8b 45 1c mov 0x1c(%ebp),%eax
b33: 8d 58 ff lea -0x1(%eax),%ebx
b36: 8b 45 18 mov 0x18(%ebp),%eax
b39: ba 00 00 00 00 mov $0x0,%edx
b3e: 52 push %edx
b3f: 50 push %eax
b40: ff 75 f4 pushl -0xc(%ebp)
b43: ff 75 f0 pushl -0x10(%ebp)
b46: e8 a5 05 00 00 call 10f0 <__udivdi3>
b4b: 83 c4 10 add $0x10,%esp
b4e: 83 ec 04 sub $0x4,%esp
b51: ff 75 20 pushl 0x20(%ebp)
b54: 53 push %ebx
b55: ff 75 18 pushl 0x18(%ebp)
b58: 52 push %edx
b59: 50 push %eax
b5a: ff 75 0c pushl 0xc(%ebp)
b5d: ff 75 08 pushl 0x8(%ebp)
b60: e8 a1 ff ff ff call b06 <printnum>
b65: 83 c4 20 add $0x20,%esp
b68: eb 1b jmp b85 <printnum+0x7f>
else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
b6a: 83 ec 08 sub $0x8,%esp
b6d: ff 75 0c pushl 0xc(%ebp)
b70: ff 75 20 pushl 0x20(%ebp)
b73: 8b 45 08 mov 0x8(%ebp),%eax
b76: ff d0 call *%eax
b78: 83 c4 10 add $0x10,%esp
while (--width > 0)
b7b: 83 6d 1c 01 subl $0x1,0x1c(%ebp)
b7f: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp)
b83: 7f e5 jg b6a <printnum+0x64>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
b85: 8b 4d 18 mov 0x18(%ebp),%ecx
b88: bb 00 00 00 00 mov $0x0,%ebx
b8d: 8b 45 f0 mov -0x10(%ebp),%eax
b90: 8b 55 f4 mov -0xc(%ebp),%edx
b93: 53 push %ebx
b94: 51 push %ecx
b95: 52 push %edx
b96: 50 push %eax
b97: e8 74 06 00 00 call 1210 <__umoddi3>
b9c: 83 c4 10 add $0x10,%esp
b9f: 05 40 14 00 00 add $0x1440,%eax
ba4: 0f b6 00 movzbl (%eax),%eax
ba7: 0f be c0 movsbl %al,%eax
baa: 83 ec 08 sub $0x8,%esp
bad: ff 75 0c pushl 0xc(%ebp)
bb0: 50 push %eax
bb1: 8b 45 08 mov 0x8(%ebp),%eax
bb4: ff d0 call *%eax
bb6: 83 c4 10 add $0x10,%esp
}
bb9: 90 nop
bba: 8b 5d fc mov -0x4(%ebp),%ebx
bbd: c9 leave
bbe: c3 ret
00000bbf <getuint>:
// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
bbf: 55 push %ebp
bc0: 89 e5 mov %esp,%ebp
if (lflag >= 2)
bc2: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
bc6: 7e 14 jle bdc <getuint+0x1d>
return va_arg(*ap, unsigned long long);
bc8: 8b 45 08 mov 0x8(%ebp),%eax
bcb: 8b 00 mov (%eax),%eax
bcd: 8d 48 08 lea 0x8(%eax),%ecx
bd0: 8b 55 08 mov 0x8(%ebp),%edx
bd3: 89 0a mov %ecx,(%edx)
bd5: 8b 50 04 mov 0x4(%eax),%edx
bd8: 8b 00 mov (%eax),%eax
bda: eb 30 jmp c0c <getuint+0x4d>
else if (lflag)
bdc: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
be0: 74 16 je bf8 <getuint+0x39>
return va_arg(*ap, unsigned long);
be2: 8b 45 08 mov 0x8(%ebp),%eax
be5: 8b 00 mov (%eax),%eax
be7: 8d 48 04 lea 0x4(%eax),%ecx
bea: 8b 55 08 mov 0x8(%ebp),%edx
bed: 89 0a mov %ecx,(%edx)
bef: 8b 00 mov (%eax),%eax
bf1: ba 00 00 00 00 mov $0x0,%edx
bf6: eb 14 jmp c0c <getuint+0x4d>
else
return va_arg(*ap, unsigned int);
bf8: 8b 45 08 mov 0x8(%ebp),%eax
bfb: 8b 00 mov (%eax),%eax
bfd: 8d 48 04 lea 0x4(%eax),%ecx
c00: 8b 55 08 mov 0x8(%ebp),%edx
c03: 89 0a mov %ecx,(%edx)
c05: 8b 00 mov (%eax),%eax
c07: ba 00 00 00 00 mov $0x0,%edx
}
c0c: 5d pop %ebp
c0d: c3 ret
00000c0e <getint>:
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
c0e: 55 push %ebp
c0f: 89 e5 mov %esp,%ebp
if (lflag >= 2)
c11: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
c15: 7e 14 jle c2b <getint+0x1d>
return va_arg(*ap, long long);
c17: 8b 45 08 mov 0x8(%ebp),%eax
c1a: 8b 00 mov (%eax),%eax
c1c: 8d 48 08 lea 0x8(%eax),%ecx
c1f: 8b 55 08 mov 0x8(%ebp),%edx
c22: 89 0a mov %ecx,(%edx)
c24: 8b 50 04 mov 0x4(%eax),%edx
c27: 8b 00 mov (%eax),%eax
c29: eb 28 jmp c53 <getint+0x45>
else if (lflag)
c2b: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
c2f: 74 12 je c43 <getint+0x35>
return va_arg(*ap, long);
c31: 8b 45 08 mov 0x8(%ebp),%eax
c34: 8b 00 mov (%eax),%eax
c36: 8d 48 04 lea 0x4(%eax),%ecx
c39: 8b 55 08 mov 0x8(%ebp),%edx
c3c: 89 0a mov %ecx,(%edx)
c3e: 8b 00 mov (%eax),%eax
c40: 99 cltd
c41: eb 10 jmp c53 <getint+0x45>
else
return va_arg(*ap, int);
c43: 8b 45 08 mov 0x8(%ebp),%eax
c46: 8b 00 mov (%eax),%eax
c48: 8d 48 04 lea 0x4(%eax),%ecx
c4b: 8b 55 08 mov 0x8(%ebp),%edx
c4e: 89 0a mov %ecx,(%edx)
c50: 8b 00 mov (%eax),%eax
c52: 99 cltd
}
c53: 5d pop %ebp
c54: c3 ret
00000c55 <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
c55: 55 push %ebp
c56: 89 e5 mov %esp,%ebp
c58: 56 push %esi
c59: 53 push %ebx
c5a: 83 ec 20 sub $0x20,%esp
unsigned long long num;
int base, lflag, width, precision, altflag;
char padc;
while (1) {
while ((ch = *(unsigned char*)fmt++) != '%') {
c5d: eb 17 jmp c76 <vprintfmt+0x21>
if (ch == '\0')
c5f: 85 db test %ebx,%ebx
c61: 0f 84 a0 03 00 00 je 1007 <vprintfmt+0x3b2>
return;
putch(ch, putdat);
c67: 83 ec 08 sub $0x8,%esp
c6a: ff 75 0c pushl 0xc(%ebp)
c6d: 53 push %ebx
c6e: 8b 45 08 mov 0x8(%ebp),%eax
c71: ff d0 call *%eax
c73: 83 c4 10 add $0x10,%esp
while ((ch = *(unsigned char*)fmt++) != '%') {
c76: 8b 45 10 mov 0x10(%ebp),%eax
c79: 8d 50 01 lea 0x1(%eax),%edx
c7c: 89 55 10 mov %edx,0x10(%ebp)
c7f: 0f b6 00 movzbl (%eax),%eax
c82: 0f b6 d8 movzbl %al,%ebx
c85: 83 fb 25 cmp $0x25,%ebx
c88: 75 d5 jne c5f <vprintfmt+0xa>
}
// Process a %-escape sequence
padc = ' ';
c8a: c6 45 db 20 movb $0x20,-0x25(%ebp)
width = -1;
c8e: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
precision = -1;
c95: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
c9c: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
altflag = 0;
ca3: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
reswitch:
switch (ch = *(unsigned char*)fmt++) {
caa: 8b 45 10 mov 0x10(%ebp),%eax
cad: 8d 50 01 lea 0x1(%eax),%edx
cb0: 89 55 10 mov %edx,0x10(%ebp)
cb3: 0f b6 00 movzbl (%eax),%eax
cb6: 0f b6 d8 movzbl %al,%ebx
cb9: 8d 43 dd lea -0x23(%ebx),%eax
cbc: 83 f8 55 cmp $0x55,%eax
cbf: 0f 87 15 03 00 00 ja fda <vprintfmt+0x385>
cc5: 8b 04 85 64 14 00 00 mov 0x1464(,%eax,4),%eax
ccc: ff e0 jmp *%eax
// flag to pad on the right
case '-':
padc = '-';
cce: c6 45 db 2d movb $0x2d,-0x25(%ebp)
goto reswitch;
cd2: eb d6 jmp caa <vprintfmt+0x55>
// flag to pad with 0's instead of spaces
case '0':
padc = '0';
cd4: c6 45 db 30 movb $0x30,-0x25(%ebp)
goto reswitch;
cd8: eb d0 jmp caa <vprintfmt+0x55>
case '5':
case '6':
case '7':
case '8':
case '9':
for (precision = 0;; ++fmt) {
cda: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
precision = precision * 10 + ch - '0';
ce1: 8b 55 e0 mov -0x20(%ebp),%edx
ce4: 89 d0 mov %edx,%eax
ce6: c1 e0 02 shl $0x2,%eax
ce9: 01 d0 add %edx,%eax
ceb: 01 c0 add %eax,%eax
ced: 01 d8 add %ebx,%eax
cef: 83 e8 30 sub $0x30,%eax
cf2: 89 45 e0 mov %eax,-0x20(%ebp)
ch = *fmt;
cf5: 8b 45 10 mov 0x10(%ebp),%eax
cf8: 0f b6 00 movzbl (%eax),%eax
cfb: 0f be d8 movsbl %al,%ebx
if (ch < '0' || ch > '9')
cfe: 83 fb 2f cmp $0x2f,%ebx
d01: 7e 39 jle d3c <vprintfmt+0xe7>
d03: 83 fb 39 cmp $0x39,%ebx
d06: 7f 34 jg d3c <vprintfmt+0xe7>
for (precision = 0;; ++fmt) {
d08: 83 45 10 01 addl $0x1,0x10(%ebp)
precision = precision * 10 + ch - '0';
d0c: eb d3 jmp ce1 <vprintfmt+0x8c>
break;
}
goto process_precision;
case '*':
precision = va_arg(ap, int);
d0e: 8b 45 14 mov 0x14(%ebp),%eax
d11: 8d 50 04 lea 0x4(%eax),%edx
d14: 89 55 14 mov %edx,0x14(%ebp)
d17: 8b 00 mov (%eax),%eax
d19: 89 45 e0 mov %eax,-0x20(%ebp)
goto process_precision;
d1c: eb 1f jmp d3d <vprintfmt+0xe8>
case '.':
if (width < 0)
d1e: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
d22: 79 86 jns caa <vprintfmt+0x55>
width = 0;
d24: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
goto reswitch;
d2b: e9 7a ff ff ff jmp caa <vprintfmt+0x55>
case '#':
altflag = 1;
d30: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp)
goto reswitch;
d37: e9 6e ff ff ff jmp caa <vprintfmt+0x55>
goto process_precision;
d3c: 90 nop
process_precision:
if (width < 0)
d3d: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
d41: 0f 89 63 ff ff ff jns caa <vprintfmt+0x55>
width = precision, precision = -1;
d47: 8b 45 e0 mov -0x20(%ebp),%eax
d4a: 89 45 e4 mov %eax,-0x1c(%ebp)
d4d: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
goto reswitch;
d54: e9 51 ff ff ff jmp caa <vprintfmt+0x55>
// long flag (doubled for long long)
case 'l':
lflag++;
d59: 83 45 e8 01 addl $0x1,-0x18(%ebp)
goto reswitch;
d5d: e9 48 ff ff ff jmp caa <vprintfmt+0x55>
// character
case 'c':
putch(va_arg(ap, int), putdat);
d62: 8b 45 14 mov 0x14(%ebp),%eax
d65: 8d 50 04 lea 0x4(%eax),%edx
d68: 89 55 14 mov %edx,0x14(%ebp)
d6b: 8b 00 mov (%eax),%eax
d6d: 83 ec 08 sub $0x8,%esp
d70: ff 75 0c pushl 0xc(%ebp)
d73: 50 push %eax
d74: 8b 45 08 mov 0x8(%ebp),%eax
d77: ff d0 call *%eax
d79: 83 c4 10 add $0x10,%esp
break;
d7c: e9 81 02 00 00 jmp 1002 <vprintfmt+0x3ad>
// error message
case 'e':
err = va_arg(ap, int);
d81: 8b 45 14 mov 0x14(%ebp),%eax
d84: 8d 50 04 lea 0x4(%eax),%edx
d87: 89 55 14 mov %edx,0x14(%ebp)
d8a: 8b 18 mov (%eax),%ebx
if (err < 0)
d8c: 85 db test %ebx,%ebx
d8e: 79 02 jns d92 <vprintfmt+0x13d>
err = -err;
d90: f7 db neg %ebx
if (err >= MAXERROR || (p = error_string[err]) == NULL)
d92: 83 fb 0f cmp $0xf,%ebx
d95: 7f 0b jg da2 <vprintfmt+0x14d>
d97: 8b 34 9d 00 14 00 00 mov 0x1400(,%ebx,4),%esi
d9e: 85 f6 test %esi,%esi
da0: 75 19 jne dbb <vprintfmt+0x166>
printfmt(putch, putdat, "error %d", err);
da2: 53 push %ebx
da3: 68 51 14 00 00 push $0x1451
da8: ff 75 0c pushl 0xc(%ebp)
dab: ff 75 08 pushl 0x8(%ebp)
dae: e8 5c 02 00 00 call 100f <printfmt>
db3: 83 c4 10 add $0x10,%esp
else
printfmt(putch, putdat, "%s", p);
break;
db6: e9 47 02 00 00 jmp 1002 <vprintfmt+0x3ad>
printfmt(putch, putdat, "%s", p);
dbb: 56 push %esi
dbc: 68 5a 14 00 00 push $0x145a
dc1: ff 75 0c pushl 0xc(%ebp)
dc4: ff 75 08 pushl 0x8(%ebp)
dc7: e8 43 02 00 00 call 100f <printfmt>
dcc: 83 c4 10 add $0x10,%esp
break;
dcf: e9 2e 02 00 00 jmp 1002 <vprintfmt+0x3ad>
// string
case 's':
if ((p = va_arg(ap, char *)) == NULL)
dd4: 8b 45 14 mov 0x14(%ebp),%eax
dd7: 8d 50 04 lea 0x4(%eax),%edx
dda: 89 55 14 mov %edx,0x14(%ebp)
ddd: 8b 30 mov (%eax),%esi
ddf: 85 f6 test %esi,%esi
de1: 75 05 jne de8 <vprintfmt+0x193>
p = "(null)";
de3: be 5d 14 00 00 mov $0x145d,%esi
if (width > 0 && padc != '-')
de8: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
dec: 7e 6f jle e5d <vprintfmt+0x208>
dee: 80 7d db 2d cmpb $0x2d,-0x25(%ebp)
df2: 74 69 je e5d <vprintfmt+0x208>
for (width -= strnlen(p, precision); width > 0; width--)
df4: 8b 45 e0 mov -0x20(%ebp),%eax
df7: 83 ec 08 sub $0x8,%esp
dfa: 50 push %eax
dfb: 56 push %esi
dfc: e8 f1 f5 ff ff call 3f2 <strnlen>
e01: 83 c4 10 add $0x10,%esp
e04: 29 45 e4 sub %eax,-0x1c(%ebp)
e07: eb 17 jmp e20 <vprintfmt+0x1cb>
putch(padc, putdat);
e09: 0f be 45 db movsbl -0x25(%ebp),%eax
e0d: 83 ec 08 sub $0x8,%esp
e10: ff 75 0c pushl 0xc(%ebp)
e13: 50 push %eax
e14: 8b 45 08 mov 0x8(%ebp),%eax
e17: ff d0 call *%eax
e19: 83 c4 10 add $0x10,%esp
for (width -= strnlen(p, precision); width > 0; width--)
e1c: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
e20: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
e24: 7f e3 jg e09 <vprintfmt+0x1b4>
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
e26: eb 35 jmp e5d <vprintfmt+0x208>
if (altflag && (ch < ' ' || ch > '~'))
e28: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
e2c: 74 1c je e4a <vprintfmt+0x1f5>
e2e: 83 fb 1f cmp $0x1f,%ebx
e31: 7e 05 jle e38 <vprintfmt+0x1e3>
e33: 83 fb 7e cmp $0x7e,%ebx
e36: 7e 12 jle e4a <vprintfmt+0x1f5>
putch('?', putdat);
e38: 83 ec 08 sub $0x8,%esp
e3b: ff 75 0c pushl 0xc(%ebp)
e3e: 6a 3f push $0x3f
e40: 8b 45 08 mov 0x8(%ebp),%eax
e43: ff d0 call *%eax
e45: 83 c4 10 add $0x10,%esp
e48: eb 0f jmp e59 <vprintfmt+0x204>
else
putch(ch, putdat);
e4a: 83 ec 08 sub $0x8,%esp
e4d: ff 75 0c pushl 0xc(%ebp)
e50: 53 push %ebx
e51: 8b 45 08 mov 0x8(%ebp),%eax
e54: ff d0 call *%eax
e56: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
e59: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
e5d: 89 f0 mov %esi,%eax
e5f: 8d 70 01 lea 0x1(%eax),%esi
e62: 0f b6 00 movzbl (%eax),%eax
e65: 0f be d8 movsbl %al,%ebx
e68: 85 db test %ebx,%ebx
e6a: 74 26 je e92 <vprintfmt+0x23d>
e6c: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
e70: 78 b6 js e28 <vprintfmt+0x1d3>
e72: 83 6d e0 01 subl $0x1,-0x20(%ebp)
e76: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
e7a: 79 ac jns e28 <vprintfmt+0x1d3>
for (; width > 0; width--)
e7c: eb 14 jmp e92 <vprintfmt+0x23d>
putch(' ', putdat);
e7e: 83 ec 08 sub $0x8,%esp
e81: ff 75 0c pushl 0xc(%ebp)
e84: 6a 20 push $0x20
e86: 8b 45 08 mov 0x8(%ebp),%eax
e89: ff d0 call *%eax
e8b: 83 c4 10 add $0x10,%esp
for (; width > 0; width--)
e8e: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
e92: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
e96: 7f e6 jg e7e <vprintfmt+0x229>
break;
e98: e9 65 01 00 00 jmp 1002 <vprintfmt+0x3ad>
// (signed) decimal
case 'd':
num = getint(&ap, lflag);
e9d: 83 ec 08 sub $0x8,%esp
ea0: ff 75 e8 pushl -0x18(%ebp)
ea3: 8d 45 14 lea 0x14(%ebp),%eax
ea6: 50 push %eax
ea7: e8 62 fd ff ff call c0e <getint>
eac: 83 c4 10 add $0x10,%esp
eaf: 89 45 f0 mov %eax,-0x10(%ebp)
eb2: 89 55 f4 mov %edx,-0xc(%ebp)
if ((long long)num < 0) {
eb5: 8b 45 f0 mov -0x10(%ebp),%eax
eb8: 8b 55 f4 mov -0xc(%ebp),%edx
ebb: 85 d2 test %edx,%edx
ebd: 79 23 jns ee2 <vprintfmt+0x28d>
putch('-', putdat);
ebf: 83 ec 08 sub $0x8,%esp
ec2: ff 75 0c pushl 0xc(%ebp)
ec5: 6a 2d push $0x2d
ec7: 8b 45 08 mov 0x8(%ebp),%eax
eca: ff d0 call *%eax
ecc: 83 c4 10 add $0x10,%esp
num = -(long long)num;
ecf: 8b 45 f0 mov -0x10(%ebp),%eax
ed2: 8b 55 f4 mov -0xc(%ebp),%edx
ed5: f7 d8 neg %eax
ed7: 83 d2 00 adc $0x0,%edx
eda: f7 da neg %edx
edc: 89 45 f0 mov %eax,-0x10(%ebp)
edf: 89 55 f4 mov %edx,-0xc(%ebp)
}
base = 10;
ee2: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
ee9: e9 b6 00 00 00 jmp fa4 <vprintfmt+0x34f>
// unsigned decimal
case 'u':
num = getuint(&ap, lflag);
eee: 83 ec 08 sub $0x8,%esp
ef1: ff 75 e8 pushl -0x18(%ebp)
ef4: 8d 45 14 lea 0x14(%ebp),%eax
ef7: 50 push %eax
ef8: e8 c2 fc ff ff call bbf <getuint>
efd: 83 c4 10 add $0x10,%esp
f00: 89 45 f0 mov %eax,-0x10(%ebp)
f03: 89 55 f4 mov %edx,-0xc(%ebp)
base = 10;
f06: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
f0d: e9 92 00 00 00 jmp fa4 <vprintfmt+0x34f>
// (unsigned) octal
case 'o':
// Replace this with your code
putch('X', putdat);
f12: 83 ec 08 sub $0x8,%esp
f15: ff 75 0c pushl 0xc(%ebp)
f18: 6a 58 push $0x58
f1a: 8b 45 08 mov 0x8(%ebp),%eax
f1d: ff d0 call *%eax
f1f: 83 c4 10 add $0x10,%esp
putch('X', putdat);
f22: 83 ec 08 sub $0x8,%esp
f25: ff 75 0c pushl 0xc(%ebp)
f28: 6a 58 push $0x58
f2a: 8b 45 08 mov 0x8(%ebp),%eax
f2d: ff d0 call *%eax
f2f: 83 c4 10 add $0x10,%esp
putch('X', putdat);
f32: 83 ec 08 sub $0x8,%esp
f35: ff 75 0c pushl 0xc(%ebp)
f38: 6a 58 push $0x58
f3a: 8b 45 08 mov 0x8(%ebp),%eax
f3d: ff d0 call *%eax
f3f: 83 c4 10 add $0x10,%esp
break;
f42: e9 bb 00 00 00 jmp 1002 <vprintfmt+0x3ad>
// pointer
case 'p':
putch('0', putdat);
f47: 83 ec 08 sub $0x8,%esp
f4a: ff 75 0c pushl 0xc(%ebp)
f4d: 6a 30 push $0x30
f4f: 8b 45 08 mov 0x8(%ebp),%eax
f52: ff d0 call *%eax
f54: 83 c4 10 add $0x10,%esp
putch('x', putdat);
f57: 83 ec 08 sub $0x8,%esp
f5a: ff 75 0c pushl 0xc(%ebp)
f5d: 6a 78 push $0x78
f5f: 8b 45 08 mov 0x8(%ebp),%eax
f62: ff d0 call *%eax
f64: 83 c4 10 add $0x10,%esp
num = (unsigned long long)
(uint)va_arg(ap, void *);
f67: 8b 45 14 mov 0x14(%ebp),%eax
f6a: 8d 50 04 lea 0x4(%eax),%edx
f6d: 89 55 14 mov %edx,0x14(%ebp)
f70: 8b 00 mov (%eax),%eax
num = (unsigned long long)
f72: 89 45 f0 mov %eax,-0x10(%ebp)
f75: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
base = 16;
f7c: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
goto number;
f83: eb 1f jmp fa4 <vprintfmt+0x34f>
// (unsigned) hexadecimal
case 'x':
num = getuint(&ap, lflag);
f85: 83 ec 08 sub $0x8,%esp
f88: ff 75 e8 pushl -0x18(%ebp)
f8b: 8d 45 14 lea 0x14(%ebp),%eax
f8e: 50 push %eax
f8f: e8 2b fc ff ff call bbf <getuint>
f94: 83 c4 10 add $0x10,%esp
f97: 89 45 f0 mov %eax,-0x10(%ebp)
f9a: 89 55 f4 mov %edx,-0xc(%ebp)
base = 16;
f9d: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
number:
printnum(putch, putdat, num, base, width, padc);
fa4: 0f be 55 db movsbl -0x25(%ebp),%edx
fa8: 8b 45 ec mov -0x14(%ebp),%eax
fab: 83 ec 04 sub $0x4,%esp
fae: 52 push %edx
faf: ff 75 e4 pushl -0x1c(%ebp)
fb2: 50 push %eax
fb3: ff 75 f4 pushl -0xc(%ebp)
fb6: ff 75 f0 pushl -0x10(%ebp)
fb9: ff 75 0c pushl 0xc(%ebp)
fbc: ff 75 08 pushl 0x8(%ebp)
fbf: e8 42 fb ff ff call b06 <printnum>
fc4: 83 c4 20 add $0x20,%esp
break;
fc7: eb 39 jmp 1002 <vprintfmt+0x3ad>
// escaped '%' character
case '%':
putch(ch, putdat);
fc9: 83 ec 08 sub $0x8,%esp
fcc: ff 75 0c pushl 0xc(%ebp)
fcf: 53 push %ebx
fd0: 8b 45 08 mov 0x8(%ebp),%eax
fd3: ff d0 call *%eax
fd5: 83 c4 10 add $0x10,%esp
break;
fd8: eb 28 jmp 1002 <vprintfmt+0x3ad>
// unrecognized escape sequence - just print it literally
default:
putch('%', putdat);
fda: 83 ec 08 sub $0x8,%esp
fdd: ff 75 0c pushl 0xc(%ebp)
fe0: 6a 25 push $0x25
fe2: 8b 45 08 mov 0x8(%ebp),%eax
fe5: ff d0 call *%eax
fe7: 83 c4 10 add $0x10,%esp
for (fmt--; fmt[-1] != '%'; fmt--)
fea: 83 6d 10 01 subl $0x1,0x10(%ebp)
fee: eb 04 jmp ff4 <vprintfmt+0x39f>
ff0: 83 6d 10 01 subl $0x1,0x10(%ebp)
ff4: 8b 45 10 mov 0x10(%ebp),%eax
ff7: 83 e8 01 sub $0x1,%eax
ffa: 0f b6 00 movzbl (%eax),%eax
ffd: 3c 25 cmp $0x25,%al
fff: 75 ef jne ff0 <vprintfmt+0x39b>
/* do nothing */;
break;
1001: 90 nop
while ((ch = *(unsigned char*)fmt++) != '%') {
1002: e9 6f fc ff ff jmp c76 <vprintfmt+0x21>
return;
1007: 90 nop
}
}
}
1008: 8d 65 f8 lea -0x8(%ebp),%esp
100b: 5b pop %ebx
100c: 5e pop %esi
100d: 5d pop %ebp
100e: c3 ret
0000100f <printfmt>:
void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
100f: 55 push %ebp
1010: 89 e5 mov %esp,%ebp
1012: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
1015: 8d 45 14 lea 0x14(%ebp),%eax
1018: 89 45 f4 mov %eax,-0xc(%ebp)
vprintfmt(putch, putdat, fmt, ap);
101b: 8b 45 f4 mov -0xc(%ebp),%eax
101e: 50 push %eax
101f: ff 75 10 pushl 0x10(%ebp)
1022: ff 75 0c pushl 0xc(%ebp)
1025: ff 75 08 pushl 0x8(%ebp)
1028: e8 28 fc ff ff call c55 <vprintfmt>
102d: 83 c4 10 add $0x10,%esp
va_end(ap);
}
1030: 90 nop
1031: c9 leave
1032: c3 ret
00001033 <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
1033: 55 push %ebp
1034: 89 e5 mov %esp,%ebp
b->cnt++;
1036: 8b 45 0c mov 0xc(%ebp),%eax
1039: 8b 40 08 mov 0x8(%eax),%eax
103c: 8d 50 01 lea 0x1(%eax),%edx
103f: 8b 45 0c mov 0xc(%ebp),%eax
1042: 89 50 08 mov %edx,0x8(%eax)
if (b->buf < b->ebuf)
1045: 8b 45 0c mov 0xc(%ebp),%eax
1048: 8b 10 mov (%eax),%edx
104a: 8b 45 0c mov 0xc(%ebp),%eax
104d: 8b 40 04 mov 0x4(%eax),%eax
1050: 39 c2 cmp %eax,%edx
1052: 73 12 jae 1066 <sprintputch+0x33>
*b->buf++ = ch;
1054: 8b 45 0c mov 0xc(%ebp),%eax
1057: 8b 00 mov (%eax),%eax
1059: 8d 48 01 lea 0x1(%eax),%ecx
105c: 8b 55 0c mov 0xc(%ebp),%edx
105f: 89 0a mov %ecx,(%edx)
1061: 8b 55 08 mov 0x8(%ebp),%edx
1064: 88 10 mov %dl,(%eax)
}
1066: 90 nop
1067: 5d pop %ebp
1068: c3 ret
00001069 <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
1069: 55 push %ebp
106a: 89 e5 mov %esp,%ebp
106c: 83 ec 18 sub $0x18,%esp
struct sprintbuf b = { buf, buf+n-1, 0 };
106f: 8b 45 08 mov 0x8(%ebp),%eax
1072: 89 45 ec mov %eax,-0x14(%ebp)
1075: 8b 45 0c mov 0xc(%ebp),%eax
1078: 8d 50 ff lea -0x1(%eax),%edx
107b: 8b 45 08 mov 0x8(%ebp),%eax
107e: 01 d0 add %edx,%eax
1080: 89 45 f0 mov %eax,-0x10(%ebp)
1083: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
108a: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
108e: 74 06 je 1096 <vsnprintf+0x2d>
1090: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
1094: 7f 07 jg 109d <vsnprintf+0x34>
return -E_INVAL;
1096: b8 fd ff ff ff mov $0xfffffffd,%eax
109b: eb 20 jmp 10bd <vsnprintf+0x54>
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
109d: ff 75 14 pushl 0x14(%ebp)
10a0: ff 75 10 pushl 0x10(%ebp)
10a3: 8d 45 ec lea -0x14(%ebp),%eax
10a6: 50 push %eax
10a7: 68 33 10 00 00 push $0x1033
10ac: e8 a4 fb ff ff call c55 <vprintfmt>
10b1: 83 c4 10 add $0x10,%esp
// null terminate the buffer
*b.buf = '\0';
10b4: 8b 45 ec mov -0x14(%ebp),%eax
10b7: c6 00 00 movb $0x0,(%eax)
return b.cnt;
10ba: 8b 45 f4 mov -0xc(%ebp),%eax
}
10bd: c9 leave
10be: c3 ret
000010bf <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
10bf: 55 push %ebp
10c0: 89 e5 mov %esp,%ebp
10c2: 83 ec 18 sub $0x18,%esp
va_list ap;
int rc;
va_start(ap, fmt);
10c5: 8d 45 14 lea 0x14(%ebp),%eax
10c8: 89 45 f0 mov %eax,-0x10(%ebp)
rc = vsnprintf(buf, n, fmt, ap);
10cb: 8b 45 f0 mov -0x10(%ebp),%eax
10ce: 50 push %eax
10cf: ff 75 10 pushl 0x10(%ebp)
10d2: ff 75 0c pushl 0xc(%ebp)
10d5: ff 75 08 pushl 0x8(%ebp)
10d8: e8 8c ff ff ff call 1069 <vsnprintf>
10dd: 83 c4 10 add $0x10,%esp
10e0: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return rc;
10e3: 8b 45 f4 mov -0xc(%ebp),%eax
}
10e6: c9 leave
10e7: c3 ret
10e8: 66 90 xchg %ax,%ax
10ea: 66 90 xchg %ax,%ax
10ec: 66 90 xchg %ax,%ax
10ee: 66 90 xchg %ax,%ax
000010f0 <__udivdi3>:
10f0: 55 push %ebp
10f1: 57 push %edi
10f2: 56 push %esi
10f3: 53 push %ebx
10f4: 83 ec 1c sub $0x1c,%esp
10f7: 8b 54 24 3c mov 0x3c(%esp),%edx
10fb: 8b 6c 24 30 mov 0x30(%esp),%ebp
10ff: 8b 74 24 34 mov 0x34(%esp),%esi
1103: 8b 5c 24 38 mov 0x38(%esp),%ebx
1107: 85 d2 test %edx,%edx
1109: 75 35 jne 1140 <__udivdi3+0x50>
110b: 39 f3 cmp %esi,%ebx
110d: 0f 87 bd 00 00 00 ja 11d0 <__udivdi3+0xe0>
1113: 85 db test %ebx,%ebx
1115: 89 d9 mov %ebx,%ecx
1117: 75 0b jne 1124 <__udivdi3+0x34>
1119: b8 01 00 00 00 mov $0x1,%eax
111e: 31 d2 xor %edx,%edx
1120: f7 f3 div %ebx
1122: 89 c1 mov %eax,%ecx
1124: 31 d2 xor %edx,%edx
1126: 89 f0 mov %esi,%eax
1128: f7 f1 div %ecx
112a: 89 c6 mov %eax,%esi
112c: 89 e8 mov %ebp,%eax
112e: 89 f7 mov %esi,%edi
1130: f7 f1 div %ecx
1132: 89 fa mov %edi,%edx
1134: 83 c4 1c add $0x1c,%esp
1137: 5b pop %ebx
1138: 5e pop %esi
1139: 5f pop %edi
113a: 5d pop %ebp
113b: c3 ret
113c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1140: 39 f2 cmp %esi,%edx
1142: 77 7c ja 11c0 <__udivdi3+0xd0>
1144: 0f bd fa bsr %edx,%edi
1147: 83 f7 1f xor $0x1f,%edi
114a: 0f 84 98 00 00 00 je 11e8 <__udivdi3+0xf8>
1150: 89 f9 mov %edi,%ecx
1152: b8 20 00 00 00 mov $0x20,%eax
1157: 29 f8 sub %edi,%eax
1159: d3 e2 shl %cl,%edx
115b: 89 54 24 08 mov %edx,0x8(%esp)
115f: 89 c1 mov %eax,%ecx
1161: 89 da mov %ebx,%edx
1163: d3 ea shr %cl,%edx
1165: 8b 4c 24 08 mov 0x8(%esp),%ecx
1169: 09 d1 or %edx,%ecx
116b: 89 f2 mov %esi,%edx
116d: 89 4c 24 08 mov %ecx,0x8(%esp)
1171: 89 f9 mov %edi,%ecx
1173: d3 e3 shl %cl,%ebx
1175: 89 c1 mov %eax,%ecx
1177: d3 ea shr %cl,%edx
1179: 89 f9 mov %edi,%ecx
117b: 89 5c 24 0c mov %ebx,0xc(%esp)
117f: d3 e6 shl %cl,%esi
1181: 89 eb mov %ebp,%ebx
1183: 89 c1 mov %eax,%ecx
1185: d3 eb shr %cl,%ebx
1187: 09 de or %ebx,%esi
1189: 89 f0 mov %esi,%eax
118b: f7 74 24 08 divl 0x8(%esp)
118f: 89 d6 mov %edx,%esi
1191: 89 c3 mov %eax,%ebx
1193: f7 64 24 0c mull 0xc(%esp)
1197: 39 d6 cmp %edx,%esi
1199: 72 0c jb 11a7 <__udivdi3+0xb7>
119b: 89 f9 mov %edi,%ecx
119d: d3 e5 shl %cl,%ebp
119f: 39 c5 cmp %eax,%ebp
11a1: 73 5d jae 1200 <__udivdi3+0x110>
11a3: 39 d6 cmp %edx,%esi
11a5: 75 59 jne 1200 <__udivdi3+0x110>
11a7: 8d 43 ff lea -0x1(%ebx),%eax
11aa: 31 ff xor %edi,%edi
11ac: 89 fa mov %edi,%edx
11ae: 83 c4 1c add $0x1c,%esp
11b1: 5b pop %ebx
11b2: 5e pop %esi
11b3: 5f pop %edi
11b4: 5d pop %ebp
11b5: c3 ret
11b6: 8d 76 00 lea 0x0(%esi),%esi
11b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
11c0: 31 ff xor %edi,%edi
11c2: 31 c0 xor %eax,%eax
11c4: 89 fa mov %edi,%edx
11c6: 83 c4 1c add $0x1c,%esp
11c9: 5b pop %ebx
11ca: 5e pop %esi
11cb: 5f pop %edi
11cc: 5d pop %ebp
11cd: c3 ret
11ce: 66 90 xchg %ax,%ax
11d0: 31 ff xor %edi,%edi
11d2: 89 e8 mov %ebp,%eax
11d4: 89 f2 mov %esi,%edx
11d6: f7 f3 div %ebx
11d8: 89 fa mov %edi,%edx
11da: 83 c4 1c add $0x1c,%esp
11dd: 5b pop %ebx
11de: 5e pop %esi
11df: 5f pop %edi
11e0: 5d pop %ebp
11e1: c3 ret
11e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11e8: 39 f2 cmp %esi,%edx
11ea: 72 06 jb 11f2 <__udivdi3+0x102>
11ec: 31 c0 xor %eax,%eax
11ee: 39 eb cmp %ebp,%ebx
11f0: 77 d2 ja 11c4 <__udivdi3+0xd4>
11f2: b8 01 00 00 00 mov $0x1,%eax
11f7: eb cb jmp 11c4 <__udivdi3+0xd4>
11f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1200: 89 d8 mov %ebx,%eax
1202: 31 ff xor %edi,%edi
1204: eb be jmp 11c4 <__udivdi3+0xd4>
1206: 66 90 xchg %ax,%ax
1208: 66 90 xchg %ax,%ax
120a: 66 90 xchg %ax,%ax
120c: 66 90 xchg %ax,%ax
120e: 66 90 xchg %ax,%ax
00001210 <__umoddi3>:
1210: 55 push %ebp
1211: 57 push %edi
1212: 56 push %esi
1213: 53 push %ebx
1214: 83 ec 1c sub $0x1c,%esp
1217: 8b 6c 24 3c mov 0x3c(%esp),%ebp
121b: 8b 74 24 30 mov 0x30(%esp),%esi
121f: 8b 5c 24 34 mov 0x34(%esp),%ebx
1223: 8b 7c 24 38 mov 0x38(%esp),%edi
1227: 85 ed test %ebp,%ebp
1229: 89 f0 mov %esi,%eax
122b: 89 da mov %ebx,%edx
122d: 75 19 jne 1248 <__umoddi3+0x38>
122f: 39 df cmp %ebx,%edi
1231: 0f 86 b1 00 00 00 jbe 12e8 <__umoddi3+0xd8>
1237: f7 f7 div %edi
1239: 89 d0 mov %edx,%eax
123b: 31 d2 xor %edx,%edx
123d: 83 c4 1c add $0x1c,%esp
1240: 5b pop %ebx
1241: 5e pop %esi
1242: 5f pop %edi
1243: 5d pop %ebp
1244: c3 ret
1245: 8d 76 00 lea 0x0(%esi),%esi
1248: 39 dd cmp %ebx,%ebp
124a: 77 f1 ja 123d <__umoddi3+0x2d>
124c: 0f bd cd bsr %ebp,%ecx
124f: 83 f1 1f xor $0x1f,%ecx
1252: 89 4c 24 04 mov %ecx,0x4(%esp)
1256: 0f 84 b4 00 00 00 je 1310 <__umoddi3+0x100>
125c: b8 20 00 00 00 mov $0x20,%eax
1261: 89 c2 mov %eax,%edx
1263: 8b 44 24 04 mov 0x4(%esp),%eax
1267: 29 c2 sub %eax,%edx
1269: 89 c1 mov %eax,%ecx
126b: 89 f8 mov %edi,%eax
126d: d3 e5 shl %cl,%ebp
126f: 89 d1 mov %edx,%ecx
1271: 89 54 24 0c mov %edx,0xc(%esp)
1275: d3 e8 shr %cl,%eax
1277: 09 c5 or %eax,%ebp
1279: 8b 44 24 04 mov 0x4(%esp),%eax
127d: 89 c1 mov %eax,%ecx
127f: d3 e7 shl %cl,%edi
1281: 89 d1 mov %edx,%ecx
1283: 89 7c 24 08 mov %edi,0x8(%esp)
1287: 89 df mov %ebx,%edi
1289: d3 ef shr %cl,%edi
128b: 89 c1 mov %eax,%ecx
128d: 89 f0 mov %esi,%eax
128f: d3 e3 shl %cl,%ebx
1291: 89 d1 mov %edx,%ecx
1293: 89 fa mov %edi,%edx
1295: d3 e8 shr %cl,%eax
1297: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
129c: 09 d8 or %ebx,%eax
129e: f7 f5 div %ebp
12a0: d3 e6 shl %cl,%esi
12a2: 89 d1 mov %edx,%ecx
12a4: f7 64 24 08 mull 0x8(%esp)
12a8: 39 d1 cmp %edx,%ecx
12aa: 89 c3 mov %eax,%ebx
12ac: 89 d7 mov %edx,%edi
12ae: 72 06 jb 12b6 <__umoddi3+0xa6>
12b0: 75 0e jne 12c0 <__umoddi3+0xb0>
12b2: 39 c6 cmp %eax,%esi
12b4: 73 0a jae 12c0 <__umoddi3+0xb0>
12b6: 2b 44 24 08 sub 0x8(%esp),%eax
12ba: 19 ea sbb %ebp,%edx
12bc: 89 d7 mov %edx,%edi
12be: 89 c3 mov %eax,%ebx
12c0: 89 ca mov %ecx,%edx
12c2: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
12c7: 29 de sub %ebx,%esi
12c9: 19 fa sbb %edi,%edx
12cb: 8b 5c 24 04 mov 0x4(%esp),%ebx
12cf: 89 d0 mov %edx,%eax
12d1: d3 e0 shl %cl,%eax
12d3: 89 d9 mov %ebx,%ecx
12d5: d3 ee shr %cl,%esi
12d7: d3 ea shr %cl,%edx
12d9: 09 f0 or %esi,%eax
12db: 83 c4 1c add $0x1c,%esp
12de: 5b pop %ebx
12df: 5e pop %esi
12e0: 5f pop %edi
12e1: 5d pop %ebp
12e2: c3 ret
12e3: 90 nop
12e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
12e8: 85 ff test %edi,%edi
12ea: 89 f9 mov %edi,%ecx
12ec: 75 0b jne 12f9 <__umoddi3+0xe9>
12ee: b8 01 00 00 00 mov $0x1,%eax
12f3: 31 d2 xor %edx,%edx
12f5: f7 f7 div %edi
12f7: 89 c1 mov %eax,%ecx
12f9: 89 d8 mov %ebx,%eax
12fb: 31 d2 xor %edx,%edx
12fd: f7 f1 div %ecx
12ff: 89 f0 mov %esi,%eax
1301: f7 f1 div %ecx
1303: e9 31 ff ff ff jmp 1239 <__umoddi3+0x29>
1308: 90 nop
1309: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1310: 39 dd cmp %ebx,%ebp
1312: 72 08 jb 131c <__umoddi3+0x10c>
1314: 39 f7 cmp %esi,%edi
1316: 0f 87 21 ff ff ff ja 123d <__umoddi3+0x2d>
131c: 89 da mov %ebx,%edx
131e: 89 f0 mov %esi,%eax
1320: 29 f8 sub %edi,%eax
1322: 19 ea sbb %ebp,%edx
1324: e9 14 ff ff ff jmp 123d <__umoddi3+0x2d>
|
programs/oeis/270/A270031.asm | neoneye/loda | 22 | 93845 | <filename>programs/oeis/270/A270031.asm
; A270031: a(n) is the smallest b for which the base-b representation of n contains at least one 5 (or 0 if no such base exists).
; 0,0,0,0,6,0,0,0,0,0,6,7,8,9,10,11,6,13,7,15,8,17,6,19,10,7,11,23,6,6,6,6,6,6,6,7,7,7,7,7,6,8,8,8,8,8,6,9,9,9,9,9,6,7,10,10,10,10,6,11,7,11,11,11,6,6,6,6,6,6,6,13,13,13,7,13,6,14,14,14,14,7,6,7,7,7,7,7,6,7,16,16,8,16,6,7,17,17,17,17
add $0,1
mov $2,2
mov $3,$0
mov $4,$0
lpb $3
mov $5,$4
lpb $5
add $1,$2
lpb $0
mov $6,$0
div $0,$2
mod $6,$2
cmp $6,5
sub $5,$6
lpe
lpe
add $2,1
mov $6,$0
cmp $6,1
cmp $6,0
sub $3,$6
lpe
mov $0,$1
|
message/generation/swift-mt-generation/repository/SR2018/grammars/SwiftMtParser_MT565.g4 | Yanick-Salzmann/message-converter-c | 0 | 2697 | grammar SwiftMtParser_MT565;
@lexer::header {
#include "repository/ISwiftMtParser.h"
#include "SwiftMtMessage.pb.h"
#include <vector>
#include <string>
#include "BaseErrorListener.h"
}
@parser::header {
#include "repository/ISwiftMtParser.h"
#include "SwiftMtMessage.pb.h"
#include <vector>
#include <string>
#include "BaseErrorListener.h"
#include "SwiftMtParser_MT565Lexer.h"
}
@parser::members {
public:
typedef SwiftMtParser_MT565Lexer tLexer;
typedef SwiftMtParser_MT565Parser tParser;
private:
std::vector<std::string> _errors;
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 };
public:
class Helper : public ISwiftMtParser {
public:
bool parse_message(const std::string& message, std::vector<std::string>& errors, SwiftMtMessage& out_message) override {
antlr4::ANTLRInputStream stream{message};
tLexer lexer{&stream};
antlr4::CommonTokenStream token_stream{&lexer};
tParser parser{&token_stream};
return parser.process(errors, out_message);
}
};
private:
SwiftMtMessage _message_builder{};
bool process(std::vector<std::string>& errors, SwiftMtMessage& out_message) {
_errors.clear();
removeErrorListeners();
addErrorListener(&_error_listener);
_message_builder = SwiftMtMessage{};
message();
if(!_errors.empty()) {
errors.insert(errors.end(), _errors.begin(), _errors.end());
return false;
}
out_message = _message_builder;
return true;
}
public:
[[nodiscard]] SwiftMtMessage parsed_message() const {
return _message_builder;
}
}
message : bh ah uh? mt tr? EOF;
bh : TAG_BH bh_content RBRACE ;
bh_content : ~(RBRACE)+ ;
ah : TAG_AH ah_content RBRACE ;
ah_content : ~( RBRACE )+ ;
uh : TAG_UH sys_block RBRACE ;
tr : TAG_TR sys_block RBRACE ;
sys_block : sys_element+ ;
sys_element : LBRACE sys_element_key COLON sys_element_content RBRACE ;
sys_element_key : ~( COLON | RBRACE )+ ;
sys_element_content : ~( RBRACE )+ ;
mt returns [message::definition::swift::mt::MessageText elem] @after { _message_builder.mutable_msg_text()->MergeFrom($elem); }
: TAG_MT seq_A seq_B seq_C* seq_D seq_E? MT_END;
seq_A returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("A"); } :
fld_16R_A { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_A.fld); }
fld_20C_A+ { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_20C_A.fld); }
fld_23G_A { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_23G_A.fld); }
fld_22F_A { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_22F_A.fld); }
fld_98a_A? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_98a_A.fld); }
seq_A1* { $elem.mutable_objects()->Add()->mutable_sequence()->MergeFrom($seq_A1.elem); }
fld_16S_A { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_A.fld); }
;
seq_A1 returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("A1"); } :
fld_16R_A1 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_A1.fld); }
fld_22F_A1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_22F_A1.fld); }
fld_13a_A1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_13a_A1.fld); }
fld_20C_A1 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_20C_A1.fld); }
fld_16S_A1 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_A1.fld); }
;
seq_B returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("B"); } :
fld_16R_B { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_B.fld); }
fld_35B_B? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_35B_B.fld); }
seq_B1? { $elem.mutable_objects()->Add()->mutable_sequence()->MergeFrom($seq_B1.elem); }
seq_B2 { $elem.mutable_objects()->Add()->mutable_sequence()->MergeFrom($seq_B2.elem); }
fld_16S_B { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_B.fld); }
;
seq_B1 returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("B1"); } :
fld_16R_B1 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_B1.fld); }
fld_94B_B1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_94B_B1.fld); }
fld_22F_B1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_22F_B1.fld); }
fld_12a_B1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_12a_B1.fld); }
fld_11A_B1? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_11A_B1.fld); }
fld_98A_B1* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_98A_B1.fld); }
fld_92A_B1* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_92A_B1.fld); }
fld_36B_B1* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_36B_B1.fld); }
fld_16S_B1 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_B1.fld); }
;
seq_B2 returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("B2"); } :
fld_16R_B2 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_B2.fld); }
fld_95a_B2? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_95a_B2.fld); }
fld_97A_B2 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_97A_B2.fld); }
fld_94a_B2? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_94a_B2.fld); }
fld_93a_B2* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_93a_B2.fld); }
fld_16S_B2 { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_B2.fld); }
;
seq_C returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("C"); } :
fld_16R_C { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_C.fld); }
fld_95a_C+ { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_95a_C.fld); }
fld_94C_C* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_94C_C.fld); }
fld_36B_C { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_36B_C.fld); }
fld_22F_C* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_22F_C.fld); }
fld_70E_C* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_70E_C.fld); }
fld_16S_C { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_C.fld); }
;
seq_D returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("D"); } :
fld_16R_D { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_D.fld); }
fld_13A_D { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_13A_D.fld); }
fld_22a_D+ { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_22a_D.fld); }
fld_11A_D* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_11A_D.fld); }
fld_35B_D? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_35B_D.fld); }
fld_36a_D* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_36a_D.fld); }
fld_19B_D? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_19B_D.fld); }
fld_98a_D? { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_98a_D.fld); }
fld_92a_D* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_92a_D.fld); }
fld_90a_D* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_90a_D.fld); }
fld_70E_D* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_70E_D.fld); }
fld_16S_D { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_D.fld); }
;
seq_E returns [message::definition::swift::mt::Sequence elem] @init { $elem.set_tag("E"); } :
fld_16R_E { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16R_E.fld); }
fld_70E_E* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_70E_E.fld); }
fld_95a_E* { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_95a_E.fld); }
fld_16S_E { $elem.mutable_objects()->Add()->mutable_field()->MergeFrom($fld_16S_E.fld); }
;
fld_16R_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_20C_A returns [message::definition::swift::mt::Field fld] :
fld_20C_A_C { $fld.MergeFrom($fld_20C_A_C.fld); }
;
fld_23G_A returns [message::definition::swift::mt::Field fld] :
fld_23G_A_G { $fld.MergeFrom($fld_23G_A_G.fld); }
;
fld_22F_A returns [message::definition::swift::mt::Field fld] :
fld_22F_A_F { $fld.MergeFrom($fld_22F_A_F.fld); }
;
fld_98a_A returns [message::definition::swift::mt::Field fld] :
fld_98a_A_A { $fld.MergeFrom($fld_98a_A_A.fld); }
| fld_98a_A_C { $fld.MergeFrom($fld_98a_A_C.fld); }
;
fld_16R_A1 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_22F_A1 returns [message::definition::swift::mt::Field fld] :
fld_22F_A1_F { $fld.MergeFrom($fld_22F_A1_F.fld); }
;
fld_13a_A1 returns [message::definition::swift::mt::Field fld] :
fld_13a_A1_A { $fld.MergeFrom($fld_13a_A1_A.fld); }
| fld_13a_A1_B { $fld.MergeFrom($fld_13a_A1_B.fld); }
;
fld_20C_A1 returns [message::definition::swift::mt::Field fld] :
fld_20C_A1_C { $fld.MergeFrom($fld_20C_A1_C.fld); }
;
fld_16S_A1 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16S_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16R_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_35B_B returns [message::definition::swift::mt::Field fld] :
fld_35B_B_B { $fld.MergeFrom($fld_35B_B_B.fld); }
;
fld_16R_B1 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_94B_B1 returns [message::definition::swift::mt::Field fld] :
fld_94B_B1_B { $fld.MergeFrom($fld_94B_B1_B.fld); }
;
fld_22F_B1 returns [message::definition::swift::mt::Field fld] :
fld_22F_B1_F { $fld.MergeFrom($fld_22F_B1_F.fld); }
;
fld_12a_B1 returns [message::definition::swift::mt::Field fld] :
fld_12a_B1_A { $fld.MergeFrom($fld_12a_B1_A.fld); }
| fld_12a_B1_C { $fld.MergeFrom($fld_12a_B1_C.fld); }
;
fld_11A_B1 returns [message::definition::swift::mt::Field fld] :
fld_11A_B1_A { $fld.MergeFrom($fld_11A_B1_A.fld); }
;
fld_98A_B1 returns [message::definition::swift::mt::Field fld] :
fld_98A_B1_A { $fld.MergeFrom($fld_98A_B1_A.fld); }
;
fld_92A_B1 returns [message::definition::swift::mt::Field fld] :
fld_92A_B1_A { $fld.MergeFrom($fld_92A_B1_A.fld); }
;
fld_36B_B1 returns [message::definition::swift::mt::Field fld] :
fld_36B_B1_B { $fld.MergeFrom($fld_36B_B1_B.fld); }
;
fld_16S_B1 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16R_B2 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_95a_B2 returns [message::definition::swift::mt::Field fld] :
fld_95a_B2_P { $fld.MergeFrom($fld_95a_B2_P.fld); }
| fld_95a_B2_R { $fld.MergeFrom($fld_95a_B2_R.fld); }
;
fld_97A_B2 returns [message::definition::swift::mt::Field fld] :
fld_97A_B2_A { $fld.MergeFrom($fld_97A_B2_A.fld); }
;
fld_94a_B2 returns [message::definition::swift::mt::Field fld] :
fld_94a_B2_B { $fld.MergeFrom($fld_94a_B2_B.fld); }
| fld_94a_B2_C { $fld.MergeFrom($fld_94a_B2_C.fld); }
| fld_94a_B2_F { $fld.MergeFrom($fld_94a_B2_F.fld); }
;
fld_93a_B2 returns [message::definition::swift::mt::Field fld] :
fld_93a_B2_B { $fld.MergeFrom($fld_93a_B2_B.fld); }
| fld_93a_B2_C { $fld.MergeFrom($fld_93a_B2_C.fld); }
;
fld_16S_B2 returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16S_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16R_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_95a_C returns [message::definition::swift::mt::Field fld] :
fld_95a_C_P { $fld.MergeFrom($fld_95a_C_P.fld); }
| fld_95a_C_R { $fld.MergeFrom($fld_95a_C_R.fld); }
| fld_95a_C_S { $fld.MergeFrom($fld_95a_C_S.fld); }
| fld_95a_C_V { $fld.MergeFrom($fld_95a_C_V.fld); }
;
fld_94C_C returns [message::definition::swift::mt::Field fld] :
fld_94C_C_C { $fld.MergeFrom($fld_94C_C_C.fld); }
;
fld_36B_C returns [message::definition::swift::mt::Field fld] :
fld_36B_C_B { $fld.MergeFrom($fld_36B_C_B.fld); }
;
fld_22F_C returns [message::definition::swift::mt::Field fld] :
fld_22F_C_F { $fld.MergeFrom($fld_22F_C_F.fld); }
;
fld_70E_C returns [message::definition::swift::mt::Field fld] :
fld_70E_C_E { $fld.MergeFrom($fld_70E_C_E.fld); }
;
fld_16S_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16R_D returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_13A_D returns [message::definition::swift::mt::Field fld] :
fld_13A_D_A { $fld.MergeFrom($fld_13A_D_A.fld); }
;
fld_22a_D returns [message::definition::swift::mt::Field fld] :
fld_22a_D_F { $fld.MergeFrom($fld_22a_D_F.fld); }
| fld_22a_D_H { $fld.MergeFrom($fld_22a_D_H.fld); }
;
fld_11A_D returns [message::definition::swift::mt::Field fld] :
fld_11A_D_A { $fld.MergeFrom($fld_11A_D_A.fld); }
;
fld_35B_D returns [message::definition::swift::mt::Field fld] :
fld_35B_D_B { $fld.MergeFrom($fld_35B_D_B.fld); }
;
fld_36a_D returns [message::definition::swift::mt::Field fld] :
fld_36a_D_B { $fld.MergeFrom($fld_36a_D_B.fld); }
| fld_36a_D_C { $fld.MergeFrom($fld_36a_D_C.fld); }
;
fld_19B_D returns [message::definition::swift::mt::Field fld] :
fld_19B_D_B { $fld.MergeFrom($fld_19B_D_B.fld); }
;
fld_98a_D returns [message::definition::swift::mt::Field fld] :
fld_98a_D_A { $fld.MergeFrom($fld_98a_D_A.fld); }
| fld_98a_D_C { $fld.MergeFrom($fld_98a_D_C.fld); }
;
fld_92a_D returns [message::definition::swift::mt::Field fld] :
fld_92a_D_A { $fld.MergeFrom($fld_92a_D_A.fld); }
| fld_92a_D_F { $fld.MergeFrom($fld_92a_D_F.fld); }
| fld_92a_D_R { $fld.MergeFrom($fld_92a_D_R.fld); }
;
fld_90a_D returns [message::definition::swift::mt::Field fld] :
fld_90a_D_A { $fld.MergeFrom($fld_90a_D_A.fld); }
| fld_90a_D_B { $fld.MergeFrom($fld_90a_D_B.fld); }
| fld_90a_D_E { $fld.MergeFrom($fld_90a_D_E.fld); }
| fld_90a_D_F { $fld.MergeFrom($fld_90a_D_F.fld); }
| fld_90a_D_J { $fld.MergeFrom($fld_90a_D_J.fld); }
| fld_90a_D_L { $fld.MergeFrom($fld_90a_D_L.fld); }
;
fld_70E_D returns [message::definition::swift::mt::Field fld] :
fld_70E_D_E { $fld.MergeFrom($fld_70E_D_E.fld); }
;
fld_16S_D returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_16R_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16R"); } :
START_OF_FIELD '16R:' ~(START_OF_FIELD)+;
fld_70E_E returns [message::definition::swift::mt::Field fld] :
fld_70E_E_E { $fld.MergeFrom($fld_70E_E_E.fld); }
;
fld_95a_E returns [message::definition::swift::mt::Field fld] :
fld_95a_E_P { $fld.MergeFrom($fld_95a_E_P.fld); }
| fld_95a_E_Q { $fld.MergeFrom($fld_95a_E_Q.fld); }
| fld_95a_E_R { $fld.MergeFrom($fld_95a_E_R.fld); }
;
fld_16S_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("16S"); } :
START_OF_FIELD '16S:' ~(START_OF_FIELD)+;
fld_20C_A_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("20C"); }:
START_OF_FIELD '20C:' ~(START_OF_FIELD)+ ;
fld_23G_A_G returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("23G"); }:
START_OF_FIELD '23G:' ~(START_OF_FIELD)+ ;
fld_22F_A_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22F"); }:
START_OF_FIELD '22F:' ~(START_OF_FIELD)+ ;
fld_98a_A_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("98A"); }:
START_OF_FIELD '98A:' ~(START_OF_FIELD)+ ;
fld_98a_A_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("98C"); }:
START_OF_FIELD '98C:' ~(START_OF_FIELD)+ ;
fld_22F_A1_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22F"); }:
START_OF_FIELD '22F:' ~(START_OF_FIELD)+ ;
fld_13a_A1_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("13A"); }:
START_OF_FIELD '13A:' ~(START_OF_FIELD)+ ;
fld_13a_A1_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("13B"); }:
START_OF_FIELD '13B:' ~(START_OF_FIELD)+ ;
fld_20C_A1_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("20C"); }:
START_OF_FIELD '20C:' ~(START_OF_FIELD)+ ;
fld_35B_B_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("35B"); }:
START_OF_FIELD '35B:' ~(START_OF_FIELD)+ ;
fld_94B_B1_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("94B"); }:
START_OF_FIELD '94B:' ~(START_OF_FIELD)+ ;
fld_22F_B1_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22F"); }:
START_OF_FIELD '22F:' ~(START_OF_FIELD)+ ;
fld_12a_B1_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("12A"); }:
START_OF_FIELD '12A:' ~(START_OF_FIELD)+ ;
fld_12a_B1_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("12C"); }:
START_OF_FIELD '12C:' ~(START_OF_FIELD)+ ;
fld_11A_B1_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("11A"); }:
START_OF_FIELD '11A:' ~(START_OF_FIELD)+ ;
fld_98A_B1_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("98A"); }:
START_OF_FIELD '98A:' ~(START_OF_FIELD)+ ;
fld_92A_B1_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("92A"); }:
START_OF_FIELD '92A:' ~(START_OF_FIELD)+ ;
fld_36B_B1_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("36B"); }:
START_OF_FIELD '36B:' ~(START_OF_FIELD)+ ;
fld_95a_B2_P returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95P"); }:
START_OF_FIELD '95P:' ~(START_OF_FIELD)+ ;
fld_95a_B2_R returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95R"); }:
START_OF_FIELD '95R:' ~(START_OF_FIELD)+ ;
fld_97A_B2_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("97A"); }:
START_OF_FIELD '97A:' ~(START_OF_FIELD)+ ;
fld_94a_B2_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("94B"); }:
START_OF_FIELD '94B:' ~(START_OF_FIELD)+ ;
fld_94a_B2_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("94C"); }:
START_OF_FIELD '94C:' ~(START_OF_FIELD)+ ;
fld_94a_B2_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("94F"); }:
START_OF_FIELD '94F:' ~(START_OF_FIELD)+ ;
fld_93a_B2_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("93B"); }:
START_OF_FIELD '93B:' ~(START_OF_FIELD)+ ;
fld_93a_B2_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("93C"); }:
START_OF_FIELD '93C:' ~(START_OF_FIELD)+ ;
fld_95a_C_P returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95P"); }:
START_OF_FIELD '95P:' ~(START_OF_FIELD)+ ;
fld_95a_C_R returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95R"); }:
START_OF_FIELD '95R:' ~(START_OF_FIELD)+ ;
fld_95a_C_S returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95S"); }:
START_OF_FIELD '95S:' ~(START_OF_FIELD)+ ;
fld_95a_C_V returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95V"); }:
START_OF_FIELD '95V:' ~(START_OF_FIELD)+ ;
fld_94C_C_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("94C"); }:
START_OF_FIELD '94C:' ~(START_OF_FIELD)+ ;
fld_36B_C_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("36B"); }:
START_OF_FIELD '36B:' ~(START_OF_FIELD)+ ;
fld_22F_C_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22F"); }:
START_OF_FIELD '22F:' ~(START_OF_FIELD)+ ;
fld_70E_C_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("70E"); }:
START_OF_FIELD '70E:' ~(START_OF_FIELD)+ ;
fld_13A_D_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("13A"); }:
START_OF_FIELD '13A:' ~(START_OF_FIELD)+ ;
fld_22a_D_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22F"); }:
START_OF_FIELD '22F:' ~(START_OF_FIELD)+ ;
fld_22a_D_H returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("22H"); }:
START_OF_FIELD '22H:' ~(START_OF_FIELD)+ ;
fld_11A_D_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("11A"); }:
START_OF_FIELD '11A:' ~(START_OF_FIELD)+ ;
fld_35B_D_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("35B"); }:
START_OF_FIELD '35B:' ~(START_OF_FIELD)+ ;
fld_36a_D_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("36B"); }:
START_OF_FIELD '36B:' ~(START_OF_FIELD)+ ;
fld_36a_D_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("36C"); }:
START_OF_FIELD '36C:' ~(START_OF_FIELD)+ ;
fld_19B_D_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("19B"); }:
START_OF_FIELD '19B:' ~(START_OF_FIELD)+ ;
fld_98a_D_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("98A"); }:
START_OF_FIELD '98A:' ~(START_OF_FIELD)+ ;
fld_98a_D_C returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("98C"); }:
START_OF_FIELD '98C:' ~(START_OF_FIELD)+ ;
fld_92a_D_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("92A"); }:
START_OF_FIELD '92A:' ~(START_OF_FIELD)+ ;
fld_92a_D_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("92F"); }:
START_OF_FIELD '92F:' ~(START_OF_FIELD)+ ;
fld_92a_D_R returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("92R"); }:
START_OF_FIELD '92R:' ~(START_OF_FIELD)+ ;
fld_90a_D_A returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90A"); }:
START_OF_FIELD '90A:' ~(START_OF_FIELD)+ ;
fld_90a_D_B returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90B"); }:
START_OF_FIELD '90B:' ~(START_OF_FIELD)+ ;
fld_90a_D_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90E"); }:
START_OF_FIELD '90E:' ~(START_OF_FIELD)+ ;
fld_90a_D_F returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90F"); }:
START_OF_FIELD '90F:' ~(START_OF_FIELD)+ ;
fld_90a_D_J returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90J"); }:
START_OF_FIELD '90J:' ~(START_OF_FIELD)+ ;
fld_90a_D_L returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("90L"); }:
START_OF_FIELD '90L:' ~(START_OF_FIELD)+ ;
fld_70E_D_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("70E"); }:
START_OF_FIELD '70E:' ~(START_OF_FIELD)+ ;
fld_70E_E_E returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("70E"); }:
START_OF_FIELD '70E:' ~(START_OF_FIELD)+ ;
fld_95a_E_P returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95P"); }:
START_OF_FIELD '95P:' ~(START_OF_FIELD)+ ;
fld_95a_E_Q returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95Q"); }:
START_OF_FIELD '95Q:' ~(START_OF_FIELD)+ ;
fld_95a_E_R returns [message::definition::swift::mt::Field fld] @init { $fld.set_tag("95R"); }:
START_OF_FIELD '95R:' ~(START_OF_FIELD)+ ;
TAG_BH : '{1:' ;
TAG_AH : '{2:' ;
TAG_UH : '{3:' ;
TAG_MT : '{4:' ;
TAG_TR : '{5:' ;
MT_END : '-}';
LBRACE : '{';
RBRACE : '}' ;
COLON : ':';
START_OF_FIELD : '\r'? '\n:' ;
ANY : . ; |
Appl/coop/FreeCell/freecellSound.asm | steakknife/pcgeos | 504 | 172418 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: sound.asm
AUTHOR: <NAME>, Feb 3, 1993
ROUTINES:
Name Description
---- -----------
SoundSetupSounds Allocate all sounds.
SoundPlaySound Plays the specified sound.
SoundShutOffSounds Stops all sounds and frees them.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 2/ 3/93 Initial revision
mkh 7/16/93 Modified for FreeCell
DESCRIPTION:
$Id: freecellSound.asm,v 1.1 97/04/04 15:02:51 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TWICE_NUM_SOUNDS equ 4
DEAL_CARDS_TEMPO equ 16
WINNER_TEMPO equ 16
;
; Need a couple extra low notes for the Entertainer theme.
;
VERY_LOW_G = 196
VERY_LOW_A_b = 207
VERY_LOW_A = 220
VERY_LOW_B = 247
FreeCellSounds etype word, 0, 2
FCS_DEAL_CARDS enum FreeCellSounds
FCS_WINNER enum FreeCellSounds
;---------------------------------
; idata
;---------------------------------
idata segment
dealCardsSound label word ; beginning of Entertainer.
ChangeEnvelope 0, IP_VIOLIN
General GE_SET_TEMPO
word DEAL_CARDS_TEMPO
Staccato 0, HIGH_D, EIGHTH, FORTE
Staccato 0, HIGH_E, EIGHTH, FORTE
Staccato 0, HIGH_C, EIGHTH, FORTE
Staccato 0, MIDDLE_A, QUARTER, FORTE
Staccato 0, MIDDLE_B, EIGHTH, FORTE
Staccato 0, MIDDLE_G, EIGHTH, FORTE
Rest EIGHTH
Staccato 0, MIDDLE_D, EIGHTH, FORTE
Staccato 0, MIDDLE_E, EIGHTH, FORTE
Staccato 0, MIDDLE_C, EIGHTH, FORTE
Staccato 0, LOW_A, QUARTER, FORTE
Staccato 0, LOW_B, EIGHTH, FORTE
Staccato 0, LOW_G, EIGHTH, FORTE
Rest EIGHTH
Staccato 0, LOW_D, EIGHTH, FORTE
Staccato 0, LOW_E, EIGHTH, FORTE
Staccato 0, LOW_C, EIGHTH, FORTE
Staccato 0, VERY_LOW_A, QUARTER, FORTE
Staccato 0, VERY_LOW_B, EIGHTH, FORTE
Staccato 0, VERY_LOW_A, EIGHTH, FORTE
Staccato 0, VERY_LOW_A_b, EIGHTH, FORTE
Staccato 0, VERY_LOW_G, QUARTER, FORTE
Rest QUARTER
Staccato 0, LOW_G, QUARTER, FORTE
General GE_END_OF_SONG
winnerSound label word ; Fanfare
ChangeEnvelope 0, IP_TUBULAR_BELLS
General GE_SET_TEMPO
word WINNER_TEMPO
Staccato 0, MIDDLE_G, EIGHTH, FORTE
Rest EIGHTH
Staccato 0, MIDDLE_G, EIGHTH, FORTE
Staccato 0, MIDDLE_G, EIGHTH, FORTE
Natural 0, HIGH_C, HALF, FORTE
General GE_END_OF_SONG
idata ends
;----------------------------------
; udata
;----------------------------------
udata segment
dealCardsSoundHandle word ; sound handles for all the
winnerSoundHandle word ; sounds in Concentration
udata ends
SoundCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundSetupSounds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate all sounds and save all sound handles.
CALLED BY: GLOBAL
PASS: es = idata
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 2/ 3/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundSetupSounds proc far
uses bx,cx,bp,si,di
.enter
clr bp
soundLoop:
mov bx, es
mov si, cs:soundOffsetTable[bp]
mov cx, cs:soundNumVoicesTable[bp]
call SoundAllocMusic ; allocate the sound
; handle returned in bx
mov di, cs:soundHandleTable[bp]
mov es:[di], bx ; save the handle
add bp, 2
cmp bp, TWICE_NUM_SOUNDS ; are we done?
jl soundLoop
.leave
ret
soundOffsetTable word \
offset dealCardsSound,
offset winnerSound
soundNumVoicesTable word \
1, ; dealCards
1 ; winnerSound
soundHandleTable word \
dealCardsSoundHandle,
winnerSoundHandle
SoundSetupSounds endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundPlaySound
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Plays the specified sound.
CALLED BY: GLOBAL
PASS: cx = ConcenSounds type
es = idata
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 2/ 3/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundPlaySound proc far
uses ax,bx,cx,dx,bp,di
.enter
mov bp, cx
mov di, cs:soundTypeToHandleTable[bp]
mov bx, es:[di]
mov dl, mask EOSF_UNLOCK
mov ax, cs:soundPriorityTable[bp]
mov cx, 16
call SoundPlayMusic
.leave
ret
soundTypeToHandleTable word \
dealCardsSoundHandle, ; FCS_DEAL_CARDS
winnerSoundHandle ; FCS_WINNER
soundPriorityTable word \
SP_BACKGROUND, ; deal cards
SP_BACKGROUND ; winner
SoundPlaySound endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundShutOffSounds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stops all sounds and frees them.
CALLED BY: GLOBAL
PASS: es = idata
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 2/ 3/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SoundShutOffSounds proc far
uses bx,bp,di
.enter
clr bp
shutoffLoop:
mov di, cs:soundHandleToStopTable[bp]
mov bx, es:[di]
call SoundStopMusic
call SoundFreeMusic
add bp, 2
cmp bp, TWICE_NUM_SOUNDS
jl shutoffLoop
.leave
ret
soundHandleToStopTable word \
dealCardsSoundHandle,
winnerSoundHandle
SoundShutOffSounds endp
SoundCode ends
|
compsci courses/CPSC355 - Computing Machinery/assignments/as5/a5a.asm | q-omar/UofC | 1 | 29827 | <reponame>q-omar/UofC
//CPSC 355
//<NAME>
//ID 10086638
//Assignment 5
//The following assembly code is called by the main method in the accompanying C code. The C code calls upon
//the global methods defined here. The program can push integers to the stack, pop them, and display them in order
define(STACKSIZE,5) //specify constant stacksize macro
define(FALSE,0) //setting constants false and true macros
define(TRUE,1)
define(top64, x20) //top 64 register
define(top32, w22) // top 32register
define(valueR, w23) // value register
define(i_reg,w24) //i register
fp .req x29 //register aliases
lr .req x30
defineStrings:
stackOverflow: .string "\nStack overflow! Cannot push value onto stack.\n" //defining strings
stackUnderflow: .string "\nStack underflow! Cannot pop an empty stack.\n"
stackEmptyStr: .string "\nEmpty stack\n"
stackContents: .string "\nCurrent stack contents:\n"
stackIndex: .string "%d"
stackTop: .string " <-- top of stack"
linebreak: .string "\n"
.balign 4
.global push, pop, display //setting subroutines as global so C code can call it
push:
stp x29, x30, [sp, -16]! //allocate memory on stack
mov x29, sp //fp to sp link
mov valueR, w0 //store pushed value into register
bl stackFull //branch to stackfull to return a boolean
cmp w0, TRUE //if not true, push
b.ne pushElse //by branching to else
pushIf:
adrp x0, stackOverflow //otherwise print overflow message, load higher order bits
add x0, x0, :lo12:stackOverflow //lower order bits
bl printf //call print function
b pushEnd //branch to end
pushElse:
adrp top64, top //load higher and lower order bits
add top64, top64, :lo12:top
ldr top32, [top64] //then load from x19 into top register
add top32, top32, 1 //increment top
str top32, [top64] //store top
adrp x21, stack //load higher and lower order bits, reading from stack
add x21, x21, :lo12:stack
str valueR, [x21, top32, SXTW 2] // store value into stack
pushEnd:
ldp x29, x30, [sp], 16 //deallocate memory and return to calling code
ret
pop:
stp x29, x30, [sp, -16]! //allocate memoryy
mov x29, sp //link fp and fp
bl stackEmpty //branch to stackempty to return boolean
cmp w0, TRUE //if stack isnt empty
b.ne popElse //branch to else
popIf:
adrp x0, stackUnderflow //otherwise print stack is underflow
add x0, x0, :lo12:stackUnderflow
bl printf //calling print
mov x0, -1 //return negative 1
b popEnd
popElse:
adrp top64, top //if stack isnt underflow, read top (load higher/lower order bits)
add top64, top64, :lo12:top
ldr top32, [top64] //load value of top into top register
adrp x21, stack //read stack, higher and lower bits
add x21, x21, :lo12:stack
ldr valueR, [x21, top32, SXTW 2] //load index of stack that is at top, stack[top]
sub top32, top32, 1 // top = top - 1
str top32, [top64] //store top
mov w0, valueR // return value
popEnd:
ldp x29, x30, [sp], 16 //deallocate and return to calling code
ret
stackFull:
stp x29, x30, [sp, -16]! //allocate memory
mov x29, sp //equate fp to sp
adrp top64, top //loading higher and lower bits of top
add top64, top64, :lo12:top
ldr top32, [top64] //putting into register
cmp top32, STACKSIZE - 1
b.ne stackFullElse //else branch to false
stackFullIf:
mov x0, TRUE //otherwise true
b stackFullEnd //branch to end
stackFullElse:
mov x0, FALSE //setting flag appropriately
stackFullEnd:
ldp x29, x30, [sp], 16 //deallocate and return to calling code
ret
stackEmpty:
stp x29, x30, [sp, -16]! //allocate memory,
mov x29, sp //link fp to sp
adrp top64, top //loading higher/lower order bits of top
add top64, top64, :lo12:top
ldr top32, [top64] //loading top into register
cmp top32, -1 //checking empty
b.ne stackEmptyElse //if it isnt equal to -1, its not empty branch to false
stackEmptyIf:
mov x0, TRUE //otherwise it is empty
b stackEmptyEnd
stackEmptyElse:
mov x0, FALSE //not empty flag
stackEmptyEnd:
ldp x29, x30, [sp], 16 //deallocate memory
ret
display:
stp x29, x30, [sp, -16]! //allocate memory,
mov x29, sp //link fp to sp
bl stackEmpty //branch to stack empty to return boolean
cmp w0, TRUE //if true, print empty
b.ne displayElse
displayIf:
adrp x0, stackEmptyStr //printing stack empty, load higher order bits
add x0, x0, :lo12:stackEmptyStr //lower order bits
bl printf
b displayEnd //if its empty, just go to end
displayElse:
adrp x0, stackContents //printing current content tag
add x0, x0, :lo12:stackContents
adrp top64, top //loading top
add top64, top64, :lo12:top
ldr top32, [top64]
mov i_reg, top32 //move top value into register i
b loopTest //looping to print all values on stack
loop:
adrp x21, stack //read stack, higher and lower bits
add x21, x21, :lo12:stack
ldr w28, [x21, i_reg, SXTW 2] //load index of stack that is at top, stack[i_reg]
adrp x0, stackIndex //loading higher and lower bits of stack index
add x0, x0, :lo12:stackIndex
mov w1, w28 //setting register for printing
bl printf
cmp i_reg, top32 //check if current value i is == top
b.ne updateLoop //if not, decrement
adrp x0, stackTop //printing stacktop
add x0, x0, :lo12:stackTop
bl printf
updateLoop:
adrp x0, linebreak //pritning a linebreak character
add x0, x0, :lo12:linebreak
bl printf
sub i_reg, i_reg, 1 //then decrementing index i by 1
loopTest:
cmp i_reg, 0 //checking if register i value is >= 0
b.ge loop //then loop otherwise end
displayEnd:
ldp x29, x30, [sp], 16 //deallocate memory, return to calling code
ret
|
programs/oeis/147/A147974.asm | karttu/loda | 1 | 9491 | ; A147974: n^3-((n-1)^3+(n-2)^3+(n-3)^3).
; 10,8,18,28,26,0,-62,-172,-342,-584,-910,-1332,-1862,-2512,-3294,-4220,-5302,-6552,-7982,-9604,-11430,-13472,-15742,-18252,-21014,-24040,-27342,-30932,-34822,-39024,-43550,-48412,-53622,-59192,-65134,-71460
mov $4,$0
sub $4,2
mov $2,$4
pow $2,3
mov $1,$2
sub $1,4
add $2,5
mov $3,$4
div $4,$1
mul $0,$4
mov $1,3
sub $1,$2
add $3,5
add $0,$3
mul $0,6
add $1,1
add $1,$0
sub $1,20
mul $1,2
|
src/harvesters_autoharvest.asm | mvdhout1992/ts-patches | 33 | 14036 | ; Harvesters and Weeders Automatically Start to Harvest When Built
; After leaving the factory, Harvesters and Weeders will now start to harvest
; instead of waiting there until the player commanded them to do so.
;
; Patch based on information by CCHyper
; http://www.ppmforums.com/viewtopic.php?p=552284#552284
;
; Author: AlexB
; Date: 2016-11-22
%include "macros/patch.inc"
%include "macros/hack.inc"
@LJMP 0x006517BE, _UnitClass_UpdatePosition_Harvester
section .text
_UnitClass_UpdatePosition_Harvester:
mov ecx, [ebp+360h]; UnitClass::Type
mov ax, [ecx+48Eh]; UnitClass::Harvester and UnitClass::Weeder
test ax, ax
jz .Return
mov eax, [ebp]; UnitClass::vtbl
push 9; Mission::Harvest
mov ecx, ebp
call [eax+158h]; UnitClass::QueueMission
jmp 0x0065194E
.Return:
push 0
push 0x006F2EE8; BuildingClassTypeDescriptor
jmp 0x006517C5
|
libsrc/_DEVELOPMENT/adt/ba_priority_queue/c/sccz80/ba_priority_queue_pop.asm | meesokim/z88dk | 0 | 24746 |
; int ba_priority_queue_pop(ba_priority_queue_t *q)
SECTION code_adt_ba_priority_queue
PUBLIC ba_priority_queue_pop
ba_priority_queue_pop:
INCLUDE "adt/ba_priority_queue/z80/asm_ba_priority_queue_pop.asm"
|
src/words_engine/words_engine-english_support_package.ads | spr93/whitakers-words | 204 | 18150 | -- WORDS, a Latin dictionary, by <NAME> (USAF, Retired)
--
-- Copyright <NAME> (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Ada.Text_IO;
with Ada.Direct_IO;
with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package;
with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package;
package Words_Engine.English_Support_Package is
Eword_Size : constant := 24;
Aux_Word_Size : constant := 12;
Line_Number_Width : constant := 10;
Priority_Width : constant := 3;
subtype Eword is String (1 .. Eword_Size);
Null_Eword : constant Eword := (others => ' ');
subtype Auxword is String (1 .. Aux_Word_Size);
Null_Auxword : constant Auxword := (others => ' ');
subtype Priority_Type is Integer range 0 .. 99;
Number_Of_Ewords : Integer := 0;
type Ewds_Record is
record
W : Eword := Null_Eword;
Aux : Auxword := Null_Auxword;
N : Integer := 0;
Pofs : Part_Of_Speech_Type := X;
Freq : Frequency_Type := X;
Semi : Integer := 0;
Kind : Integer := 0;
Rank : Integer := 0;
end record;
Null_Ewds_Record : constant Ewds_Record := ((others => ' '),
(others => ' '), 0, X, X, 0, 0, 0);
type Ewds_Array is array (Positive range <>) of Ewds_Record;
package Ewds_Direct_Io is new Ada.Direct_IO (Ewds_Record);
package Ewds_Record_Io is
Default_Width : Natural;
procedure Get (F : in Ada.Text_IO.File_Type; P : out Ewds_Record);
procedure Get (P : out Ewds_Record);
procedure Put (F : in Ada.Text_IO.File_Type; P : in Ewds_Record);
procedure Put (P : in Ewds_Record);
procedure Get (S : in String; P : out Ewds_Record;
Last : out Integer);
procedure Put (S : out String; P : in Ewds_Record);
end Ewds_Record_Io;
English_Dictionary_Available : array (Dictionary_Kind) of Boolean := (False,
False, False, False, False, False, False, -- don't SEARCH
False, False, False, False);
Ewds_File : Ewds_Direct_Io.File_Type;
end Words_Engine.English_Support_Package;
|
mc-sema/validator/x86_64/tests/FILD_64m.asm | randolphwong/mcsema | 2 | 245080 | BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
;TEST_BEGIN_RECORDING
lea rdi, [rsp-0x0c]
mov dword [rdi+00], 0x0000
mov dword [rdi+04], 0x0001
FILD qword [rdi]
mov edi, 0
;TEST_END_RECORDING
|
Task/Miller-Rabin-primality-test/Ada/miller-rabin-primality-test-2.ada | djgoku/RosettaCodeData | 0 | 7255 | <filename>Task/Miller-Rabin-primality-test/Ada/miller-rabin-primality-test-2.ada
with Ada.Numerics.Discrete_Random;
package body Miller_Rabin is
function Is_Prime (N : Number; K : Positive := 10)
return Result_Type
is
subtype Number_Range is Number range 2 .. N - 1;
package Random is new Ada.Numerics.Discrete_Random (Number_Range);
function Mod_Exp (Base, Exponent, Modulus : Number) return Number is
Result : Number := 1;
begin
for E in 1 .. Exponent loop
Result := Result * Base mod Modulus;
end loop;
return Result;
end Mod_Exp;
Generator : Random.Generator;
D : Number := N - 1;
S : Natural := 0;
X : Number;
begin
-- exclude 2 and even numbers
if N = 2 then
return Probably_Prime;
elsif N mod 2 = 0 then
return Composite;
end if;
-- write N-1 as 2**S * D, with D mod 2 /= 0
while D mod 2 = 0 loop
D := D / 2;
S := S + 1;
end loop;
-- initialize RNG
Random.Reset (Generator);
for Loops in 1 .. K loop
X := Mod_Exp(Random.Random (Generator), D, N);
if X /= 1 and X /= N - 1 then
Inner : for R in 1 .. S - 1 loop
X := Mod_Exp (X, 2, N);
if X = 1 then return Composite; end if;
exit Inner when X = N - 1;
end loop Inner;
if X /= N - 1 then return Composite; end if;
end if;
end loop;
return Probably_Prime;
end Is_Prime;
end Miller_Rabin;
|
dino/lcs/base/6666.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 168599 | <reponame>zengfr/arcade_game_romhacking_sourcecode_top_secret_data<filename>dino/lcs/base/6666.asm
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004C88 move.w A0, -(A1)
004C8A move.b #$8, ($82,A0) [base+6638, base+663A, base+663C, base+663E, base+6640, base+6642, base+6644, base+6646, base+6648, base+664A, base+664C, base+664E, base+6650, base+6652, base+6654, base+6656, base+6658, base+665A, base+665C, base+665E, base+6660, base+6662, base+6664, base+6666]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
src/vulkan-math/gentype/vulkan-math-genftype.adb | zrmyers/VulkanAda | 1 | 19596 | <reponame>zrmyers/VulkanAda
--------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 <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.
--------------------------------------------------------------------------------
-- This package describes a generic Single Precision Floating Point Vulkan Math type.
--------------------------------------------------------------------------------
package body Vulkan.Math.GenFType is
function "<" (left, right : in Vkm_GenFType) return Vkm_GenBType is
result : Vkm_GenBType(last_index => left.last_index);
begin
for index in Vkm_Indices'First .. left.last_index loop
result.data(index) := Vkm_Bool(left.data(index) < right.data(index));
end loop;
return result;
end "<";
----------------------------------------------------------------------------
function "<=" (left, right : in Vkm_GenFType) return Vkm_GenBType is
result : Vkm_GenBType(last_index => left.last_index);
begin
for index in Vkm_Indices'First .. left.last_index loop
result.data(index) := Vkm_Bool(left.data(index) <= right.data(index));
end loop;
return result;
end "<=";
----------------------------------------------------------------------------
function ">" (left, right : in Vkm_GenFType) return Vkm_GenBType is
result : Vkm_GenBType(last_index => left.last_index);
begin
for index in Vkm_Indices'First .. left.last_index loop
result.data(index) := Vkm_Bool(left.data(index) > right.data(index));
end loop;
return result;
end ">";
----------------------------------------------------------------------------
function ">=" (left, right : in Vkm_GenFType) return Vkm_GenBType is
result : Vkm_GenBType(last_index => left.last_index);
begin
for index in Vkm_Indices'First .. left.last_index loop
result.data(index) := Vkm_Bool(left.data(index) >= right.data(index));
end loop;
return result;
end ">=";
----------------------------------------------------------------------------
-- Generic Operations
----------------------------------------------------------------------------
function Apply_Func_IVF_IVF_IVB_RVF(IVF1, IVF2 : in Vkm_GenFType;
IVB1 : in Vkm_GenBType) return Vkm_GenFType is
Result : Vkm_GenFType := IVF1;
begin
for I in Vkm_Indices'First .. To_Vkm_Indices(IVF1.Length) loop
Result.data(I) := Func(IVF1.data(I), IVF2.data(I), IVB1.data(I));
end loop;
return Result;
end Apply_Func_IVF_IVF_IVB_RVF;
function Apply_Func_IVF_RVB(IVF1 : in Vkm_GenFType) return Vkm_GenBType is
Result : Vkm_GenBType := (Last_Index => IVF1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF1.Last_Index loop
Result.data(I) := Func(IVF1.data(I));
end loop;
return Result;
end Apply_Func_IVF_RVB;
function Apply_Func_IVF_RVI (IVF1 : in Vkm_GenFType) return Vkm_GenIType is
Result : Vkm_GenIType := (Last_Index => IVF1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF1.Last_Index loop
Result.data(I) := Func(IVF1.data(I));
end loop;
return Result;
end Apply_Func_IVF_RVI;
function Apply_Func_IVI_RVF (IVI1 : in Vkm_GenIType) return Vkm_GenFType is
Result : Vkm_GenFType := (Last_Index => IVI1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVI1.Last_Index loop
Result.data(I) := Func(IVI1.data(I));
end loop;
return Result;
end Apply_Func_IVI_RVF;
function Apply_Func_IVF_RVU (IVF1 : in Vkm_GenFType) return Vkm_GenUType is
Result : Vkm_GenUType := (Last_Index => IVF1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF1.Last_Index loop
Result.data(I) := Func(IVF1.data(I));
end loop;
return Result;
end Apply_Func_IVF_RVU;
function Apply_Func_IVU_RVF (IVU1 : in Vkm_GenUType) return Vkm_GenFType is
Result : Vkm_GenFType := (Last_Index => IVU1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVU1.Last_Index loop
Result.data(I) := Func(IVU1.data(I));
end loop;
return Result;
end Apply_Func_IVU_RVF;
function Apply_Func_IVF_OVI_RVF(IVF : in Vkm_GenFType;
OVI : out Vkm_GenIType) return Vkm_GenFType is
Result : Vkm_GenFType := (Last_Index => IVF.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF.Last_Index loop
Result.data(I) := Func(IVF.data(I),OVI.data(I));
end loop;
return Result;
end Apply_Func_IVF_OVI_RVF;
function Apply_Func_IVF_IVI_RVF(IVF : in Vkm_GenFType;
IVI : in Vkm_GenIType) return Vkm_GenFType is
Result : Vkm_GenFType := (Last_Index => IVF.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF.Last_Index loop
Result.data(I) := Func(IVF.data(I),IVI.data(I));
end loop;
return Result;
end Apply_Func_IVF_IVI_RVF;
function Apply_Func_IVF_IVF_RVB(IVF1, IVF2 : in Vkm_GenFType) return Vkm_GenBType is
Result : Vkm_GenBType := (Last_Index => IVF1.Last_Index, others => <>);
begin
for I in Vkm_Indices'First .. IVF1.Last_Index loop
Result.data(I) := Func(IVF1.data(I), IVF2.data(I));
end loop;
return Result;
end Apply_Func_IVF_IVF_RVB;
end Vulkan.Math.GenFType;
|
src/net-protos-arp.ads | stcarrez/ada-enet | 16 | 707 | <gh_stars>10-100
-----------------------------------------------------------------------
-- net-protos-arp -- ARP Network protocol
-- Copyright (C) 2016 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Net.Interfaces;
with Net.Buffers;
-- == ARP Protocol ==
-- The <b>Net.Protos.Arp</b> package implements the support for the ARP protocol used for the
-- resolution of IPv4 addresses. The package maintains a ARP database within an Ada protected
-- object.
--
-- The <b>Resolve</b> procedure is the main entry point for the resolution of the IPv4 address.
-- Given a target IP address, it first looks in the ARP database for the associated Ethernet
-- address. When the Ethernet address is known, it updates the Ethernet header so that the
-- packet can be sent to the network interface.
--
-- When the Ethernet address is now known, the <b>Resolve</b> procedure puts the packet in a
-- queue and it makes an ARP request.
--
-- The <b>Receive</b> procedure should be called when a ARP packet is received. It is responsible
-- for replying to ARP requests from other hosts on the network and handling ARP response for
-- our requests. It updates the ARP database only when we receive a ARP response from one of
-- our ARP query.
--
package Net.Protos.Arp is
ARPHRD_ETHER : constant Uint16 := 1;
ARPOP_REQUEST : constant Uint16 := 1;
ARPOP_REPLY : constant Uint16 := 2;
ARPOP_REVREQUEST : constant Uint16 := 3;
ARPOP_REVREPLY : constant Uint16 := 4;
ARPOP_INVREQUEST : constant Uint16 := 8;
ARPOP_INVREPLY : constant Uint16 := 8;
type Arp_Status is (ARP_FOUND, ARP_PENDING, ARP_NEEDED, ARP_QUEUE_FULL, ARP_UNREACHABLE);
procedure Request (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Source_Ip : in Ip_Addr;
Target_Ip : in Ip_Addr;
Mac : in Ether_Addr);
-- Proceed to the ARP database timeouts, cleaning entries and re-sending pending
-- ARP requests. The procedure should be called once every second.
procedure Timeout (Ifnet : in out Net.Interfaces.Ifnet_Type'Class);
-- Resolve the target IP address to obtain the associated Ethernet address
-- from the ARP table. The Status indicates whether the IP address is
-- found, or a pending ARP resolution is in progress or it was unreachable.
procedure Resolve (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Target_Ip : in Ip_Addr;
Mac : out Ether_Addr;
Packet : in out Net.Buffers.Buffer_Type;
Status : out Arp_Status);
procedure Receive (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Packet : in out Net.Buffers.Buffer_Type);
-- Update the arp table with the IP address and the associated Ethernet address.
procedure Update (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Target_Ip : in Ip_Addr;
Mac : in Ether_Addr);
end Net.Protos.Arp;
|
Search and Sort/Binary Search.asm | MrR0B0T777/MIPS_Programming | 0 | 92957 | ## binsearch
.data
array: .word 1 4 7 10 15
arraySize: .word 5
msg: .asciiz "Enter the number that you want to search for:\n"
.text
main:
li $v0,4
la $a0,msg
syscall
li $v0,5
syscall
move $t5, $v0
la $s0, array
xor $a0, $a0, $a0
lw $a1, arraySize
jal search
##retval in $a0
li $v0,1
syscall
li $v0,10
syscall
search:
blt $a1, $a0, notfound
add $t1, $a0, $a1
sra $t1, $t1, 1
## mid in $t2
mul $t2, $t1, 4 ## *(int*)(arr+mid)
add $t2, $t2, $s0
lw $t2, 0($t2)
beq $t2, $t5, found
blt $t2, $t5, left #t2 less than
right: move $a1, $t1
sub $a1, $a1, 1 #right = mid-1
j search
left:
move $a0, $t1 #left = mid+1
add $a0, $a0, 1
j search
notfound:
li $a0,-1
jr $ra
found:
move $a0, $t1
jr $ra |
agda-stdlib/README/Decidability.agda | DreamLinuxer/popl21-artifact | 5 | 17156 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- Examples of decision procedures and how to use them
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module README.Decidability where
-- Reflects and Dec are defined in Relation.Nullary, and operations on them can
-- be found in Relation.Nullary.Reflects and Relation.Nullary.Decidable.
open import Relation.Nullary as Nullary
open import Relation.Nullary.Reflects
open import Relation.Nullary.Decidable
open import Data.Bool
open import Data.List
open import Data.List.Properties using (∷-injective)
open import Data.Nat
open import Data.Nat.Properties using (suc-injective)
open import Data.Product
open import Data.Unit
open import Function
open import Relation.Binary.PropositionalEquality
open import Relation.Nary
open import Relation.Nullary.Product
infix 4 _≟₀_ _≟₁_ _≟₂_
-- A proof of `Reflects P b` shows that a proposition `P` has the truth value of
-- the boolean `b`. A proof of `Reflects P true` amounts to a proof of `P`, and
-- a proof of `Reflects P false` amounts to a refutation of `P`.
ex₀ : (n : ℕ) → Reflects (n ≡ n) true
ex₀ n = ofʸ refl
ex₁ : (n : ℕ) → Reflects (zero ≡ suc n) false
ex₁ n = ofⁿ λ ()
ex₂ : (b : Bool) → Reflects (T b) b
ex₂ false = ofⁿ id
ex₂ true = ofʸ tt
-- A proof of `Dec P` is a proof of `Reflects P b` for some `b`.
-- `Dec P` is declared as a record, with fields:
-- does : Bool
-- proof : Reflects P does
ex₃ : (b : Bool) → Dec (T b)
does (ex₃ b) = b
proof (ex₃ b) = ex₂ b
-- We also have pattern synonyms `yes` and `no`, allowing both fields to be
-- given at once.
ex₄ : (n : ℕ) → Dec (zero ≡ suc n)
ex₄ n = no λ ()
-- It is possible, but not ideal, to define recursive decision procedures using
-- only the `yes` and `no` patterns. The following procedure decides whether two
-- given natural numbers are equal.
_≟₀_ : (m n : ℕ) → Dec (m ≡ n)
zero ≟₀ zero = yes refl
zero ≟₀ suc n = no λ ()
suc m ≟₀ zero = no λ ()
suc m ≟₀ suc n with m ≟₀ n
... | yes p = yes (cong suc p)
... | no ¬p = no (¬p ∘ suc-injective)
-- In this case, we can see that `does (suc m ≟ suc n)` should be equal to
-- `does (m ≟ n)`, because a `yes` from `m ≟ n` gives rise to a `yes` from the
-- result, and similarly for `no`. However, in the above definition, this
-- equality does not hold definitionally, because we always do a case split
-- before returning a result. To avoid this, we can return the `does` part
-- separately, before any pattern matching.
_≟₁_ : (m n : ℕ) → Dec (m ≡ n)
zero ≟₁ zero = yes refl
zero ≟₁ suc n = no λ ()
suc m ≟₁ zero = no λ ()
does (suc m ≟₁ suc n) = does (m ≟₁ n)
proof (suc m ≟₁ suc n) with m ≟₁ n
... | yes p = ofʸ (cong suc p)
... | no ¬p = ofⁿ (¬p ∘ suc-injective)
-- We now get definitional equalities such as the following.
_ : (m n : ℕ) → does (5 + m ≟₁ 3 + n) ≡ does (2 + m ≟₁ n)
_ = λ m n → refl
-- Even better, from a maintainability point of view, is to use `map` or `map′`,
-- both of which capture the pattern of the `does` field remaining the same, but
-- the `proof` field being updated.
_≟₂_ : (m n : ℕ) → Dec (m ≡ n)
zero ≟₂ zero = yes refl
zero ≟₂ suc n = no λ ()
suc m ≟₂ zero = no λ ()
suc m ≟₂ suc n = map′ (cong suc) suc-injective (m ≟₂ n)
_ : (m n : ℕ) → does (5 + m ≟₂ 3 + n) ≡ does (2 + m ≟₂ n)
_ = λ m n → refl
-- `map′` can be used in conjunction with combinators such as `_⊎-dec_` and
-- `_×-dec_` to build complex (simply typed) decision procedures.
module ListDecEq₀ {a} {A : Set a} (_≟ᴬ_ : (x y : A) → Dec (x ≡ y)) where
_≟ᴸᴬ_ : (xs ys : List A) → Dec (xs ≡ ys)
[] ≟ᴸᴬ [] = yes refl
[] ≟ᴸᴬ (y ∷ ys) = no λ ()
(x ∷ xs) ≟ᴸᴬ [] = no λ ()
(x ∷ xs) ≟ᴸᴬ (y ∷ ys) =
map′ (uncurry (cong₂ _∷_)) ∷-injective (x ≟ᴬ y ×-dec xs ≟ᴸᴬ ys)
-- The final case says that `x ∷ xs ≡ y ∷ ys` exactly when `x ≡ y` *and*
-- `xs ≡ ys`. The proofs are updated by the first two arguments to `map′`.
-- In the case of ≡-equality tests, the pattern
-- `map′ (congₙ c) c-injective (x₀ ≟ y₀ ×-dec ... ×-dec xₙ₋₁ ≟ yₙ₋₁)`
-- is captured by `≟-mapₙ n c c-injective (x₀ ≟ y₀) ... (xₙ₋₁ ≟ yₙ₋₁)`.
module ListDecEq₁ {a} {A : Set a} (_≟ᴬ_ : (x y : A) → Dec (x ≡ y)) where
_≟ᴸᴬ_ : (xs ys : List A) → Dec (xs ≡ ys)
[] ≟ᴸᴬ [] = yes refl
[] ≟ᴸᴬ (y ∷ ys) = no λ ()
(x ∷ xs) ≟ᴸᴬ [] = no λ ()
(x ∷ xs) ≟ᴸᴬ (y ∷ ys) = ≟-mapₙ 2 _∷_ ∷-injective (x ≟ᴬ y) (xs ≟ᴸᴬ ys)
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/lto13_pkg.ads | best08618/asylo | 7 | 21317 | package Lto13_Pkg is
procedure Proc;
private
type T;
end Lto13_Pkg;
|
actions/clearcache.applescript | andreifilip123/play-song | 0 | 3535 | <reponame>andreifilip123/play-song
-- clears workflow cache, including album artwork and compiled scripts --
on loadConfig()
return (load script POSIX file (do shell script "./resources/compile-config.sh"))
end loadConfig
on run query
set config to loadConfig()
try
tell application "Finder"
delete folder (workflowCacheFolder of config)
end tell
end try
end run
|
0x07_shellcode/shellcode_04_helloWorld_stack.nasm | bigb0sss/b0ssTheASM | 2 | 99590 | ; Executable name : shellcode_04_helloWorld_stack
; Version : 1.0
; Created date : 05/31/2020
; Last update : 05/31/2020
; Author : bigb0ss
; Description. : Print "Hello World\n" using shellcode
; This will directly write the string values on the stack.
; - The string should be added reverse order since the stack grows from the small addr to big.
;
; [Python Example]
; code = 'Hello World\n'
; code[::-1]
; code[::-1].encode('hex')
;
global _start
section .text
_start:
; write() syscall
xor eax, eax ; Set EAX to zero
mov al, 0x4 ; Adding "4" to AL (= lower byte of EAX)
xor ebx, ebx ; Set EBX to zero
mov bl, 0x1 ; Adding "1" to AL (= lower byte of EBX)
xor edx, edx ; Set EDX to zero
push edx ; Putting the EDX on the stack. We are doing this for string null byte at the end.
push 0x0a646c72 ; Reverse order of "Hello World\n"
push 0x6f57206f
push 0x6c6c6548
mov ecx, esp ; Putting the current ESP to ECX to align our write() syscall
mov dl, 12 ; Adding a length of "Hello World\n"
int 0x80
; exit() syscall
xor eax, eax
mov al, 0x1
xor ebx, ebx
int 0x80
|
test/Succeed/Issue1436-14.agda | shlevy/agda | 1,989 | 4554 | module _ where
module A where
postulate
!_ : Set₂ → Set₃
infix 1 !_
module B where
postulate
!_ : Set₀ → Set₁
infix 3 !_
open A
open B
postulate
#_ : Set₁ → Set₂
infix 2 #_
ok₁ : Set₁ → Set₃
ok₁ X = ! # X
ok₂ : Set₀ → Set₂
ok₂ X = # ! X
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_21829_742.asm | ljhsiun2/medusa | 9 | 242039 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rdx
lea addresses_WC_ht+0x1960f, %rbx
nop
nop
dec %rdi
mov (%rbx), %r11
nop
nop
nop
nop
sub %rcx, %rcx
lea addresses_A_ht+0x164db, %r9
clflush (%r9)
nop
add %rdx, %rdx
movb (%r9), %cl
nop
nop
nop
inc %rdx
lea addresses_A_ht+0xb5cf, %rdi
nop
inc %rcx
vmovups (%rdi), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r11
nop
nop
dec %rbx
lea addresses_UC_ht+0x90cf, %rcx
nop
nop
nop
sub %r8, %r8
movb (%rcx), %bl
nop
nop
nop
nop
sub %rbx, %rbx
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r8
push %rcx
push %rdi
push %rdx
// Store
lea addresses_normal+0x18956, %rdi
nop
nop
nop
nop
nop
xor $65262, %rdx
movw $0x5152, (%rdi)
nop
nop
nop
nop
add $46973, %r14
// Faulty Load
lea addresses_WT+0x128cf, %r8
nop
nop
nop
nop
nop
dec %r12
movups (%r8), %xmm4
vpextrq $1, %xmm4, %rdx
lea oracles, %rcx
and $0xff, %rdx
shlq $12, %rdx
mov (%rcx,%rdx,1), %rdx
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
P6/data_P6_2/cal_R_test24.asm | alxzzhou/BUAA_CO_2020 | 1 | 243952 | lui $1,22077
ori $1,$1,20245
lui $2,64674
ori $2,$2,8539
lui $3,35519
ori $3,$3,32850
lui $4,55575
ori $4,$4,38373
lui $5,25713
ori $5,$5,20581
lui $6,34572
ori $6,$6,44794
mthi $1
mtlo $2
sec0:
nop
nop
nop
addu $4,$6,$2
sec1:
nop
nop
or $2,$3,$3
addu $1,$6,$2
sec2:
nop
nop
andi $2,$2,2405
addu $3,$6,$2
sec3:
nop
nop
mfhi $2
addu $6,$6,$2
sec4:
nop
nop
lhu $2,8($0)
addu $1,$6,$2
sec5:
nop
addu $2,$4,$2
nop
addu $3,$6,$2
sec6:
nop
slt $2,$1,$3
xor $2,$4,$2
addu $5,$6,$2
sec7:
nop
and $2,$6,$4
slti $2,$1,31229
addu $3,$6,$2
sec8:
nop
sltu $2,$3,$5
mflo $2
addu $1,$6,$2
sec9:
nop
addu $2,$3,$4
lw $2,16($0)
addu $3,$6,$2
sec10:
nop
addiu $2,$1,-14436
nop
addu $1,$6,$2
sec11:
nop
slti $2,$3,-15442
sltu $2,$5,$5
addu $2,$6,$2
sec12:
nop
ori $2,$4,19733
slti $2,$2,-18867
addu $3,$6,$2
sec13:
nop
xori $2,$0,14797
mflo $2
addu $4,$6,$2
sec14:
nop
slti $2,$5,-17035
lh $2,12($0)
addu $3,$6,$2
sec15:
nop
mflo $2
nop
addu $2,$6,$2
sec16:
nop
mfhi $2
slt $2,$3,$3
addu $5,$6,$2
sec17:
nop
mfhi $2
addiu $2,$6,28264
addu $3,$6,$2
sec18:
nop
mfhi $2
mflo $2
addu $6,$6,$2
sec19:
nop
mflo $2
lb $2,9($0)
addu $2,$6,$2
sec20:
nop
lhu $2,14($0)
nop
addu $3,$6,$2
sec21:
nop
lbu $2,3($0)
subu $2,$2,$2
addu $3,$6,$2
sec22:
nop
lh $2,6($0)
ori $2,$4,33206
addu $1,$6,$2
sec23:
nop
lb $2,1($0)
mflo $2
addu $3,$6,$2
sec24:
nop
lb $2,9($0)
lh $2,12($0)
addu $5,$6,$2
sec25:
addu $6,$3,$4
nop
nop
addu $3,$6,$2
sec26:
addu $6,$4,$0
nop
xor $2,$2,$3
addu $0,$6,$2
sec27:
subu $6,$3,$1
nop
lui $2,54434
addu $6,$6,$2
sec28:
subu $6,$1,$5
nop
mflo $2
addu $4,$6,$2
sec29:
sltu $6,$3,$1
nop
lb $2,4($0)
addu $4,$6,$2
sec30:
and $6,$6,$6
subu $2,$4,$4
nop
addu $5,$6,$2
sec31:
slt $6,$2,$3
subu $2,$1,$6
or $2,$1,$1
addu $5,$6,$2
sec32:
xor $6,$4,$5
sltu $2,$2,$4
xori $2,$3,54260
addu $2,$6,$2
sec33:
and $6,$3,$3
addu $2,$1,$1
mfhi $2
addu $2,$6,$2
sec34:
nor $6,$3,$3
and $2,$3,$6
lb $2,10($0)
addu $3,$6,$2
sec35:
addu $6,$3,$4
addiu $2,$4,26122
nop
addu $3,$6,$2
sec36:
addu $6,$4,$3
sltiu $2,$3,-5763
nor $2,$0,$2
addu $3,$6,$2
sec37:
subu $6,$0,$2
ori $2,$3,22064
sltiu $2,$3,-10954
addu $3,$6,$2
sec38:
slt $6,$5,$1
andi $2,$5,64607
mfhi $2
addu $6,$6,$2
sec39:
slt $6,$3,$1
addiu $2,$3,-16280
lhu $2,2($0)
addu $3,$6,$2
sec40:
or $6,$2,$6
mflo $2
nop
addu $3,$6,$2
sec41:
or $6,$3,$1
mfhi $2
addu $2,$3,$1
addu $1,$6,$2
sec42:
addu $6,$3,$4
mfhi $2
andi $2,$2,35079
addu $4,$6,$2
sec43:
xor $6,$4,$2
mfhi $2
mflo $2
addu $2,$6,$2
sec44:
sltu $6,$2,$5
mfhi $2
lbu $2,13($0)
addu $5,$6,$2
sec45:
xor $6,$5,$3
lw $2,12($0)
nop
addu $1,$6,$2
sec46:
sltu $6,$5,$4
lw $2,4($0)
nor $2,$1,$3
addu $2,$6,$2
sec47:
slt $6,$1,$1
lw $2,12($0)
andi $2,$3,50618
addu $3,$6,$2
sec48:
nor $6,$3,$3
lhu $2,6($0)
mflo $2
addu $4,$6,$2
sec49:
sltu $6,$3,$6
lw $2,12($0)
lhu $2,8($0)
addu $4,$6,$2
sec50:
andi $6,$4,2735
nop
nop
addu $1,$6,$2
sec51:
lui $6,36479
nop
addu $2,$3,$6
addu $1,$6,$2
sec52:
xori $6,$3,19149
nop
lui $2,37921
addu $3,$6,$2
sec53:
xori $6,$1,23335
nop
mfhi $2
addu $3,$6,$2
sec54:
slti $6,$3,30884
nop
lw $2,0($0)
addu $4,$6,$2
sec55:
lui $6,16494
nor $2,$2,$3
nop
addu $1,$6,$2
sec56:
addiu $6,$6,-26779
slt $2,$1,$6
and $2,$3,$3
addu $5,$6,$2
sec57:
xori $6,$3,44486
xor $2,$3,$2
ori $2,$4,51741
addu $5,$6,$2
sec58:
ori $6,$4,41852
slt $2,$6,$4
mflo $2
addu $0,$6,$2
sec59:
ori $6,$1,14635
addu $2,$6,$0
lw $2,4($0)
addu $2,$6,$2
sec60:
xori $6,$4,25416
lui $2,53106
nop
addu $3,$6,$2
sec61:
sltiu $6,$4,11142
ori $2,$3,47714
or $2,$5,$4
addu $0,$6,$2
sec62:
lui $6,33290
xori $2,$5,37293
slti $2,$5,-15304
addu $4,$6,$2
sec63:
andi $6,$2,3277
sltiu $2,$4,29026
mflo $2
addu $4,$6,$2
sec64:
xori $6,$4,42088
ori $2,$4,52616
lh $2,2($0)
addu $2,$6,$2
sec65:
xori $6,$2,18361
mflo $2
nop
addu $6,$6,$2
sec66:
lui $6,47857
mflo $2
sltu $2,$4,$4
addu $5,$6,$2
sec67:
xori $6,$3,28219
mfhi $2
ori $2,$5,6526
addu $2,$6,$2
sec68:
andi $6,$3,44843
mfhi $2
mfhi $2
addu $1,$6,$2
sec69:
lui $6,47274
mfhi $2
lhu $2,8($0)
addu $3,$6,$2
sec70:
andi $6,$3,25665
lw $2,12($0)
nop
addu $4,$6,$2
sec71:
addiu $6,$2,565
lhu $2,0($0)
subu $2,$2,$3
addu $0,$6,$2
sec72:
lui $6,42158
lb $2,5($0)
xori $2,$5,23572
addu $3,$6,$2
sec73:
slti $6,$1,20224
lhu $2,6($0)
mfhi $2
addu $3,$6,$2
sec74:
ori $6,$3,40629
lhu $2,4($0)
lw $2,16($0)
addu $2,$6,$2
sec75:
mflo $6
nop
nop
addu $3,$6,$2
sec76:
mfhi $6
nop
sltu $2,$6,$2
addu $3,$6,$2
sec77:
mflo $6
nop
lui $2,29746
addu $4,$6,$2
sec78:
mfhi $6
nop
mfhi $2
addu $0,$6,$2
sec79:
mfhi $6
nop
lbu $2,6($0)
addu $0,$6,$2
sec80:
mfhi $6
or $2,$4,$4
nop
addu $2,$6,$2
sec81:
mflo $6
xor $2,$6,$4
addu $2,$3,$2
addu $0,$6,$2
sec82:
mflo $6
or $2,$4,$3
andi $2,$4,49166
addu $4,$6,$2
sec83:
mflo $6
subu $2,$3,$3
mfhi $2
addu $1,$6,$2
sec84:
mflo $6
slt $2,$4,$4
lb $2,0($0)
addu $2,$6,$2
sec85:
mflo $6
sltiu $2,$3,-11337
nop
addu $2,$6,$2
sec86:
mfhi $6
xori $2,$0,24139
and $2,$0,$2
addu $2,$6,$2
sec87:
mflo $6
addiu $2,$6,23665
lui $2,27121
addu $2,$6,$2
sec88:
mfhi $6
xori $2,$1,28432
mfhi $2
addu $5,$6,$2
sec89:
mflo $6
ori $2,$6,43073
lb $2,15($0)
addu $1,$6,$2
sec90:
mflo $6
mflo $2
nop
addu $4,$6,$2
sec91:
mfhi $6
mflo $2
subu $2,$2,$5
addu $5,$6,$2
sec92:
mfhi $6
mfhi $2
andi $2,$1,18843
addu $3,$6,$2
sec93:
mflo $6
mflo $2
mfhi $2
addu $4,$6,$2
sec94:
mfhi $6
mflo $2
lbu $2,7($0)
addu $3,$6,$2
sec95:
mfhi $6
lw $2,4($0)
nop
addu $1,$6,$2
sec96:
mflo $6
lh $2,0($0)
and $2,$1,$3
addu $3,$6,$2
sec97:
mfhi $6
lb $2,12($0)
slti $2,$3,-9760
addu $4,$6,$2
sec98:
mflo $6
lhu $2,6($0)
mfhi $2
addu $1,$6,$2
sec99:
mfhi $6
lhu $2,4($0)
lb $2,10($0)
addu $5,$6,$2
sec100:
lhu $6,2($0)
nop
nop
addu $1,$6,$2
sec101:
lbu $6,14($0)
nop
slt $2,$4,$6
addu $0,$6,$2
sec102:
lh $6,2($0)
nop
addiu $2,$3,2909
addu $3,$6,$2
sec103:
lw $6,4($0)
nop
mflo $2
addu $3,$6,$2
sec104:
lh $6,0($0)
nop
lbu $2,13($0)
addu $0,$6,$2
sec105:
lw $6,4($0)
slt $2,$4,$4
nop
addu $1,$6,$2
sec106:
lbu $6,8($0)
xor $2,$2,$0
or $2,$5,$1
addu $3,$6,$2
sec107:
lb $6,2($0)
slt $2,$4,$0
addiu $2,$0,9317
addu $4,$6,$2
sec108:
lbu $6,13($0)
nor $2,$5,$1
mflo $2
addu $4,$6,$2
sec109:
lh $6,16($0)
addu $2,$0,$1
lh $2,12($0)
addu $6,$6,$2
sec110:
lhu $6,14($0)
sltiu $2,$3,16614
nop
addu $2,$6,$2
sec111:
lhu $6,0($0)
lui $2,13348
xor $2,$3,$5
addu $1,$6,$2
sec112:
lh $6,10($0)
addiu $2,$4,9527
andi $2,$3,59443
addu $4,$6,$2
sec113:
lw $6,0($0)
slti $2,$0,23505
mfhi $2
addu $3,$6,$2
sec114:
lh $6,8($0)
xori $2,$3,42746
lh $2,14($0)
addu $0,$6,$2
sec115:
lb $6,8($0)
mfhi $2
nop
addu $5,$6,$2
sec116:
lhu $6,12($0)
mflo $2
xor $2,$1,$3
addu $1,$6,$2
sec117:
lw $6,4($0)
mflo $2
addiu $2,$2,-4555
addu $2,$6,$2
sec118:
lh $6,2($0)
mflo $2
mfhi $2
addu $3,$6,$2
sec119:
lw $6,4($0)
mflo $2
lb $2,12($0)
addu $1,$6,$2
sec120:
lw $6,12($0)
lw $2,0($0)
nop
addu $5,$6,$2
sec121:
lw $6,0($0)
lw $2,12($0)
xor $2,$2,$3
addu $1,$6,$2
sec122:
lbu $6,0($0)
lhu $2,4($0)
sltiu $2,$6,27011
addu $4,$6,$2
sec123:
lw $6,16($0)
lw $2,4($0)
mfhi $2
addu $2,$6,$2
sec124:
lw $6,12($0)
lhu $2,6($0)
lhu $2,2($0)
addu $4,$6,$2
|
Transynther/x86/_processed/NONE/_ht_zr_/i9-9900K_12_0xca.log_4_878.asm | ljhsiun2/medusa | 9 | 171828 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %r8
push %rax
push %rsi
lea addresses_D_ht+0x96bc, %rsi
nop
nop
sub %r13, %r13
mov (%rsi), %eax
nop
nop
cmp %r15, %r15
lea addresses_normal_ht+0xbe0c, %r8
nop
nop
cmp %r11, %r11
mov (%r8), %r12w
nop
nop
nop
nop
add $369, %rax
lea addresses_D_ht+0x5d2c, %r15
nop
nop
nop
nop
xor %r8, %r8
vmovups (%r15), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r13
nop
nop
nop
nop
add %r15, %r15
lea addresses_WC_ht+0x182cc, %rax
nop
nop
nop
nop
nop
inc %r11
mov (%rax), %r8d
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_A_ht+0x442c, %r11
nop
nop
add $62764, %rsi
movb (%r11), %r13b
nop
inc %r12
pop %rsi
pop %rax
pop %r8
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0xce8c, %r12
nop
nop
xor $46764, %rax
mov $0x5152535455565758, %rdi
movq %rdi, (%r12)
nop
nop
nop
nop
add $55712, %rbx
// Load
lea addresses_RW+0x73ac, %r8
nop
nop
nop
xor %rbp, %rbp
vmovups (%r8), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r12
nop
nop
nop
cmp %rbp, %rbp
// Store
lea addresses_UC+0x1a9ec, %rbp
nop
nop
nop
cmp $710, %r14
movw $0x5152, (%rbp)
nop
inc %r8
// REPMOV
lea addresses_PSE+0x128f1, %rsi
mov $0x18cf650000000eac, %rdi
nop
nop
nop
nop
inc %r8
mov $54, %rcx
rep movsb
nop
nop
nop
nop
nop
xor $47964, %r8
// Faulty Load
lea addresses_WT+0xe82c, %r14
sub $30249, %rdi
vmovups (%r14), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rsi
lea oracles, %r14
and $0xff, %rsi
shlq $12, %rsi
mov (%r14,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': True, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_PSE', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_NC', 'congruent': 6}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 10}}
{'00': 2, '46': 2}
46 00 46 00
*/
|
oeis/314/A314672.asm | neoneye/loda-programs | 11 | 81316 | ; A314672: Coordination sequence Gal.4.38.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by <NAME>(s2)
; 1,5,9,13,17,21,25,29,34,39,43,47,51,55,59,63,68,73,77,81,85,89,93,97,102,107,111,115,119,123,127,131,136,141,145,149,153,157,161,165,170,175,179,183,187,191,195,199,204,209
mov $1,$0
pow $1,2
mov $3,$0
mul $3,3
add $3,$0
div $0,8
mov $2,$3
add $2,1
mul $2,2
div $1,$2
add $1,$0
add $1,$3
mov $0,$1
add $0,1
|
src/fot/FOTC/Program/Division/ResultATP.agda | asr/fotc | 11 | 561 | <reponame>asr/fotc<gh_stars>10-100
------------------------------------------------------------------------------
-- The division result is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Division.ResultATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.PropertiesATP
open import FOTC.Program.Division.Division
open import FOTC.Program.Division.Specification
------------------------------------------------------------------------------
-- The division result is correct when the dividend is less than
-- the divisor.
postulate div-x<y-helper : ∀ {i j} → N i → N j → i < j → i ≡ j * div i j + i
{-# ATP prove div-x<y-helper *-rightZero #-}
div-x<y-resultCorrect : ∀ {i j} → N i → N j → i < j →
∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r
div-x<y-resultCorrect Ni Nj i<j = _ , Ni , i<j , div-x<y-helper Ni Nj i<j
-- The division result is correct when the dividend is greater or equal
-- than the divisor.
-- Using the inductive hypothesis ih we know that
--
-- i ∸ j = j * (div (i ∸ j) j) + r.
-- From that we get
--
-- i = j * (succ (div (i ∸ j) j)) + r and we know
--
-- div i j = succ (div (i ∸ j) j) therefore we get
--
-- i = j * div i j + r.
postulate helper : ∀ {i j r} → N i → N j → N r →
i ∸ j ≡ j * div (i ∸ j) j + r →
i ≡ j * succ₁ (div (i ∸ j) j) + r
postulate div-x≮y-helper : ∀ {i j r} → N i → N j → N r →
i ≮ j →
i ∸ j ≡ j * div (i ∸ j) j + r →
i ≡ j * div i j + r
{-# ATP prove div-x≮y-helper helper #-}
postulate div-x≮y-resultCorrect : ∀ {i j} → N i → N j →
(ih : divSpec (i ∸ j) j (div (i ∸ j) j)) →
i ≮ j →
∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r
{-# ATP prove div-x≮y-resultCorrect div-x≮y-helper #-}
|
oeis/179/A179060.asm | neoneye/loda-programs | 11 | 243711 | ; A179060: Number of non-attacking placements of 5 rooks on an n X n board.
; 0,0,0,0,120,4320,52920,376320,1905120,7620480,25613280,75271680,198764280,480960480,1082161080,2289530880,4594961280,8809274880,16225246080,28844881920,49689816120,83217546720,135870624120,216790801920,338735628000,519241008000,782079948000,1159075008000,1692330003000,2436955204320,3464369750520,4866275205120,6759405227520,9291168184320,12646312250880,17054756167680,22800743353080,30233492563680,39779534765880,51956943367680,67391683488480,86836325546880,111191389152480,141529605127680
add $0,1
bin $0,5
pow $0,2
mul $0,120
|
alloy4fun_models/trashltl/models/4/DkazuGYBFEmFiPwF9.als | Kaixi26/org.alloytools.alloy | 0 | 1787 | open main
pred idDkazuGYBFEmFiPwF9_prop5 {
some f : File | eventually f not in File
}
pred __repair { idDkazuGYBFEmFiPwF9_prop5 }
check __repair { idDkazuGYBFEmFiPwF9_prop5 <=> prop5o } |
Blob_Lib/assimp-5.2.3/assimp/contrib/zlib/contrib/ada/zlib.ads | antholuo/Blob_Traffic | 0 | 2227 | <reponame>antholuo/Blob_Traffic
version https://git-lfs.github.com/spec/v1
oid sha256:02634bec0d5e4c69d8d2859124380074a57de8d8bd928398379bfacc514236d2
size 13594
|
src/pp/iloc/parse/ILOC.g4 | Pieterjaninfo/PP | 1 | 3762 | <reponame>Pieterjaninfo/PP
grammar ILOC;
@header{package pp.iloc.parse;}
fragment LETTER: [a-zA-Z];
fragment DIGIT: [0-9];
/** Full ILOC program. */
program: decl* instr (EOL+ instr)* EOL* EOF;
decl: ID ASS NUM COMMENT? EOL+
;
/** Instruction: single op or []-bracketed non-empty op sequence. */
instr
: (label ':')?
op #singleInstr
| (label ':')?
LSQ
EOL*
op
(EOL+ op)*
EOL*
RSQ #instrList
;
/** Single operation. */
op : COMMENT #comment
| opCode sources ((ARROW|DARROW) targets)?
SEMI?
COMMENT? #realOp
;
sources: (operand (COMMA operand)*)?;
targets: operand (COMMA operand)*;
/** Operation label. */
label: ID;
/** Opcode: not distinguished by the parser. */
opCode: ID;
/** Operand: ID (label or register), number or string. */
operand : ID | NUM | SYMB | LAB | STR;
MINUS: '-';
COMMA: ',';
SEMI: ';';
LSQ: '[';
RSQ: ']';
DARROW: '=>';
ARROW: '->';
ASS: '<-';
/** Identifier. */
ID: LETTER (LETTER|DIGIT|[\-_])*;
/** Symbolic name. */
SYMB: '@' ID;
/** Label used as numeric parameter. */
LAB: '#' ID;
/** Number. */
NUM: MINUS? DIGIT+;
/** String with optional escaped double quotes. */
STR : '"' (~["\n\r] | '\\"')* '"';
/** Java-style comment: // to end of line */
COMMENT: '//' ~[\r\n]*;
/** Whitespace. */
WS : [ \t]+ -> skip;
EOL : [\r\n]+; |
src/main/antlr4/wallpaper.g4 | joaobarbirato/compilador-NPR | 0 | 1964 |
/* Gramática Wallpaper
** Autores RA
** - <NAME> 726507
** - <NAME> 726546
** - <NAME> 726552
** - <NAME> 486060
*/
grammar wallpaper;
fragment
LETRA
: 'a'..'z'|'A'..'Z'
;
fragment
ALGARISMO
: '0'..'9'
;
HEX
: '0x' (LETRA|ALGARISMO)*
;
NUM_INT
: '-'? (ALGARISMO)+
;
NUM_REAL
: (ALGARISMO)+ '.' (ALGARISMO)+
;
WS : (' ') -> skip ;
ENDL
: ([\n] | [\t] | [\r]) -> skip
;
IDENT
: (LETRA | '_') ('_'| ALGARISMO | LETRA)*
;
CAMINHO
: '"' (LETRA | '_' | '-' | '.' | '/' | ALGARISMO)+ '"'
;
programa
: declaracao corpo*
;
declaracao
: imagem+
;
imagem
: 'Img' IDENT ';'
;
corpo
: IDENT '.' propriedade
;
propriedade
: cor | tamanho | nome_arquivo | conteudo | filtro
;
filtro
: 'filtro' '=' filtro_opcoes
;
filtro_opcoes
: 'desfoque' | 'relevo' | 'contorno'
;
conteudo
: 'conteudo' '=' '{' (valores|referencia)+ '}'
;
valores
: forma '=' '[' atributos ']'
| 'importado' '=' '[' chave caminho tamanho? ']'
;
atributos
: chave cor posicao
;
caminho
: 'caminho' '=' CAMINHO
;
referencia
: 'copia' '->' IDENT '.' IDENT '[' 'chave' '=' IDENT cor? posicao? ']'
;
forma
: 'retangulo' | 'triangulo' | 'circulo'
;
chave
: 'chave' '=' IDENT
;
cor
: 'cor' '=' HEX
;
tamanho
: 'tamanho' '=' '(' NUM_INT ',' NUM_INT ')'
;
posicao
: 'posicao' '=' '(' NUM_INT ',' NUM_INT (',' NUM_INT ',' NUM_INT)+ ')'
;
nome_arquivo
: 'nome' '=' CAMINHO
; |
alloy4fun_models/trashltl/models/11/7X2Xf9szSKcpPz6mQ.als | Kaixi26/org.alloytools.alloy | 0 | 4519 | open main
pred id7X2Xf9szSKcpPz6mQ_prop12 {
always all f:File | eventually f in Trash implies always f in Trash'
}
pred __repair { id7X2Xf9szSKcpPz6mQ_prop12 }
check __repair { id7X2Xf9szSKcpPz6mQ_prop12 <=> prop12o } |
oeis/188/A188802.asm | neoneye/loda-programs | 11 | 21440 | <reponame>neoneye/loda-programs
; A188802: Expansion of (x^2+1)/(x^4+2*x^3-2*x+1).
; Submitted by <NAME>
; 1,2,5,8,11,10,-1,-32,-95,-198,-331,-440,-389,82,1375,3968,8161,13490,17669,15048,-5045,-58918,-165601,-336160,-549439,-708758,-579595,275848,2518651,6905250,13838399,22363648,28398145,22214242,-14137211,-107434360,-287695349,-569330518,-909655105,-1136485152,-846613919,695412890,4573451189,11976615368,23409018875,36975722482,45424763039,32054872960,-33250717919,-194326684398,-498187877755,-961929192632,-1501954298549,-1813206157190,-1204366051361,1557105687008,8242577986945,20707094233802
mov $2,1
mov $5,1
lpb $0
sub $0,1
add $1,$3
sub $3,$4
mov $4,$2
mov $2,$3
add $5,$4
mov $3,$5
add $4,$1
add $5,$2
lpe
add $5,$1
mov $0,$5
|
examples/DTP08/ulf/Talk.agda | cruhland/agda | 1,989 | 10033 | <filename>examples/DTP08/ulf/Talk.agda
{-
TBA - Talk 'Bout Agda
<NAME>
Chalmers
DTP 2008, Nottingham
-}
module Talk where
-- Normal everyday lists
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
infixr 40 _::_
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
-- More boring types: Bool and Maybe
data Bool : Set where
false : Bool
true : Bool
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A -> Maybe A
fmap : forall {A B} -> (A -> B) -> Maybe A -> Maybe B
fmap f nothing = nothing
fmap f (just x) = just (f x)
-- The intensional equality type
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
-- Sigma types
data Σ {A : Set}(B : A -> Set) : Set where
_,_ : (x : A) -> B x -> Σ B
fst : {A : Set}{B : A -> Set} -> Σ B -> A
fst (x , y) = x
snd : {A : Set}{B : A -> Set}(p : Σ B) -> B (fst p)
snd (x , y) = y
_×_ : Set -> Set -> Set
A × B = Σ {A} (\_ -> B)
-- A more interesting type
infix 20 _∈_
data _∈_ {A : Set} : A -> List A -> Set where
first : forall {x xs} -> x ∈ x :: xs
later : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs
module Map (K V : Set)
(_=?=_ : (x y : K) -> Maybe (x == y))
where
Map : Set
Map = List (K × V)
HasKey : K -> Map -> Set
HasKey k m = k ∈ map fst m
member : (x : K)(m : Map) -> Maybe (HasKey x m)
member x [] = nothing
member x ((y , v) :: m) with x =?= y
... | nothing = fmap later (member x m)
member x ((.x , v) :: m) | just refl = just first
lookup : (x : K)(m : Map) -> HasKey x m -> Σ \v -> (x , v) ∈ m
lookup x [] ()
lookup x ((.x , u) :: m) first = u , first
lookup x (e :: m) (later p) with lookup x m p
... | v , q = v , later q
|
data/moves/secret_power.asm | AtmaBuster/pokeplat-gen2 | 6 | 163744 | <reponame>AtmaBuster/pokeplat-gen2
secretpowerdata: MACRO
db \1
dw \2
dba \3
ENDM
SecretPowerTypeData:
secretpowerdata NORMAL, BODY_SLAM, BattleCommand_paralyzetarget
secretpowerdata GROUND, MUD_SLAP, SecretPowerLowerAccuracy
secretpowerdata ROCK, ROCK_THROW, BattleCommand_flinchtarget
secretpowerdata GRASS, NEEDLE_ARM, SecretPowerSleep
secretpowerdata WATER, WATER_PULSE, SecretPowerLowerAttack
secretpowerdata ICE, AVALANCHE, BattleCommand_freezetarget
db -1
|
source/amf/uml/amf-uml-templateable_elements.ads | svn2github/matreshka | 24 | 28129 | <gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- 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 templateable element is an element that can optionally be defined as a
-- template and bound to other templates.
------------------------------------------------------------------------------
with AMF.UML.Elements;
limited with AMF.UML.Parameterable_Elements.Collections;
limited with AMF.UML.Template_Bindings.Collections;
limited with AMF.UML.Template_Signatures;
package AMF.UML.Templateable_Elements is
pragma Preelaborate;
type UML_Templateable_Element is limited interface
and AMF.UML.Elements.UML_Element;
type UML_Templateable_Element_Access is
access all UML_Templateable_Element'Class;
for UML_Templateable_Element_Access'Storage_Size use 0;
not overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Templateable_Element)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access is abstract;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
not overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Templateable_Element;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is abstract;
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
not overriding function Get_Template_Binding
(Self : not null access constant UML_Templateable_Element)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding is abstract;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
not overriding function Is_Template
(Self : not null access constant UML_Templateable_Element)
return Boolean is abstract;
-- Operation TemplateableElement::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
not overriding function Parameterable_Elements
(Self : not null access constant UML_Templateable_Element)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element is abstract;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
end AMF.UML.Templateable_Elements;
|
Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2_notsx.log_12_1578.asm | ljhsiun2/medusa | 9 | 167302 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x35a8, %rsi
lea addresses_UC_ht+0x113a8, %rdi
clflush (%rdi)
nop
nop
nop
nop
and $35688, %rbp
mov $78, %rcx
rep movsl
cmp %rbx, %rbx
lea addresses_normal_ht+0x1e398, %r12
nop
inc %rbx
movw $0x6162, (%r12)
nop
nop
nop
cmp %rsi, %rsi
lea addresses_WC_ht+0x1da8, %rsi
lea addresses_A_ht+0x1c4a8, %rdi
dec %rdx
mov $30, %rcx
rep movsb
nop
nop
nop
nop
sub $4197, %rdx
lea addresses_A_ht+0x130dc, %rsi
lea addresses_A_ht+0x4428, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
sub %rdx, %rdx
mov $32, %rcx
rep movsl
nop
nop
nop
dec %rdx
lea addresses_D_ht+0x7c48, %rsi
nop
sub %rbp, %rbp
mov (%rsi), %ecx
nop
nop
nop
sub %rsi, %rsi
lea addresses_normal_ht+0x15fa8, %rsi
lea addresses_WC_ht+0x8114, %rdi
nop
nop
nop
nop
nop
and $31672, %r14
mov $59, %rcx
rep movsb
nop
nop
add %r12, %r12
lea addresses_WC_ht+0xeb88, %rsi
lea addresses_A_ht+0xe858, %rdi
nop
nop
nop
nop
sub %rbx, %rbx
mov $31, %rcx
rep movsq
nop
nop
nop
nop
cmp %r12, %r12
lea addresses_D_ht+0x89c8, %r12
and %r14, %r14
and $0xffffffffffffffc0, %r12
movntdqa (%r12), %xmm4
vpextrq $1, %xmm4, %rdi
nop
nop
nop
nop
add $47388, %rbp
lea addresses_D_ht+0x159b, %rsi
nop
nop
nop
nop
cmp %rbx, %rbx
mov (%rsi), %r12w
nop
nop
nop
nop
cmp %r12, %r12
lea addresses_D_ht+0x121a8, %rsi
nop
and $38091, %r14
movw $0x6162, (%rsi)
nop
sub %rbp, %rbp
lea addresses_WT_ht+0x15a8, %rsi
lea addresses_WC_ht+0x1e84c, %rdi
nop
nop
nop
sub $64841, %r14
mov $54, %rcx
rep movsb
nop
nop
dec %r12
lea addresses_A_ht+0x6d08, %rsi
lea addresses_WC_ht+0x37e8, %rdi
nop
nop
xor $20757, %r12
mov $108, %rcx
rep movsl
add %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r8
push %rbx
push %rcx
push %rdx
push %rsi
// Store
lea addresses_WT+0xb528, %r8
nop
nop
nop
sub $58429, %rdx
movw $0x5152, (%r8)
nop
nop
xor %rbx, %rbx
// Store
lea addresses_D+0x4fa8, %r14
nop
nop
nop
nop
nop
xor %r11, %r11
movl $0x51525354, (%r14)
nop
nop
nop
add %r14, %r14
// Store
lea addresses_WT+0x3871, %rcx
nop
nop
nop
nop
nop
sub $20533, %rdx
mov $0x5152535455565758, %r8
movq %r8, (%rcx)
nop
nop
inc %rdx
// Store
lea addresses_WT+0xf20c, %rdx
nop
nop
inc %rsi
movb $0x51, (%rdx)
nop
nop
nop
nop
nop
inc %rbx
// Faulty Load
lea addresses_US+0x85a8, %rbx
nop
nop
nop
nop
nop
cmp $65121, %rsi
movups (%rbx), %xmm3
vpextrq $1, %xmm3, %r14
lea oracles, %rbx
and $0xff, %r14
shlq $12, %r14
mov (%rbx,%r14,1), %r14
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'00': 12}
00 00 00 00 00 00 00 00 00 00 00 00
*/
|
examples/ATPAxiomPostulates.agda | asr/apia | 10 | 15559 | -- The ATP pragma with the role <axiom> can be used with postulates.
module ATPAxiomPostulates where
postulate
D : Set
zero : D
succ : D → D
N : D → Set
postulate
zN : N zero
sN : ∀ {n} → N n → N (succ n)
{-# ATP axiom zN #-}
|
ordinary/runge_8th_order_demo_3.adb | jscparker/math_packages | 30 | 1029 | <filename>ordinary/runge_8th_order_demo_3.adb
with Runge_8th;
with Text_IO; use Text_IO;
with Quadrature;
with Ada.Numerics.Generic_Elementary_Functions;
procedure runge_8th_order_demo_3 is
type Real is digits 15;
package mth is new Ada.Numerics.Generic_Elementary_Functions(Real);
use mth; -- for Sin
package quadr is new Quadrature (Real, Sin);
use quadr;
package Area_Under_the_Curve is new
Runge_8th (Real, Dyn_Index, Dynamical_Variable, F, "*", "+", "-", Norm);
use Area_Under_the_Curve;
package rio is new Float_IO(Real);
use rio;
package iio is new Integer_IO(Step_Integer);
use iio;
Initial_Condition : Dynamical_Variable;
Previous_Y, Final_Y : Dynamical_Variable;
Final_Time, Starting_Time : Real;
Previous_t, Final_t : Real;
Delta_t : Real;
Steps : Step_Integer;
Error_Tolerance : Real := 1.0E-10;
Error_Control_Desired : Boolean := False;
Answer : Character := 'n';
begin
-- choose initial conditions
new_line;
put ("The test integrates (d/dt) Y(t) = Sin(t) for Y(t).");
new_line(2);
put ("Ordinary quadrature is just an area-under-the-curve problem, ");
new_line;
put ("where you solve: (d/dt) Y(t) = Sin(t) for Y.");
new_line(2);
put ("Input number of steps (try 16 with and without error control)");
new_line;
get (Steps);
new_line;
put ("Every time the integration advances this number of steps, ERROR is printed.");
new_line;
new_line;
put ("Use error control? Enter y or n:"); new_line; get (Answer);
if (Answer = 'Y') or (Answer = 'y') then
Error_Control_Desired := True;
put ("Error control it is."); new_line;
else
Error_Control_Desired := False;
put ("OK, no error control."); new_line;
end if;
Initial_Condition(0) := -1.0;
Starting_Time := 0.0;
Final_Time := 32.0;
Previous_Y := Initial_Condition;
Previous_t := Starting_Time;
Delta_t := Final_Time - Starting_Time;
for i in 1..20 loop
Final_t := Previous_t + Delta_t;
Integrate
(Final_State => Final_Y, -- the result (output).
Final_Time => Final_t, -- end integration here.
Initial_State => Previous_Y, -- the initial condition (input).
Initial_Time => Previous_t, -- start integrating here.
No_Of_Steps => Steps, -- if no err control, uses this.
Error_Control_Desired => Error_Control_Desired,
Error_Tolerance => Error_Tolerance);
Previous_Y := Final_Y;
Previous_t := Final_t;
new_line;
put ("Time = t =");
put (Final_t, Aft => 7);
put (", Error = (Cos (t) - Integrated Cos) = ");
put (Abs (-Cos(Final_t) - Final_Y(0)), Aft => 7);
end loop;
if (Answer = 'Y') or (Answer = 'y') then
new_line(2);
put ("With error control enabled, program attempted to reduce");
new_line;
put ("error *per step* to (well) under: ");
put (Error_Tolerance, Aft => 6);
new_line;
put ("Over thousands of steps, accumulated error will be much larger than that.");
new_line(2);
end if;
end;
|
oeis/008/A008430.asm | neoneye/loda-programs | 11 | 177746 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A008430: Theta series of D_8 lattice.
; Submitted by <NAME>
; 1,112,1136,3136,9328,14112,31808,38528,74864,84784,143136,149184,261184,246176,390784,395136,599152,550368,859952,768320,1175328,1078784,1513152,1362816,2096192,1764112,2496928,2289280,3208832,2731680,4007808,3336704,4793456,4177152,5582304,4854528,7061296,5673248,7792960,6892928,9432864,7719264,10941952,8904896,12424896,10682784,13822848,11628288,16776256,13215216,17893136,15410304,20502944,16674336,23219840,18797184,25753216,21512960,27707040,23002560,32909184,25421984,33843712,29165696
mul $0,2
seq $0,143 ; Number of ways of writing n as a sum of 8 squares.
|
theorems/index.agda | mikeshulman/HoTT-Agda | 0 | 1069 | {-# OPTIONS --without-K --rewriting #-}
{-
Imports everything that is not imported by something else.
This is not supposed to be used anywhere, this is just a simple way to
do `make all'
This file is intentionally named index.agda so that
Agda will generate index.html.
-}
module index where
{- some group theory results -}
import groups.ReducedWord
import groups.ProductRepr
import groups.CoefficientExtensionality
{- homotopy groups of circles -}
import homotopy.LoopSpaceCircle
import homotopy.PinSn
import homotopy.HopfJunior
import homotopy.Hopf
{- cohomology -}
import cohomology.EMModel
import cohomology.Sigma
import cohomology.Coproduct
import cohomology.Torus
-- import cohomology.MayerVietorisExact -- FIXME
{- prop * prop is still a prop -}
import homotopy.PropJoinProp
{- a space with preassigned homotopy groups -}
import homotopy.SpaceFromGroups
{- pushout 3x3 lemma -}
{- These takes lots of time and memory to check. -}
-- import homotopy.3x3.Commutes -- commented out because this does not run on travis.
-- import homotopy.JoinAssoc3x3 -- commented out because this does not run on travis.
{- covering spaces -}
import homotopy.GroupSetsRepresentCovers
import homotopy.AnyUniversalCoverIsPathSet
import homotopy.PathSetIsInitalCover
{- van kampen -}
import homotopy.VanKampen
{- blakers massey -}
import homotopy.BlakersMassey
{- cw complexes -}
import cw.CW
import cw.examples.Examples
-- cellular cohomology groups
import cw.cohomology.CellularChainComplex
-- Eilenberg-Steenred cohomology groups rephrased
import cw.cohomology.ReconstructedCohomologyGroups
-- isomorphisms between the cochains the heads
import cw.cohomology.ReconstructedCochainsIsoCellularCochains
-- There are some unported theorems
-- import Spaces.IntervalProps
-- import Algebra.F2NotCommutative
-- import Spaces.LoopSpaceDecidableWedgeCircles
-- import Homotopy.PullbackIsPullback
-- import Homotopy.PushoutIsPushout
-- import Homotopy.Truncation
-- import Sets.QuotientUP
|
day01/tests/day1_suite.adb | jwarwick/aoc_2019_ada | 0 | 13885 | with Day1.Test;
package body Day1_Suite is
function Suite return Access_Test_Suite is
Ret : constant Access_Test_Suite := new Test_Suite;
begin
Ret.Add_Test (new Day1.Test.Test);
return Ret;
end Suite;
end Day1_Suite;
|
PIM/TP6_Modules/stocks_materiel.adb | Hathoute/ENSEEIHT | 1 | 22833 | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
-- Auteur:
-- Gérer un stock de matériel informatique.
--
package body Stocks_Materiel is
-- Helpers
function Indice(Stock: in T_Stock; Numero_Serie: in Integer) return Integer is
begin
for J in 1..Stock.Nombre loop
if Stock.Materiels(J).Numero_Serie = Numero_Serie then
return J;
end if;
end loop;
return -1; -- Non trouvé, on retourne -1
end;
procedure Afficher_Materiel(Materiel: in T_Materiel) is
begin
Put("Matériel de numéro ");
Put(Materiel.Numero_Serie, 1);
Put_Line(":");
Put_Line("Type: " & T_Nature'Image(Materiel.Nature));
Put("Année: ");
Put(Materiel.Annee_Achat, 1);
New_Line;
if Materiel.Est_Fonctionnel then
Put_Line("Ce matériel est fonctionnel!");
else
Put_Line("Ce matériel est défectueux!");
end if;
end;
-- Sous Programmes du Module.
procedure Creer (Stock : out T_Stock) is
begin
Stock.Nombre := 0;
end Creer;
function Nb_Materiels (Stock: in T_Stock) return Integer is
begin
return Stock.Nombre;
end;
procedure Enregistrer (
Stock : in out T_Stock;
Numero_Serie : in Integer;
Nature : in T_Nature;
Annee_Achat : in Integer
) is
begin
Stock.Nombre := Stock.Nombre + 1;
Stock.Materiels(Stock.Nombre).Numero_Serie := Numero_Serie;
Stock.Materiels(Stock.Nombre).Nature := Nature;
Stock.Materiels(Stock.Nombre).Annee_Achat := Annee_Achat;
Stock.Materiels(Stock.Nombre).Est_Fonctionnel := True;
end;
function Nb_Defectueux (Stock: in T_Stock) return Integer is
Nbr: Integer := 0;
begin
for J in 1..Stock.Nombre loop
if not Stock.Materiels(J).Est_Fonctionnel then
Nbr := Nbr + 1;
end if;
end loop;
return Nbr;
end;
procedure Mettre_A_Jour (
Stock: in out T_Stock;
Numero_Serie: in Integer;
Est_Fonctionnel: in Boolean
) is
Position: Integer;
begin
Position := Indice(Stock, Numero_Serie);
Stock.Materiels(Position).Est_Fonctionnel := Est_Fonctionnel;
end;
procedure Supprimer (
Stock: in out T_Stock;
Numero_Serie: in Integer
) is
Position: Integer;
begin
Position := Indice(Stock, Numero_Serie);
for J in Position..Nb_Materiels(Stock) loop
Stock.Materiels(J) := Stock.Materiels(J+1);
end loop;
Stock.Nombre := Stock.Nombre - 1;
end;
function Existe(Stock: in T_Stock; Numero_Serie: in Integer) return Boolean is
begin
return Indice(Stock, Numero_Serie) > 0;
end;
procedure Afficher (Stock: in T_Stock) is
begin
for J in 1..Nb_Materiels(Stock) loop
Afficher_Materiel(Stock.Materiels(J));
New_Line;
end loop;
end;
procedure Nettoyer(Stock: in out T_Stock) is
Index: Integer;
begin
if Nb_Defectueux(Stock) = 0 then
return;
end if;
Index := 1;
while Index <= Nb_Materiels(Stock) loop
if not Stock.Materiels(Index).Est_Fonctionnel then
Supprimer(Stock, Stock.Materiels(Index).Numero_Serie);
else
Index := Index + 1;
end if;
end loop;
end;
end Stocks_Materiel;
|
programs/oeis/320/A320896.asm | neoneye/loda | 22 | 21059 | ; A320896: a(n) = Sum_{k=1..n} k * tau(k)^2, where tau is A000005.
; 1,9,21,57,77,173,201,329,410,570,614,1046,1098,1322,1562,1962,2030,2678,2754,3474,3810,4162,4254,5790,6015,6431,6863,7871,7987,9907,10031,11183,11711,12255,12815,15731,15879,16487,17111,19671,19835,22523,22695,24279
mov $3,$0
add $3,1
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
sub $0,$3
mov $4,$0
seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n.
mov $2,$0
mul $4,$0
add $0,$4
mul $2,$0
add $1,$2
lpe
mov $0,$1
|
entropy-config-buttons.applescript | rinchen/fesc | 0 | 2697 | on clicked theObject
(*Add your script here.*)
end clicked
|
ejercicios2/escribir_vector.adb | iyan22/AprendeAda | 0 | 28998 | <reponame>iyan22/AprendeAda
with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io;
with vectores; use vectores;
procedure escribir_vector (V : in Vector_De_Enteros) is
--Pre:
--Post: se han escrito en pantalla todos los valores de V
--
begin
for pos in V'First..V'Last loop
put(V(pos), width => 3);
end loop;
new_line;
end escribir_vector;
|
oeis/293/A293901.asm | neoneye/loda-programs | 11 | 98281 | ; A293901: Sum of proper divisors of form 4k+1.
; Submitted by <NAME>(w2)
; 0,1,1,1,1,1,1,1,1,6,1,1,1,1,6,1,1,10,1,6,1,1,1,1,6,14,10,1,1,6,1,1,1,18,6,10,1,1,14,6,1,22,1,1,15,1,1,1,1,31,18,14,1,10,6,1,1,30,1,6,1,1,31,1,19,34,1,18,1,6,1,10,1,38,31,1,1,14,1,6,10,42,1,22,23,1,30,1,1,60,14,1,1,1,6,1,1,50,43,31
mov $2,$0
add $0,1
seq $2,50449 ; a(n) = Sum_{d|n, d==1 (mod 4)} d.
mod $2,$0
mov $0,$2
|
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/a-stbuut.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 8494 | <reponame>JCGobbi/Nucleo-STM32G474RE
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.STRINGS.TEXT_BUFFERS.UTILS --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
package Ada.Strings.Text_Buffers.Utils with Pure is
-- Ada.Strings.Text_Buffers is a predefined unit (see Ada RM A.4.12).
-- This is a GNAT-defined child unit of that parent.
subtype Character_7 is
Character range Character'Val (0) .. Character'Val (2**7 - 1);
procedure Put_7bit
(Buffer : in out Root_Buffer_Type'Class; Item : Character_7);
procedure Put_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Character);
procedure Put_Wide_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Wide_Character);
procedure Put_Wide_Wide_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Wide_Wide_Character);
-- Single character output procedures.
function Column (Buffer : Root_Buffer_Type'Class) return Positive with
Inline;
-- Current output column. The Column is initially 1, and is incremented for
-- each 8-bit character output. A call to New_Line sets Column back to 1.
-- The next character to be output will go in this column.
procedure Tab_To_Column
(Buffer : in out Root_Buffer_Type'Class; Column : Positive);
-- Put spaces until we're at or past Column.
subtype Sink is Root_Buffer_Type;
function NL return Character is (ASCII.LF) with Inline;
function UTF_8_Length (Buffer : Root_Buffer_Type'Class) return Natural;
subtype UTF_8_Lines is UTF_Encoding.UTF_8_String with
Predicate =>
UTF_Encoding.Wide_Wide_Strings.Encode
(UTF_Encoding.Wide_Wide_Strings.Decode (UTF_8_Lines)) = UTF_8_Lines;
subtype UTF_8 is UTF_8_Lines with
Predicate => (for all UTF_8_Char of UTF_8 => UTF_8_Char /= NL);
procedure Put_UTF_8_Lines
(Buffer : in out Root_Buffer_Type'Class; Item : UTF_8_Lines);
private
function UTF_8_Length (Buffer : Root_Buffer_Type'Class) return Natural
is (Buffer.UTF_8_Length);
end Ada.Strings.Text_Buffers.Utils;
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2.log_16987_370.asm | ljhsiun2/medusa | 9 | 10115 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1a90f, %r10
nop
nop
nop
nop
nop
add %rax, %rax
mov (%r10), %rdx
nop
add $60005, %r10
lea addresses_D_ht+0x1a277, %rsi
lea addresses_D_ht+0x199f3, %rdi
nop
nop
nop
inc %r11
mov $48, %rcx
rep movsb
nop
nop
nop
nop
cmp $9415, %rcx
lea addresses_WT_ht+0x18d8f, %rsi
nop
nop
nop
nop
add $57044, %rcx
and $0xffffffffffffffc0, %rsi
vmovaps (%rsi), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $1, %xmm7, %r11
nop
nop
nop
sub $7281, %rax
lea addresses_A_ht+0xa98f, %r10
nop
nop
nop
nop
nop
cmp $60763, %rcx
mov (%r10), %rdx
nop
nop
nop
nop
lfence
lea addresses_A_ht+0x1698f, %r11
cmp %rsi, %rsi
movl $0x61626364, (%r11)
nop
nop
nop
nop
nop
dec %rdx
lea addresses_WC_ht+0x19fc9, %rax
nop
nop
nop
nop
cmp %r11, %r11
movl $0x61626364, (%rax)
nop
nop
nop
cmp $44799, %r10
lea addresses_WT_ht+0x1a48f, %rsi
lea addresses_A_ht+0xb58f, %rdi
nop
nop
nop
inc %r13
mov $64, %rcx
rep movsl
cmp $1495, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r15
push %rbx
push %rdi
push %rsi
// Store
lea addresses_WC+0x4d8f, %r10
cmp %r15, %r15
movb $0x51, (%r10)
nop
nop
and $48918, %rbx
// Store
lea addresses_PSE+0x1ccf7, %rsi
nop
xor $42635, %rbx
mov $0x5152535455565758, %r14
movq %r14, (%rsi)
cmp %r13, %r13
// Faulty Load
lea addresses_D+0x358f, %r15
clflush (%r15)
xor %rdi, %rdi
mov (%r15), %rbx
lea oracles, %rsi
and $0xff, %rbx
shlq $12, %rbx
mov (%rsi,%rbx,1), %rbx
pop %rsi
pop %rdi
pop %rbx
pop %r15
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': True, 'NT': True, 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}}
{'36': 16987}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
json-standards.ads | annexi-strayline/ASAP-JSON | 1 | 20795 | <gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- JSON Parser/Constructor --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2017-2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- 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 copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains all of the formal character and character sets
-- that are defined in the JSON standard (IETF RFD 8259/STD 90)
with Ada.Strings.Wide_Wide_Maps; use Ada.Strings.Wide_Wide_Maps;
package JSON.Standards is
-- Whitespace
Space : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0020#);
Horizontal_Tab : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0009#);
Line_Feed : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_000A#);
Carriage_Return: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_000D#);
-- Whitespace set
Whitespace: constant Wide_Wide_Character_Set := To_Set
(Wide_Wide_Character_Sequence'(1 => Space,
2 => Horizontal_Tab,
3 => Line_Feed,
4 => Carriage_Return));
-- Structural
Begin_Array : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_005B#); -- '['
End_Array : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_005D#); -- ']'
Begin_Object : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_007B#); -- '{'
End_Object : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_007D#); -- '}'
Name_Separator : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_003A#); -- ':'
Value_Separator: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_002C#); -- ','
Structural: constant Wide_Wide_Character_Set := To_Set
(Wide_Wide_String'(1 => Begin_Array,
2 => End_Array,
3 => Begin_Object,
4 => End_Object,
5 => Name_Separator,
6 => Value_Separator));
-- Nesting down set
Nesting_Down : constant Wide_Wide_Character_Set
:= To_Set(Wide_Wide_String'(1 => Begin_Object, 2 => Begin_Array));
Nesting_Up : constant Wide_Wide_Character_Set
:= To_Set(Wide_Wide_String'(1 => End_Object, 2 => End_Array));
-- Literals
Literal_False_Start: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0066#); -- 'f'
Literal_False : constant Wide_Wide_String
:= (1 => Literal_False_Start, -- 'f'
2 => Wide_Wide_Character'Val(16#0000_0061#), -- 'a'
3 => Wide_Wide_Character'Val(16#0000_006C#), -- 'l'
4 => Wide_Wide_Character'Val(16#0000_0073#), -- 's'
5 => Wide_Wide_Character'Val(16#0000_0065#)); -- 'e'
Literal_True_Start: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0074#); -- 't'
Literal_True : constant Wide_Wide_String
:= (1 => Literal_True_Start, -- 't'
2 => Wide_Wide_Character'Val(16#0000_0072#), -- 'r'
3 => Wide_Wide_Character'Val(16#0000_0075#), -- 'u'
4 => Wide_Wide_Character'Val(16#0000_0065#)); -- 'e'
Literal_Null_Start: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_006E#); -- 'n'
Literal_Null : constant Wide_Wide_String
:= (1 => Literal_Null_Start, -- 'n'
2 => Wide_Wide_Character'Val(16#0000_0075#), -- 'u'
3 => Wide_Wide_Character'Val(16#0000_006C#), -- 'l'
4 => Wide_Wide_Character'Val(16#0000_006C#)); -- 'l'
-- Numerics
Decimal_Point: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_002E#); -- '.'
Minus_Sign : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_002D#); -- '-'
Plus_Sign : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_002B#); -- '+'
Exponent_Upper: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0045#); -- 'E'
Exponent_Lower: constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0065#); -- 'e'
Exponent_Set : constant Wide_Wide_Character_Set := To_Set
(Wide_Wide_String'(1 => Exponent_Upper,
2 => Exponent_Lower));
Integer_Terminator: constant Wide_Wide_Character_Set
:= To_Set (Decimal_Point & To_Sequence (Exponent_Set));
-- Values that follow the first set of contigious digits that make-up the
-- (required) "int" portion of a json number value.
Num_Zero : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0030#); -- '0'
Digit_1_9_Range : constant Wide_Wide_Character_Range
:= (Low => Wide_Wide_Character'Val(16#0000_0031#), -- '1'
High => Wide_Wide_Character'Val(16#0000_0039#)); -- '9'
Digit_1_9_Set: constant Wide_Wide_Character_Set := To_Set (Digit_1_9_Range);
Digit_Range: constant Wide_Wide_Character_Range
:= (Low => Num_Zero,
High => Digit_1_9_Range.High);
Digit_Set : constant Wide_Wide_Character_Set := To_Set (Digit_Range);
Numeric_Begin_Set: constant Wide_Wide_Character_Set
:= To_Set (Num_Zero & To_Sequence (Digit_1_9_Set) & Minus_Sign);
-- Valid beginning to Numeric values
Numeric_Continue_Set: constant Wide_Wide_Character_Set
:= To_Set (To_Sequence (Digit_Set) & To_Sequence (Exponent_Set)
& Decimal_Point);
Number_Termination_Set: constant Wide_Wide_Character_Set
:= To_Set (End_Object
& End_Array
& Value_Separator
& To_Sequence (Whitespace));
-- All valid character to indicate the end of a number value
-- Strings
Quotation_Mark : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0022#); -- '"'
Reverse_Solidus : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_005C#); -- '\'
Escape_Symbol : Wide_Wide_Character
renames Reverse_Solidus;
Universal_Code : constant Wide_Wide_Character
:= Wide_Wide_Character'Val(16#0000_0075#); -- 'u'
-- Little problem here with maps - the sets from which the maps are derrived
-- will be re-rodered by their character value, in ascending order! that
-- means "abc" and "CBA" to a map will still translate from "abc" to "ABC",
-- not "CBA". So we can't use maps to translate from escape codes to the
-- actual stand-ins, instead we will use the indexting from a match in
-- Escape_Code_List to the actual stand-in in the Escape_Actual_List
-- Characters that may follow Escape_Symbol in a string
Escape_Code_List : constant Wide_Wide_String
:= (1 => Quotation_Mark, -- '"'
2 => Reverse_Solidus, -- '\'
3 => Wide_Wide_Character'Val(16#0000_002F#), -- '/'
4 => Wide_Wide_Character'Val(16#0000_0062#), -- 'b'
5 => Wide_Wide_Character'Val(16#0000_0066#), -- 'f'
6 => Wide_Wide_Character'Val(16#0000_006E#), -- 'n'
7 => Wide_Wide_Character'Val(16#0000_0072#), -- 'r'
8 => Wide_Wide_Character'Val(16#0000_0074#), -- 't'
9 => Universal_Code); -- 'uXXXX'
Escape_Code_Set : constant Wide_Wide_Character_Set
:= To_Set (Escape_Code_List);
-- Characters that should replace the matching escape sequence
Escape_Actual_List : constant Wide_Wide_String
:= (1 => Quotation_Mark, -- '"'
2 => Reverse_Solidus, -- '\'
3 => Wide_Wide_Character'Val(16#0000_002F#), -- '/'
4 => Wide_Wide_Character'Val(16#0000_0008#), -- %backspace%
5 => Wide_Wide_Character'Val(16#0000_000C#), -- %FF%
6 => Wide_Wide_Character'Val(16#0000_000A#), -- %LF%
7 => Wide_Wide_Character'Val(16#0000_000D#), -- %CR%
8 => Wide_Wide_Character'Val(16#0000_0009#), -- %TAB%
9 => Universal_Code); -- 'uXXXX'
Escape_Actual_Set: constant Wide_Wide_Character_Set
:= To_Set (Escape_Actual_List);
Escape_Serialize_Set: constant Wide_Wide_Character_Set
:= To_Set (Escape_Actual_List (1 .. 8));
-- The list except for universal codes. This is used by the serializer to
-- insert necessary escapes for string values. It doesn't need to re-encode
-- uXXXX values, since it just encodes everything as utf_8. If the uXXXX
-- encodes, for example, \u0008 (backpace), the serializer will just output
-- "\/".
Escape_Code_Map: constant Wide_Wide_Character_Mapping
:= To_Mapping (From => Escape_Code_List, To => Escape_Actual_List);
Escape_Code_Reverse_Map: constant Wide_Wide_Character_Mapping
:= To_Mapping (From => Escape_Actual_List, To => Escape_Code_List);
-- Valid values for \uXXXX hex values
Escape_Hex_Set : constant Wide_Wide_Character_Set :=
To_Set(Wide_Wide_Character_Ranges'((Low => '0',
High => '9'),
(Low => 'a',
High => 'f'),
(Low => 'A',
High => 'F')));
-- These characters MUST be escaped, and connot appear on their own
-- inside of a string.
Escape_Imparative: constant Wide_Wide_Character_Set := To_Set
(Wide_Wide_Character_Ranges'
((Low => Wide_Wide_Character'Val(16#0000_0000#),
High => Wide_Wide_Character'Val(16#0000_001F#)),
(Low => Quotation_Mark,
High => Quotation_Mark),
(Low => Reverse_Solidus,
High => Reverse_Solidus)));
end JSON.Standards;
|
sound/musicasm/MVZ1.asm | NatsumiFox/Sonic-3-93-Nov-03 | 7 | 21291 | <filename>sound/musicasm/MVZ1.asm
MVZ1_Header:
sHeaderInit ; Z80 offset is $A52A
sHeaderPatch MVZ1_Patches
sHeaderCh $06, $03
sHeaderTempo $01, $39
sHeaderDAC MVZ1_DAC
sHeaderFM MVZ1_FM1, $00, $0F
sHeaderFM MVZ1_FM2, $00, $0C
sHeaderFM MVZ1_FM3, $00, $0E
sHeaderFM MVZ1_FM4, $00, $0F
sHeaderFM MVZ1_FM5, $00, $1A
sHeaderPSG MVZ1_PSG1, $E8, $02, $00, v00
sHeaderPSG MVZ1_PSG2, $E8, $02, $00, v00
sHeaderPSG MVZ1_PSG3, $E8, $02, $00, v00
MVZ1_FM1:
sPatFM $00
ssModZ80 $0D, $01, $02, $06
sPan spCenter
dc.b nRst, $60, nRst, nRst, nB5, $04, nBb5, nG5
dc.b nA5, nFs5, nAb5, nF5, nG5, nE5, nFs5, nEb5
dc.b nF5, nD5, nE5, nCs5, nEb5, nC5, nD5, nB4
dc.b nCs5, nBb4, nC5, nA4, nB4
MVZ1_Loop1:
sPatFM $02
dc.b nB4, $01, nC5, $3B, nD5, $06, nRst, nF5
dc.b nRst, nG5, nRst, nE5, $01, nF5, $06, nRst
dc.b $05, nCs5, $06, nRst, nC5, $08, nBb4, $06
dc.b nRst, nG4, $34, nRst, $0C, nBb4, $18, nC5
dc.b $08, nBb4, $03, nC5, $01, nCs5, $06, nRst
dc.b nC5, nRst, nEb5, $08, nD5, $06, nRst, nBb4
dc.b $04, nRst, $60
sLoop $00, $02, MVZ1_Loop1
dc.b nRst, $0C, nBb4, $18, nC5, $08, nBb4, $04
dc.b nCs5, $06, nRst, nC5, nRst, nBb4, $08, nC5
dc.b $06, nRst, nBb4, $04, nRst, $60, nRst, $0C
dc.b nBb4, $18, nC5, $08, nBb4, $03, nCs5, $01
dc.b nD5, nEb5, $06, nRst, $05, nD5, $06, nRst
dc.b nC5, $08, nD5, $06, nRst, nBb4, $04, nRst
dc.b $60, nD5, $01, nEb5, $3B, nF5, $06, nRst
dc.b $05, nF5, $02, nG5, $06, nRst, $05, nEb5
dc.b $06, nRst, nF5, $12, nRst, $06, nCs5, $14
dc.b nBb4, $34, nRst, $0B, nA4, $01, nBb4, $18
dc.b nC5, $08, nBb4, $03, nB4, $01, nC5, nCs5
dc.b $06, nRst, $05, nC5, $06, nRst, nBb4, $08
dc.b nC5, $06, nRst, nBb4, $04, nRst, $60
sJump MVZ1_FM1
dc.b $F2 ; Unused
MVZ1_FM2:
sPatFM $01
ssModZ80 $0D, $01, $02, $06
sPan spCenter
MVZ1_Loop2:
dc.b nG2, $08, nA2, $04, nD3, $08, nF3, $06
dc.b nRst, nE3, nRst, nD3, nRst, nC3, nRst, nC3
dc.b $04, nD3, $08, nD3, $01, nRst, $03, nE3
dc.b $0C, nC3, $08, nBb2, $06, nRst, nBb2, $04
dc.b nBb2, $08, nBb2, $04, nC3, $08, nBb2, $06
dc.b nRst, nBb2, nRst, nBb2, $04, nC3, $0C, nBb2
sLoop $00, $06, MVZ1_Loop2
MVZ1_Loop3:
dc.b nFs2, $08, nFs3, $04, nFs2, $06, nRst, nFs2
dc.b nRst, nFs2, nRst, nAb2, nRst, nAb2, nRst, nAb2
dc.b nRst, nAb2, $08, nAb2, $04, nRst, $08, nBb2
dc.b $10, nBb2, $06, nRst, $12, nBb2, $08, nAb2
dc.b $04, nA2, $08, nBb2, $06, nRst, $16
sLoop $00, $02, MVZ1_Loop3
dc.b nC3, $06, nRst, nC3, nRst, nC3, nRst, nC3
dc.b $08, nC3, $04, nC3, $06, nRst, nC3, nRst
dc.b nC3, nRst, nC3, $08, nC3, $04, nBb2, $06
dc.b nRst, nBb2, nRst, nBb2, nRst, nBb2, $08, nBb2
dc.b $04, nBb2, $06, nRst, nBb2, nRst, nBb2, nRst
dc.b nBb2, $08, nBb2, $04, nFs2, $08, nFs3, $04
dc.b nFs2, $06, nRst, nFs2, nRst, nFs2, nRst, nAb2
dc.b nRst, nAb2, nRst, nAb2, nRst, nAb2, $08, nAb2
dc.b $04, nRst, $08, nBb2, $10, nBb2, $06, nRst
dc.b $12, nBb2, $08, nAb2, $04, nA2, $08, nBb2
dc.b $06, nRst, $16
sJump MVZ1_FM2
dc.b $F2 ; Unused
MVZ1_FM3:
sPatFM $03
ssModZ80 $0D, $01, $02, $06
sPan spLeft
MVZ1_Loop4:
dc.b nRst, $0C, nG4, $08, nG4, $04, nG4, $08
dc.b nG4, $06, nRst, $0A, nG4, $08, nG4, $04
dc.b nG4, $08, nG4, $06, nRst, $0A, nG4, $08
dc.b nG4, $04, nRst, $60
sLoop $00, $02, MVZ1_Loop4
MVZ1_Loop5:
dc.b nRst, $0C, nE4, $08, nE4, $04, nE4, $08
dc.b nE4, $06, nRst, $0A, nE4, $08, nE4, $04
dc.b nE4, $08, nE4, $06, nRst, $0A, nE4, $08
dc.b nE4, $04, nRst, $60, nRst, $0C, nFs4, $08
dc.b nFs4, $04, nFs4, $08, nFs4, $06, nRst, $0A
dc.b nF4, $08, nF4, $04, nF4, $08, nF4, $06
dc.b nRst, $0A, nF4, $08, nF4, $04, nRst, $60
sLoop $00, $02, MVZ1_Loop5
dc.b nRst, $08, nFs5, $10, nFs5, $06, nRst, nFs5
dc.b nRst, nAb5, $08, nG5, $04, nAb5, $08, nC6
dc.b $06, nRst, $16, nRst, $08, nF4, $10, nF4
dc.b $06, nRst, $12, nF4, $08, nEb4, $04, nE4
dc.b $08, nF4, $06, nRst, nBb4, $0C, nC5, $04
dc.b nRst, $08, nFs5, $10, nFs5, $06, nRst, nFs5
dc.b nRst, nAb5, $08, nG5, $04, nAb5, $08, nC6
dc.b $06, nRst, $16, nRst, $08, nF4, $10, nF4
dc.b $06, nRst, $12, nF4, $08, nEb4, $04, nE4
dc.b $08, nF4, $04, nE4, $08, nEb4, $04, nD4
dc.b $08, nCs4, $04, nC4, $30, nC4, $06, nRst
dc.b nEb4, nRst, nF4, $08, nG4, $06, nRst, nEb4
dc.b $04, nRst, $08, nF4, $10, nF4, $06, nRst
dc.b nF4, nRst, nF4, $08, nCs4, $06, nRst, nEb4
dc.b nRst, nF4, $10, nRst, $0C, nFs4, $18, nAb4
dc.b $08, nFs4, $04, nBb4, $06, nRst, nAb4, nRst
dc.b nFs4, $08, nAb4, $06, nRst, nF4, $04, nRst
dc.b $60
sJump MVZ1_FM3
dc.b $F2 ; Unused
MVZ1_FM4:
sPatFM $03
ssModZ80 $0D, $01, $02, $06
sPan spRight
MVZ1_Loop6:
dc.b nRst, $0C, nE4, $08, nE4, $04, nE4, $08
dc.b nE4, $06, nRst, $0A, nE4, $08, nE4, $04
dc.b nE4, $08, nE4, $06, nRst, $0A, nE4, $08
dc.b nE4, $04, nRst, $60
sLoop $00, $02, MVZ1_Loop6
MVZ1_Loop7:
dc.b nRst, $0C, nC4, $08, nC4, $04, nC4, $08
dc.b nC4, $06, nRst, $0A, nC4, $08, nC4, $04
dc.b nC4, $08, nC4, $06, nRst, $0A, nC4, $08
dc.b nC4, $04, nRst, $60, nRst, $0C, nCs4, $08
dc.b nCs4, $04, nCs4, $08, nCs4, $06, nRst, $0A
dc.b nD4, $08, nD4, $04, nD4, $08, nD4, $06
dc.b nRst, $0A, nD4, $08, nD4, $04, nRst, $60
sLoop $00, $02, MVZ1_Loop7
dc.b nRst, $08, nFs4, $10, nFs4, $06, nRst, nFs4
dc.b nRst, nAb4, $08, nG4, $04, nAb4, $08, nC5
dc.b $06, nRst, $16, nRst, $08, nD4, $10, nD4
dc.b $06, nRst, $12, nD4, $08, nC4, $04, nCs4
dc.b $08, nD4, $06, nRst, nFs4, $0C, nAb4, $04
dc.b nRst, $08, nFs4, $10, nFs4, $06, nRst, nFs4
dc.b nRst, nAb4, $08, nG4, $04, nAb4, $08, nC5
dc.b $03, nRst, $19, nRst, $08, nD4, $10, nD4
dc.b $06, nRst, $12, nD4, $08, nC4, $04, nCs4
dc.b $08, nD4, $04, nCs4, $08, nC4, $04, nB3
dc.b $08, nBb3, $04, nG3, $30, nG3, $06, nRst
dc.b nC4, nRst, nD4, $08, nEb4, $06, nRst, nC4
dc.b $04, nRst, $08, nD4, $10, nD4, $06, nRst
dc.b nD4, nRst, nD4, $08, nBb3, $06, nRst, nC4
dc.b nRst, nD4, $10, nRst, $0C, nEb4, $18, nEb4
dc.b $08, nEb4, $04, nF4, $06, nRst, nEb4, nRst
dc.b nD4, $08, nEb4, $06, nRst, nD4, $04, nRst
dc.b $60
sJump MVZ1_FM4
dc.b $F2 ; Unused
MVZ1_FM5:
dc.b nRst, $07
MVZ1_Jump1:
sPatFM $00
ssModZ80 $0D, $01, $02, $06
sPan spCenter
dc.b nRst, $60, nRst, nRst, nB5, $04, nBb5, nG5
dc.b nA5, nFs5, nAb5, nF5, nG5, nE5, nFs5, nEb5
dc.b nF5, nD5, nE5, nCs5, nEb5, nC5, nD5, nB4
dc.b nCs5, nBb4, nC5, nA4, nB4
MVZ1_Loop8:
sPatFM $02
dc.b nB4, $01, nC5, $3B, nD5, $06, nRst, nF5
dc.b nRst, nG5, nRst, nE5, $01, nF5, $06, nRst
dc.b $05, nCs5, $06, nRst, nC5, $08, nBb4, $06
dc.b nRst, nG4, $34, nRst, $0C, nBb4, $18, nC5
dc.b $08, nBb4, $03, nC5, $01, nCs5, $06, nRst
dc.b nC5, nRst, nEb5, $08, nD5, $06, nRst, nBb4
dc.b $04, nRst, $60
sLoop $00, $02, MVZ1_Loop8
dc.b nRst, $0C, nBb4, $18, nC5, $08, nBb4, $04
dc.b nCs5, $06, nRst, nC5, nRst, nBb4, $08, nC5
dc.b $06, nRst, nBb4, $04, nRst, $60, nRst, $0C
dc.b nBb4, $18, nC5, $08, nBb4, $03, nCs5, $01
dc.b nD5, nEb5, $06, nRst, $05, nD5, $06, nRst
dc.b nC5, $08, nD5, $06, nRst, nBb4, $04, nRst
dc.b $60, nD5, $01, nEb5, $3B, nF5, $06, nRst
dc.b $05, nF5, $02, nG5, $06, nRst, $05, nEb5
dc.b $06, nRst, nF5, $12, nRst, $06, nCs5, $14
dc.b nBb4, $34, nRst, $0B, nA4, $01, nBb4, $18
dc.b nC5, $08, nBb4, $03, nB4, $01, nC5, nCs5
dc.b $06, nRst, $05, nC5, $06, nRst, nBb4, $08
dc.b nC5, $06, nRst, nBb4, $04, nRst, $60
sJump MVZ1_Jump1
dc.b $F2 ; Unused
MVZ1_DAC:
dc.b nRst, $60, dSnare, $08, dKick, $0C, dKick, $10
dc.b dSnare, $08, dKick, $0C, dKick, dKick, $04, dSnare
dc.b $0C, dKick, nRst, $60, dSnare, $08, dKick, $0C
dc.b dKick, $10, dSnare, $08, dKick, $04, dSnare, $0C
dc.b dSnare, dSnare, $08, dSnare, $04, dSnare, $0C
MVZ1_Loop9:
dc.b dKick, $08, dMidTom, $04, dMidTom, $0C, dSnare, dMidTom
dc.b dLowTom, $14, dLowTom, $04, dSnare, $18
sLoop $00, $08, MVZ1_Loop9
MVZ1_Loop10:
dc.b dKick, $18, dSnare, dLowTom, $08, dLowTom, $0C, dLowTom
dc.b $04, dSnare, $18, nRst, $08, dKick, $10, dSnare
dc.b $18, dLowTom, $08, dLowTom, $04, dLowTom, $08, dSnare
dc.b $10, dKick, $0C
sLoop $00, $02, MVZ1_Loop10
dc.b dKick, $08, dMidTom, $0C, dMidTom, $04, dSnare, $18
dc.b dLowTom, $0C, dLowTom, dSnare, dLowTom, $08, dLowTom, $04
dc.b dKick, $08, dMidTom, $0C, dMidTom, $04, dSnare, $18
dc.b dLowTom, $0C, dLowTom, dSnare, dLowTom, $08, dLowTom, $04
dc.b dKick, $18, dSnare, dLowTom, $08, dLowTom, $0C, dLowTom
dc.b $04, dSnare, $18, nRst, $08, dKick, $10, dSnare
dc.b $18, dLowTom, $08, dLowTom, $04, dLowTom, $08, dSnare
dc.b $10, dKick, $0C
sJump MVZ1_DAC
dc.b $F2 ; Unused
MVZ1_PSG1:
sStop
MVZ1_PSG2:
sStop
dc.b $F2 ; Unused
MVZ1_PSG3:
sStop
MVZ1_Patches:
; Patch $00
; $38
; $4C, $33, $74, $41, $1F, $1F, $1F, $1F
; $11, $0F, $0D, $0D, $00, $0F, $00, $00
; $FF, $FF, $FF, $FF, $21, $16, $26, $81
spAlgorithm $00
spFeedback $07
spDetune $04, $07, $03, $04
spMultiple $0C, $04, $03, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $11, $0D, $0F, $0D
spSustainLv $0F, $0F, $0F, $0F
spDecayRt $00, $00, $0F, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $21, $26, $16, $01
; Patch $01
; $3B
; $47, $40, $41, $40, $1F, $1F, $1F, $1F
; $06, $0F, $0F, $07, $00, $00, $00, $00
; $EF, $EF, $EF, $EF, $2C, $13, $1F, $81
spAlgorithm $03
spFeedback $07
spDetune $04, $04, $04, $04
spMultiple $07, $01, $00, $00
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $06, $0F, $0F, $07
spSustainLv $0E, $0E, $0E, $0E
spDecayRt $00, $00, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $2C, $1F, $13, $01
; Patch $02
; $3B
; $71, $12, $13, $71, $11, $10, $14, $1A
; $0C, $09, $0A, $02, $00, $06, $04, $07
; $1F, $EF, $FF, $EF, $1B, $24, $24, $81
spAlgorithm $03
spFeedback $07
spDetune $07, $01, $01, $07
spMultiple $01, $03, $02, $01
spRateScale $00, $00, $00, $00
spAttackRt $11, $14, $10, $1A
spAmpMod $00, $00, $00, $00
spSustainRt $0C, $0A, $09, $02
spSustainLv $01, $0F, $0E, $0E
spDecayRt $00, $04, $06, $07
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $1B, $24, $24, $01
; Patch $03
; $34
; $61, $03, $00, $61, $1F, $1E, $51, $D0
; $0C, $08, $01, $01, $08, $00, $09, $00
; $8F, $FF, $FF, $FF, $11, $85, $19, $86
spAlgorithm $04
spFeedback $06
spDetune $06, $00, $00, $06
spMultiple $01, $00, $03, $01
spRateScale $00, $01, $00, $03
spAttackRt $1F, $11, $1E, $10
spAmpMod $00, $00, $00, $00
spSustainRt $0C, $01, $08, $01
spSustainLv $08, $0F, $0F, $0F
spDecayRt $08, $09, $00, $00
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $11, $19, $05, $06
|
01 Mixing Desk Programming/Choose Desk to program.applescript | streth11/Qlab-Scripts | 0 | 2030 | -- @description Choose desk to program
-- @author <NAME>
-- @link bensmithsound.uk
-- @version 1.0
-- @testedmacos 10.13.6
-- @testedqlab 4.6.9
-- @about Changes which script cues the OSC "make midi desk recall" cues fire, changing the mixing desk the cues create recalls for. Current options are Allen & Heath mixing desks (GLD, SQ) and Yamaha mixing desks (CL/QL).
-- @separateprocess TRUE
-- @changelog
-- v1.0 + init
-- RUN SCRIPT -----------------------------
tell application id "com.figure53.Qlab.4" to tell front workspace
set deskOptions to {"Allen & Heath GLD/SQ", "Yamaha CL/QL"}
set deskToProgram to choose from list deskOptions with title "Choose mixing desk to program"
end tell
setDesk(deskToProgram)
-- FUNCTIONS ------------------------------
on setDesk(desk)
tell application id "com.figure53.Qlab.4" to tell front workspace
if desk is {"Allen & Heath GLD/SQ"} then
set q_num of cue "Recall" to "ahRecall"
set q_num of cue "Name" to "ahRecallName"
set armed of cue "o/s" to false
end if
if desk is {"Yamaha CL/QL"} then
set q_num of cue "Recall" to "yRecall"
set q_num of cue "Name" to "yRecallName"
set armed of cue "o/s" to true
end if
end tell
end setDesk |
source/jni/u2/twist/koe.asm | Falken42/SecondReality | 9 | 81318 | .MODEL Large
.CODE
mov es:[di+1234h],ax
END |
lab01/src/lab1.adb | evgenijaZ/PP-labs | 0 | 7618 | with Ada.Text_IO;
use Ada.Text_IO;
with Data;
use Data;
with Ada.Integer_Text_IO;
with Ada.Integer_Text_IO;
with System.Multiprocessors;
use System.Multiprocessors;
procedure lab1 is
cpu1 : CPU_Range := 1;
cpu2 : CPU_Range := 1;
cpu3 : CPU_Range := 1;
N : Integer := 50;
task T1 is
pragma Priority(3);
pragma Storage_Size(900_000_000);
pragma CPU(cpu1);
end T1;
task T2 is
pragma Priority(2);
pragma Storage_Size(900_000_000);
pragma CPU(cpu2);
end T2;
task T3 is
pragma Priority(1);
pragma Storage_Size(900_000_000);
pragma CPU(cpu3);
end T3;
task body T1 is
A,D,E : Matrix;
B : Vector;
begin
Put_Line ("Task 1:");
-- Put_Line("Enter N1:");
-- Ada.Integer_Text_IO.Get(N);
Matrix_Generate(A,N);
-- Put_Line ("Matrix A:");
-- Matrix_Output(A,N);
Matrix_Generate(D,N);
-- Put_Line ("Matrix D:");
-- Matrix_Output(D,N);
Vector_Generate(B,N);
-- Put_Line ("Vector B:");
-- Vector_Output(B,N);
E := F1(A,D,B,N);
Matrix_Output(E,N,"Matrix E:");
Put_Line("End task 1");
end T1;
task body T2 is
G,K,L,F : Matrix;
a : Integer;
begin
Put_Line ("Task 2:");
-- Put_Line("Enter N2:");
-- Ada.Integer_Text_IO.Get(N);
Matrix_Generate(G,N);
-- Put_Line ("Matrix G:");
-- Matrix_Output(G,N);
Matrix_Generate(K,N);
-- Put_Line ("Matrix K:");
-- Matrix_Output(K,N);
Matrix_Generate(L,N);
-- Put_Line ("Matrix L:");
-- Matrix_Output(L,N);
Value_Generate(a);
-- Put_Line("Variable a:");
-- Ada.Integer_Text_IO.Put(a);
-- New_Line;
F := F2(a,G,K,L,N);
Matrix_Output(F,N,"Matrix F:");
Put_Line("End task 2");
end T2;
task body T3 is
P,R : Matrix;
S,T,O : Vector;
begin
Put_Line ("Task 3:");
-- Put_Line("Enter N3:");
-- Ada.Integer_Text_IO.Get(N);
Matrix_Generate(P,N);
-- Put_Line ("Matrix P:");
-- Matrix_Output(P,N);
Matrix_Generate(R,N);
-- Put_Line ("Matrix R:");
-- Matrix_Output(R,N);
Vector_Generate(S,N);
-- Put_Line ("Vector S:");
-- Vector_Output(S,N);
Vector_Generate(T,N);
-- Put_Line ("Vector T:");
-- Vector_Output(T,N);
O:=F3(P,R,S,T,N);
Vector_Output(O,N,"Vector O:");
Put_Line("End task 3");
end T3;
begin
Put_Line("Lab1");
end lab1;
|
tools/scitools/conf/understand/ada/ada05/a-direct.ads | brucegua/moocos | 1 | 9126 | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . D I R E C T O R I E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2005, Free Software Foundation, Inc. --
-- --
-- This specification is derived for use with GNAT from AI-00248, which is --
-- expected to be a part of a future expected revised Ada Reference Manual. --
-- The copyright notice above, and the license provisions that follow apply --
-- solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Ada 2005: Implementation of Ada.Directories (AI95-00248). Note that this
-- unit is available without -gnat05. That seems reasonable, since you only
-- get it if you explicitly ask for it.
-- External files may be classified as directories, special files, or ordinary
-- files. A directory is an external file that is a container for files on
-- the target system. A special file is an external file that cannot be
-- created or read by a predefined Ada Input-Output package. External files
-- that are not special files or directories are called ordinary files.
-- A file name is a string identifying an external file. Similarly, a
-- directory name is a string identifying a directory. The interpretation of
-- file names and directory names is implementation-defined.
-- The full name of an external file is a full specification of the name of
-- the file. If the external environment allows alternative specifications of
-- the name (for example, abbreviations), the full name should not use such
-- alternatives. A full name typically will include the names of all of
-- directories that contain the item. The simple name of an external file is
-- the name of the item, not including any containing directory names. Unless
-- otherwise specified, a file name or directory name parameter to a
-- predefined Ada input-output subprogram can be a full name, a simple name,
-- or any other form of name supported by the implementation.
-- The default directory is the directory that is used if a directory or
-- file name is not a full name (that is, when the name does not fully
-- identify all of the containing directories).
-- A directory entry is a single item in a directory, identifying a single
-- external file (including directories and special files).
-- For each function that returns a string, the lower bound of the returned
-- value is 1.
with Ada.Calendar;
with Ada.Finalization;
with Ada.IO_Exceptions;
with Ada.Strings.Unbounded;
package Ada.Directories is
pragma Ada_05;
-- To be removed later ???
-----------------------------------
-- Directory and File Operations --
-----------------------------------
function Current_Directory return String;
-- Returns the full directory name for the current default directory. The
-- name returned shall be suitable for a future call to Set_Directory.
-- The exception Use_Error is propagated if a default directory is not
-- supported by the external environment.
procedure Set_Directory (Directory : String);
-- Sets the current default directory. The exception Name_Error is
-- propagated if the string given as Directory does not identify an
-- existing directory. The exception Use_Error is propagated if the
-- external environment does not support making Directory (in the absence
-- of Name_Error) a default directory.
procedure Create_Directory
(New_Directory : String;
Form : String := "");
-- Creates a directory with name New_Directory. The Form parameter can be
-- used to give system-dependent characteristics of the directory; the
-- interpretation of the Form parameter is implementation-defined. A null
-- string for Form specifies the use of the default options of the
-- implementation of the new directory. The exception Name_Error is
-- propagated if the string given as New_Directory does not allow the
-- identification of a directory. The exception Use_Error is propagated if
-- the external environment does not support the creation of a directory
-- with the given name (in the absence of Name_Error) and form.
procedure Delete_Directory (Directory : String);
-- Deletes an existing empty directory with name Directory. The exception
-- Name_Error is propagated if the string given as Directory does not
-- identify an existing directory. The exception Use_Error is propagated
-- if the external environment does not support the deletion of the
-- directory (or some portion of its contents) with the given name (in the
-- absence of Name_Error).
procedure Create_Path
(New_Directory : String;
Form : String := "");
-- Creates zero or more directories with name New_Directory. Each
-- non-existent directory named by New_Directory is created. For example,
-- on a typical Unix system, Create_Path ("/usr/me/my"); would create
-- directory "me" in directory "usr", then create directory "my" in
-- directory "me". The Form can be used to give system-dependent
-- characteristics of the directory; the interpretation of the Form
-- parameter is implementation-defined. A null string for Form specifies
-- the use of the default options of the implementation of the new
-- directory. The exception Name_Error is propagated if the string given
-- as New_Directory does not allow the identification of any directory.
-- The exception Use_Error is propagated if the external environment does
-- not support the creation of any directories with the given name (in the
-- absence of Name_Error) and form.
procedure Delete_Tree (Directory : String);
-- Deletes an existing directory with name Directory. The directory and
-- all of its contents (possibly including other directories) are deleted.
-- The exception Name_Error is propagated if the string given as Directory
-- does not identify an existing directory. The exception Use_Error is
-- propagated if the external environment does not support the deletion of
-- the directory or some portion of its contents with the given name (in
-- the absence of Name_Error). If Use_Error is propagated, it is
-- unspecified if a portion of the contents of the directory are deleted.
procedure Delete_File (Name : String);
-- Deletes an existing ordinary or special file with Name. The exception
-- Name_Error is propagated if the string given as Name does not identify
-- an existing ordinary or special external file. The exception Use_Error
-- is propagated if the external environment does not support the deletion
-- of the file with the given name (in the absence of Name_Error).
procedure Rename (Old_Name, New_Name : String);
-- Renames an existing external file (including directories) with Old_Name
-- to New_Name. The exception Name_Error is propagated if the string given
-- as Old_Name does not identify an existing external file. The exception
-- Use_Error is propagated if the external environment does not support the
-- renaming of the file with the given name (in the absence of Name_Error).
-- In particular, Use_Error is propagated if a file or directory already
-- exists with New_Name.
procedure Copy_File
(Source_Name : String;
Target_Name : String;
Form : String := "");
-- Copies the contents of the existing external file with Source_Name
-- to Target_Name. The resulting external file is a duplicate of the source
-- external file. The Form can be used to give system-dependent
-- characteristics of the resulting external file; the interpretation of
-- the Form parameter is implementation-defined. Exception Name_Error is
-- propagated if the string given as Source_Name does not identify an
-- existing external ordinary or special file or if the string given as
-- Target_Name does not allow the identification of an external file.
-- The exception Use_Error is propagated if the external environment does
-- not support the creating of the file with the name given by Target_Name
-- and form given by Form, or copying of the file with the name given by
-- Source_Name (in the absence of Name_Error).
----------------------------------------
-- File and directory name operations --
----------------------------------------
function Full_Name (Name : String) return String;
-- Returns the full name corresponding to the file name specified by Name.
-- The exception Name_Error is propagated if the string given as Name does
-- not allow the identification of an external file (including directories
-- and special files).
function Simple_Name (Name : String) return String;
-- Returns the simple name portion of the file name specified by Name. The
-- exception Name_Error is propagated if the string given as Name does not
-- allow the identification of an external file (including directories and
-- special files).
function Containing_Directory (Name : String) return String;
-- Returns the name of the containing directory of the external file
-- (including directories) identified by Name. If more than one directory
-- can contain Name, the directory name returned is implementation-defined.
-- The exception Name_Error is propagated if the string given as Name does
-- not allow the identification of an external file. The exception
-- Use_Error is propagated if the external file does not have a containing
-- directory.
function Extension (Name : String) return String;
-- Returns the extension name corresponding to Name. The extension name is
-- a portion of a simple name (not including any separator characters),
-- typically used to identify the file class. If the external environment
-- does not have extension names, then the null string is returned.
-- The exception Name_Error is propagated if the string given as Name does
-- not allow the identification of an external file.
function Base_Name (Name : String) return String;
-- Returns the base name corresponding to Name. The base name is the
-- remainder of a simple name after removing any extension and extension
-- separators. The exception Name_Error is propagated if the string given
-- as Name does not allow the identification of an external file
-- (including directories and special files).
function Compose
(Containing_Directory : String := "";
Name : String;
Extension : String := "") return String;
-- Returns the name of the external file with the specified
-- Containing_Directory, Name, and Extension. If Extension is the null
-- string, then Name is interpreted as a simple name; otherwise Name is
-- interpreted as a base name. The exception Name_Error is propagated if
-- the string given as Containing_Directory is not null and does not allow
-- the identification of a directory, or if the string given as Extension
-- is not null and is not a possible extension, or if the string given as
-- Name is not a possible simple name (if Extension is null) or base name
-- (if Extension is non-null).
--------------------------------
-- File and directory queries --
--------------------------------
type File_Kind is (Directory, Ordinary_File, Special_File);
-- The type File_Kind represents the kind of file represented by an
-- external file or directory.
type File_Size is range 0 .. Long_Long_Integer'Last;
-- The type File_Size represents the size of an external file
function Exists (Name : String) return Boolean;
-- Returns True if external file represented by Name exists, and False
-- otherwise. The exception Name_Error is propagated if the string given as
-- Name does not allow the identification of an external file (including
-- directories and special files).
function Kind (Name : String) return File_Kind;
-- Returns the kind of external file represented by Name. The exception
-- Name_Error is propagated if the string given as Name does not allow the
-- identification of an existing external file.
function Size (Name : String) return File_Size;
-- Returns the size of the external file represented by Name. The size of
-- an external file is the number of stream elements contained in the file.
-- If the external file is discontiguous (not all elements exist), the
-- result is implementation-defined. If the external file is not an
-- ordinary file, the result is implementation-defined. The exception
-- Name_Error is propagated if the string given as Name does not allow the
-- identification of an existing external file. The exception
-- Constraint_Error is propagated if the file size is not a value of type
-- File_Size.
function Modification_Time (Name : String) return Ada.Calendar.Time;
-- Returns the time that the external file represented by Name was most
-- recently modified. If the external file is not an ordinary file, the
-- result is implementation-defined. The exception Name_Error is propagated
-- if the string given as Name does not allow the identification of an
-- existing external file. The exception Use_Error is propagated if the
-- external environment does not support the reading the modification time
-- of the file with the name given by Name (in the absence of Name_Error).
-------------------------
-- Directory Searching --
-------------------------
type Directory_Entry_Type is limited private;
-- The type Directory_Entry_Type represents a single item in a directory.
-- These items can only be created by the Get_Next_Entry procedure in this
-- package. Information about the item can be obtained from the functions
-- declared in this package. A default initialized object of this type is
-- invalid; objects returned from Get_Next_Entry are valid.
type Filter_Type is array (File_Kind) of Boolean;
-- The type Filter_Type specifies which directory entries are provided from
-- a search operation. If the Directory component is True, directory
-- entries representing directories are provided. If the Ordinary_File
-- component is True, directory entries representing ordinary files are
-- provided. If the Special_File component is True, directory entries
-- representing special files are provided.
type Search_Type is limited private;
-- The type Search_Type contains the state of a directory search. A
-- default-initialized Search_Type object has no entries available
-- (More_Entries returns False).
procedure Start_Search
(Search : in out Search_Type;
Directory : String;
Pattern : String;
Filter : Filter_Type := (others => True));
-- Starts a search in the directory entry in the directory named by
-- Directory for entries matching Pattern. Pattern represents a file name
-- matching pattern. If Pattern is null, all items in the directory are
-- matched; otherwise, the interpretation of Pattern is implementation-
-- defined. Only items which match Filter will be returned. After a
-- successful call on Start_Search, the object Search may have entries
-- available, but it may have no entries available if no files or
-- directories match Pattern and Filter. The exception Name_Error is
-- propagated if the string given by Directory does not identify an
-- existing directory, or if Pattern does not allow the identification of
-- any possible external file or directory. The exception Use_Error is
-- propagated if the external environment does not support the searching
-- of the directory with the given name (in the absence of Name_Error).
procedure End_Search (Search : in out Search_Type);
-- Ends the search represented by Search. After a successful call on
-- End_Search, the object Search will have no entries available. Note
-- that is is not necessary to call End_Search if the call to Start_Search
-- was unsuccessful and raised an exception (but it is harmless to make
-- the call in this case)>
function More_Entries (Search : Search_Type) return Boolean;
-- Returns True if more entries are available to be returned by a call
-- to Get_Next_Entry for the specified search object, and False otherwise.
procedure Get_Next_Entry
(Search : in out Search_Type;
Directory_Entry : out Directory_Entry_Type);
-- Returns the next Directory_Entry for the search described by Search that
-- matches the pattern and filter. If no further matches are available,
-- Status_Error is raised. It is implementation-defined as to whether the
-- results returned by this routine are altered if the contents of the
-- directory are altered while the Search object is valid (for example, by
-- another program). The exception Use_Error is propagated if the external
-- environment does not support continued searching of the directory
-- represented by Search.
-------------------------------------
-- Operations on Directory Entries --
-------------------------------------
function Simple_Name (Directory_Entry : Directory_Entry_Type) return String;
-- Returns the simple external name of the external file (including
-- directories) represented by Directory_Entry. The format of the name
-- returned is implementation-defined. The exception Status_Error is
-- propagated if Directory_Entry is invalid.
function Full_Name (Directory_Entry : Directory_Entry_Type) return String;
-- Returns the full external name of the external file (including
-- directories) represented by Directory_Entry. The format of the name
-- returned is implementation-defined. The exception Status_Error is
-- propagated if Directory_Entry is invalid.
function Kind (Directory_Entry : Directory_Entry_Type) return File_Kind;
-- Returns the kind of external file represented by Directory_Entry. The
-- exception Status_Error is propagated if Directory_Entry is invalid.
function Size (Directory_Entry : Directory_Entry_Type) return File_Size;
-- Returns the size of the external file represented by Directory_Entry.
-- The size of an external file is the number of stream elements contained
-- in the file. If the external file is discontiguous (not all elements
-- exist), the result is implementation-defined. If the external file
-- represented by Directory_Entry is not an ordinary file, the result is
-- implementation-defined. The exception Status_Error is propagated if
-- Directory_Entry is invalid. The exception Constraint_Error is propagated
-- if the file size is not a value of type File_Size.
function Modification_Time
(Directory_Entry : Directory_Entry_Type) return Ada.Calendar.Time;
-- Returns the time that the external file represented by Directory_Entry
-- was most recently modified. If the external file represented by
-- Directory_Entry is not an ordinary file, the result is
-- implementation-defined. The exception Status_Error is propagated if
-- Directory_Entry is invalid. The exception Use_Error is propagated if
-- the external environment does not support the reading the modification
-- time of the file represented by Directory_Entry.
----------------
-- Exceptions --
----------------
Status_Error : exception renames Ada.IO_Exceptions.Status_Error;
Name_Error : exception renames Ada.IO_Exceptions.Name_Error;
Use_Error : exception renames Ada.IO_Exceptions.Use_Error;
Device_Error : exception renames Ada.IO_Exceptions.Device_Error;
private
type Directory_Entry_Type is record
Is_Valid : Boolean := False;
Simple : Ada.Strings.Unbounded.Unbounded_String;
Full : Ada.Strings.Unbounded.Unbounded_String;
Kind : File_Kind := Ordinary_File;
end record;
-- The type Search_Data is defined in the body, so that the spec does not
-- depend on packages of the GNAT hierarchy.
type Search_Data;
type Search_Ptr is access Search_Data;
-- Search_Type need to be a controlled type, because it includes component
-- of type Dir_Type (in GNAT.Directory_Operations) that need to be closed
-- (if opened) during finalization. The component need to be an access
-- value, because Search_Data is not fully defined in the spec.
type Search_Type is new Ada.Finalization.Controlled with record
Value : Search_Ptr;
end record;
procedure Finalize (Search : in out Search_Type);
-- Close the directory, if opened, and deallocate Value
procedure End_Search (Search : in out Search_Type) renames Finalize;
end Ada.Directories;
|
win/macosx/NetHackGuidebook.applescript | aoeixsz4/nh-setseed | 2,107 | 3758 | #!/usr/bin/osascript
# NetHack 3.7 NetHackGuidebook.applescript $NHDT-Date: 1596498328 2020/08/03 23:45:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.13 $
# Copyright (c) <NAME>, Kensington, Maryland, 2011
# NetHack may be freely redistributed. See license for details.
# Display the Guidebook from the GUI.
tell application "Finder"
open location "file:///Library/Nethack/doc/NetHackGuidebook.pdf"
delay 5
end tell
|
Raw.g4 | sirkon/mdl | 10 | 211 | grammar Raw;
set
: (line eoc)* (line EOF)?
|
;
eoc
: NEWLINE*;
line
: (IDENTIFIER '=' value)
;
value
: STRING_LITERAL
| NUMBER
| boolean
| INLINE_STRING
| IDENTIFIER
;
boolean
: 'true'
| 'false';
IDENTIFIER
: [a-zA-Z_] [a-zA-Z0-9_]*
;
STRING_LITERAL
: '"' (~["\\\r\n] | EscapeSequence)* '"'
;
NUMBER
: '-'? INT ('.' [0-9] +)? EXP?
;
INT
: '0' | [1-9] [0-9]*
;
// no leading zeros
fragment EXP
: [Ee] [+\-]? INT
;
fragment EscapeSequence
: '\\' [btnfr"'\\]
;
INLINE_STRING
: ~(' ' | '\r' | '\t' | '\n' | '=')+
;
NEWLINE: '\n';
WS
:
[ \t\r] -> skip ;
|
bb-runtimes/src/a-intnam__p55.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 4365 | <reponame>JCGobbi/Nucleo-STM32G474RE<filename>bb-runtimes/src/a-intnam__p55.ads
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . I N T E R R U P T S . N A M E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2012-2017, 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the version for p5566 target of this package
pragma Restrictions (No_Elaboration_Code);
package Ada.Interrupts.Names is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
-- Names come from the Source column of Table 10-9 of MPC5566RM
INTC_SSCIR0 : constant Interrupt_ID := 0;
INTC_SSCIR1 : constant Interrupt_ID := 1;
INTC_SSCIR2 : constant Interrupt_ID := 2;
INTC_SSCIR3 : constant Interrupt_ID := 3;
INTC_SSCIR4 : constant Interrupt_ID := 4;
INTC_SSCIR5 : constant Interrupt_ID := 5;
INTC_SSCIR6 : constant Interrupt_ID := 6;
INTC_SSCIR7 : constant Interrupt_ID := 7;
end Ada.Interrupts.Names;
|
awa/src/awa-users-services.adb | Letractively/ada-awa | 0 | 22145 | -----------------------------------------------------------------------
-- awa.users -- User registration, authentication processes
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings;
with Ada.Calendar;
with Util.Log.Loggers;
with Util.Strings;
with Util.Encoders.HMAC.SHA1;
with Ada.Numerics.Discrete_Random;
with ADO.SQL;
with ADO.Statements;
with ADO.Objects;
with AWA.Services;
with AWA.Services.Contexts;
package body AWA.Users.Services is
use Util.Log;
use ADO.Statements;
use ADO.Sessions;
use Ada.Strings.Unbounded;
use ADO.SQL;
use AWA.Services;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Users.Services");
function Random return Integer;
function Create_Key (Number : ADO.Identifier) return String;
package Integer_Random is new Ada.Numerics.Discrete_Random (Integer);
Random_Generator : Integer_Random.Generator;
function Random return Integer is
begin
return Integer_Random.Random (Random_Generator);
end Random;
procedure Send_Alert (Model : in User_Service;
Kind : in AWA.Events.Event_Index;
User : in User_Ref'Class;
Props : in out AWA.Events.Module_Event) is
begin
Props.Set_Event_Kind (Kind);
Props.Set_Parameter ("first_name", User.Get_First_Name);
Props.Set_Parameter ("last_name", User.Get_Last_Name);
Props.Set_Parameter ("name", User.Get_Name);
Model.Send_Event (Props);
end Send_Alert;
function Create_Key (Number : ADO.Identifier) return String is
Rand : constant String := Integer'Image (Random);
begin
Log.Info ("Random {0}", Rand);
return Util.Encoders.HMAC.SHA1.Sign_Base64 (Key => ADO.Identifier'Image (Number),
Data => Rand,
URL => True);
end Create_Key;
-- ------------------------------
-- Build the authenticate cookie. The cookie is signed using HMAC-SHA1 with a private key.
-- ------------------------------
function Get_Authenticate_Cookie (Model : in User_Service;
Id : in ADO.Identifier)
return String is
Ident : constant String := Util.Strings.Image (Integer (Id));
Key : constant String := To_String (Model.Auth_Key);
begin
return Ident & '.' & Util.Encoders.HMAC.SHA1.Sign_Base64 (Key => Key, Data => Ident);
end Get_Authenticate_Cookie;
-- ------------------------------
-- Get the password hash. The password is signed using HMAC-SHA1 with the email address.
-- ------------------------------
function Get_Password_Hash (Model : in User_Service;
Password : in String;
Email : in String)
return String is
pragma Unreferenced (Model);
begin
return Util.Encoders.HMAC.SHA1.Sign_Base64 (Key => Email, Data => Password);
end Get_Password_Hash;
-- ------------------------------
-- Get the authenticate identifier from the cookie.
-- Verify that the cookie is valid, the signature is correct.
-- Returns the identified or NO_IDENTIFIER
-- ------------------------------
function Get_Authenticate_Id (Model : in User_Service;
Cookie : in String) return ADO.Identifier is
Pos : constant Natural := Util.Strings.Index (Cookie, '.');
Id : ADO.Identifier;
begin
if Pos <= 1 then
return ADO.NO_IDENTIFIER;
end if;
Id := ADO.Identifier'Value (Cookie (Cookie'First .. Pos - 1));
if Cookie /= Model.Get_Authenticate_Cookie (Id) then
return ADO.NO_IDENTIFIER;
end if;
return Id;
exception
when others =>
return ADO.NO_IDENTIFIER;
end Get_Authenticate_Id;
-- ------------------------------
-- Get the user name from the email address.
-- Returns the possible user name from his email address.
-- ------------------------------
function Get_Name_From_Email (Email : in String) return String is
Pos : Natural := Util.Strings.Index (Email, '<');
begin
if Pos > 0 then
return Email (Email'First .. Pos - 1);
end if;
Pos := Util.Strings.Index (Email, '@');
if Pos > 0 then
return Email (Email'First .. Pos - 1);
else
return Email;
end if;
end Get_Name_From_Email;
procedure Create_Session (Model : in User_Service;
DB : in out Master_Session;
Session : out Session_Ref'Class;
User : in User_Ref'Class;
Ip_Addr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
Auth_Session : Session_Ref;
begin
-- Create the authenticate session.
Auth_Session.Set_Start_Date (Ada.Calendar.Clock);
Auth_Session.Set_User (User);
Auth_Session.Set_Ip_Address (Ip_Addr);
Auth_Session.Set_Stype (Users.Models.AUTH_SESSION);
Auth_Session.Set_Server_Id (Model.Server_Id);
Auth_Session.Save (DB);
-- Create the connection session.
Session := Session_Ref'Class (Null_Session);
Session.Set_Start_Date (Auth_Session.Get_Start_Date);
Session.Set_User (User);
Session.Set_Ip_Address (Ip_Addr);
Session.Set_Stype (Users.Models.CONNECT_SESSION);
Session.Set_Auth (Auth_Session);
Session.Set_Server_Id (Model.Server_Id);
Session.Save (DB);
Principal := AWA.Users.Principals.Create (User_Ref (User), Session_Ref (Session));
Ctx.Set_Context (Ctx.Get_Application, Principal);
end Create_Session;
-- ------------------------------
-- Authenticate the user with his OpenID identifier. The authentication process
-- was made by an external OpenID provider. If the user does not yet exists in
-- the database, a record is created for him. Create a new session for the user.
-- The IP address of the connection is saved in the session.
-- Raises Not_Found exception if the user is not recognized
-- ------------------------------
procedure Authenticate (Model : in User_Service;
Auth : in Security.Auth.Authentication;
IpAddr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
-- Update the user first name/last name
procedure Update_User;
OpenId : constant String := Security.Auth.Get_Claimed_Id (Auth);
Email : constant String := Security.Auth.Get_Email (Auth);
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
Found : Boolean;
User : User_Ref;
Session : Session_Ref;
-- ------------------------------
-- Update the user first name/last name
-- ------------------------------
procedure Update_User is
Name : constant String := Security.Auth.Get_Full_Name (Auth);
First_Name : constant String := Security.Auth.Get_First_Name (Auth);
Last_Name : constant String := Security.Auth.Get_Last_Name (Auth);
Sep : constant Natural := Util.Strings.Index (Name, ' ');
begin
if Name'Length > 0 and Name /= String '(User.Get_Name) then
User.Set_Name (Name);
end if;
if First_Name'Length > 0 and First_Name /= String '(User.Get_First_Name) then
User.Set_First_Name (First_Name);
end if;
if Last_Name'Length > 0 and Last_Name /= String '(User.Get_Last_Name) then
User.Set_Last_Name (Last_Name);
end if;
if Sep > 0 and String '(User.Get_First_Name) = "" then
User.Set_First_Name (Name (Name'First .. Sep - 1));
end if;
if Sep > 0 and String '(User.Get_Last_Name) = "" then
User.Set_Last_Name (Name (Sep + 1 .. Name'Last));
end if;
if Name'Length > 0 and String '(User.Get_First_Name) = "" then
User.Set_First_Name (Name);
end if;
if Name'Length = 0 then
User.Set_Name (Get_Name_From_Email (Email => Email));
end if;
User.Save (DB);
end Update_User;
begin
Log.Info ("Authenticated user {0}", Email);
Ctx.Start;
-- Find the user registered under the given OpenID identifier.
Query.Bind_Param (1, OpenId);
Query.Set_Filter ("o.open_id = ?");
User.Find (DB, Query, Found);
if not Found then
Log.Info ("User {0} is not known", Email);
declare
E : Email_Ref;
begin
E.Set_Email (Email);
E.Set_User_Id (0);
E.Save (DB);
User.Set_Email (E);
User.Set_Open_Id (OpenId);
Update_User;
E.Set_User_Id (User.Get_Id);
E.Save (DB);
end;
else
Update_User;
-- The user email address could have changed
declare
E : Email_Ref'Class := User.Get_Email;
begin
if Email /= String '(E.Get_Email) then
Log.Info ("Changing email address from {0} to {1} for user {2}",
String '(E.Get_Email), Email, OpenId);
E.Set_Email (Email);
E.Save (DB);
end if;
end;
end if;
Create_Session (Model, DB, Session, User, IpAddr, Principal);
if not Found then
declare
Event : AWA.Events.Module_Event;
begin
-- Send the event to indicate a new user was created.
Event.Set_Parameter ("email", Email);
Model.Send_Alert (User_Create_Event.Kind, User, Event);
end;
end if;
Ctx.Commit;
end Authenticate;
-- ------------------------------
-- Authenticate the user with his email address and his password.
-- If the user is authenticated, return the user information and
-- create a new session. The IP address of the connection is saved
-- in the session.
-- Raises Not_Found exception if the user is not recognized
-- ------------------------------
procedure Authenticate (Model : in User_Service;
Email : in String;
Password : in String;
IpAddr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
Hash : constant String := User_Service'Class (Model).Get_Password_Hash (Email, Password);
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
Found : Boolean;
User : User_Ref;
Session : Session_Ref;
begin
Log.Info ("Authenticate user {0}", Email);
-- Find the user registered under the given email address & password.
Query.Bind_Param (1, Email);
Query.Bind_Param (2, Hash);
Query.Set_Join ("INNER JOIN awa_email e ON e.user_id = o.id");
Query.Set_Filter ("e.email = ? AND o.password = ?");
User.Find (DB, Query, Found);
if not Found then
Log.Warn ("No user registered under email address {0} or invalid password",
Email);
raise Not_Found with "No user registered under email: " & Email;
end if;
Ctx.Start;
Create_Session (Model, DB, Session, User, IpAddr, Principal);
Ctx.Commit;
Log.Info ("Session {0} created for user {1}",
ADO.Identifier'Image (Session.Get_Id), Email);
end Authenticate;
-- ------------------------------
-- Authenticate the user with the authenticate cookie generated from a previous authenticate
-- session. If the cookie has the correct signature, matches a valid session,
-- return the user information and create a new session. The IP address of the connection
-- is saved in the session.
-- Raises Not_Found exception if the user is not recognized
-- ------------------------------
procedure Authenticate (Model : in User_Service;
Cookie : in String;
Ip_Addr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
use type ADO.Identifier;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Found : Boolean;
Cookie_Session : Session_Ref;
Auth_Session : Session_Ref;
Session : Session_Ref;
User : User_Ref;
Id : constant ADO.Identifier := Model.Get_Authenticate_Id (Cookie);
begin
Log.Info ("Authenticate cookie {0}", Cookie);
if Id = ADO.NO_IDENTIFIER then
Log.Warn ("Invalid authenticate cookie: {0}", Cookie);
raise Not_Found with "Invalid cookie";
end if;
Ctx.Start;
Cookie_Session.Load (DB, Id, Found);
if not Found then
Log.Warn ("Authenticate session {0} not found in database", ADO.Identifier'Image (Id));
raise Not_Found with "Invalid cookie";
end if;
if Cookie_Session.Get_Stype /= Users.Models.CONNECT_SESSION then
Log.Warn ("Authenticate session {0} not found in database", ADO.Identifier'Image (Id));
raise Not_Found with "Invalid cookie";
end if;
Auth_Session := Session_Ref (Cookie_Session.Get_Auth);
if not Auth_Session.Get_End_Date.Is_Null then
Log.Warn ("Authenticate session was closed");
raise Not_Found with "Authenticate session was closed.";
end if;
User := User_Ref (Auth_Session.Get_User);
Session.Set_Start_Date (Ada.Calendar.Clock);
Session.Set_User (User);
Session.Set_Ip_Address (Ip_Addr);
Session.Set_Stype (Users.Models.CONNECT_SESSION);
Session.Set_Auth (Auth_Session);
Session.Set_Server_Id (Model.Server_Id);
Session.Save (DB);
Principal := AWA.Users.Principals.Create (User, Session);
Ctx.Set_Context (Ctx.Get_Application, Principal);
-- Mark the cookie session as used.
Cookie_Session.Set_Stype (Users.Models.USED_SESSION);
if Cookie_Session.Get_End_Date.Is_Null then
Cookie_Session.Set_End_Date (ADO.Nullable_Time '(Value => Session.Get_Start_Date,
Is_Null => False));
end if;
Cookie_Session.Save (DB);
Ctx.Commit;
Log.Info ("Session {0} created for user {1}",
ADO.Identifier'Image (Session.Get_Id), ADO.Identifier'Image (User.Get_Id));
exception
when ADO.Objects.NOT_FOUND =>
Log.Warn ("No user associated with session {0}", ADO.Identifier'Image (Id));
raise Not_Found with "Invalid cookie";
end Authenticate;
-- ------------------------------
-- Start the lost password process for a user. Find the user having
-- the given email address and send that user a password reset key
-- in an email.
-- Raises Not_Found exception if no user with such email exist
-- ------------------------------
procedure Lost_Password (Model : in User_Service;
Email : in String) is
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
User : User_Ref;
Key : Access_Key_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
Stmt : ADO.Statements.Delete_Statement;
begin
Log.Info ("Lost password for {0}", Email);
Ctx.Start;
-- Find the user with the given email address.
Query.Set_Join ("INNER JOIN awa_email e ON e.user_id = o.id");
Query.Set_Filter ("e.email = ?");
Query.Bind_Param (1, Email);
User.Find (DB, Query, Found);
if not Found then
Log.Warn ("No user with email address {0}", Email);
raise Not_Found with "No user registered under email: " & Email;
end if;
-- Delete any previous access key for the user.
Stmt := DB.Create_Statement (AWA.Users.Models.ACCESS_KEY_TABLE);
Stmt.Set_Filter ("user_id = ?");
Stmt.Bind_Param (1, User.Get_Id);
Stmt.Execute;
-- Create the secure key to change the password
Key.Set_Access_Key (Create_Key (User.Get_Id));
Key.Set_User (User);
Key.Save (DB);
-- Send the email with the reset password key
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("key", Key.Get_Access_Key);
Event.Set_Parameter ("email", Email);
Model.Send_Alert (User_Lost_Password_Event.Kind, User, Event);
end;
Ctx.Commit;
end Lost_Password;
-- ------------------------------
-- Reset the password of the user associated with the secure key.
-- to the user in an email.
-- Raises Not_Found if there is no key or if the user does not have any email
-- ------------------------------
procedure Reset_Password (Model : in User_Service;
Key : in String;
Password : in String;
IpAddr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
Found : Boolean;
Email : Email_Ref;
Access_Key : Access_Key_Ref;
User : User_Ref;
Session : Session_Ref;
begin
Log.Info ("Reset password with key {0}", Key);
Ctx.Start;
-- Find the user associated with the key.
Query.Bind_Param (1, Key);
Query.Set_Filter ("access_key = ?");
Access_Key.Find (DB, Query, Found);
if not Found then
Log.Warn ("Invalid reset password key {0}", Key);
raise Not_Found with "No such access key: " & Key;
end if;
User := User_Ref (Access_Key.Get_User);
-- Get the user primary email address.
Email.Load (DB, User.Get_Email.Get_Id, Found);
-- Delete the access key.
Access_Key.Delete (DB);
-- Reset the user password
User.Set_Password (User_Service'Class (Model).Get_Password_Hash (Email.Get_Email, Password));
User.Save (DB);
-- Create the authentication session.
Create_Session (Model, DB, Session, User, IpAddr, Principal);
-- Send the email to warn about the password change
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("ip_address", IpAddr);
Event.Set_Parameter ("email", Email.Get_Email);
Model.Send_Alert (User_Reset_Password_Event.Kind, User, Event);
end;
Ctx.Commit;
exception
when ADO.Objects.NOT_FOUND =>
Log.Warn ("No user associated with access key {0}", Key);
raise Not_Found with "No user associated with access key: " & Key;
end Reset_Password;
-- ------------------------------
-- Create a user in the database with the given user information and
-- the associated email address. Verify that no such user already exist.
-- Raises User_Exist exception if a user with such email is already registered.
-- ------------------------------
procedure Create_User (Model : in User_Service;
User : in out User_Ref'Class;
Email : in out Email_Ref'Class) is
COUNT_SQL : constant String := "SELECT COUNT(*) FROM awa_email WHERE email = ?";
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Key : Access_Key_Ref;
Stmt : Query_Statement := DB.Create_Statement (COUNT_SQL);
Email_Address : constant String := Email.Get_Email;
Password : constant String := User.Get_Password;
begin
Log.Info ("Create user {0}", Email_Address);
Ctx.Start;
-- Check first if this user is already known
Stmt.Bind_Param (1, Email_Address);
Stmt.Execute;
if Stmt.Has_Elements and then Stmt.Get_Integer (0) > 0 then
Log.Warn ("User {0} already registered", Email_Address);
raise User_Exist with "Email address " & Email_Address & "' already used";
end if;
-- Save the email and the user
Email.Set_User_Id (0);
Email.Save (DB);
User.Set_Email (Email);
if String '(User.Get_Name) = "" then
User.Set_Name (String '(User.Get_First_Name) & " " & String '(User.Get_Last_Name));
end if;
User.Set_Password (User_Service'Class (Model).Get_Password_Hash (Email_Address, Password));
User.Save (DB);
Email.Set_User_Id (User.Get_Id);
Email.Save (DB);
-- Create the access key
Key.Set_Access_Key (Create_Key (Email.Get_Id));
Key.Set_User (User);
Key.Save (DB);
-- Send the email with the access key to finish the user registration.
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("key", Key.Get_Access_Key);
Event.Set_Parameter ("email", Email_Address);
Model.Send_Alert (User_Register_Event.Kind, User, Event);
end;
Ctx.Commit;
end Create_User;
-- ------------------------------
-- Verify the access key and retrieve the user associated with that key.
-- Starts a new session associated with the given IP address.
-- Raises Not_Found if the access key does not exist.
-- ------------------------------
procedure Verify_User (Model : in User_Service;
Key : in String;
IpAddr : in String;
Principal : out AWA.Users.Principals.Principal_Access) is
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
Found : Boolean;
Access_Key : Access_Key_Ref;
User : User_Ref;
Session : Session_Ref;
Email : Email_Ref;
begin
Log.Info ("Verify user with key {0}", Key);
Ctx.Start;
-- Find the user associated with the given key
Query.Bind_Param (1, Key);
Query.Set_Filter ("access_key = ?");
Access_Key.Find (DB, Query, Found);
if not Found then
Log.Warn ("No access key {0}", Key);
raise Not_Found with "No access key: " & Key;
end if;
User := User_Ref (Access_Key.Get_User);
Email := Email_Ref (User.Get_Email);
Access_Key.Delete (DB);
-- Create the authentication session.
Create_Session (Model, DB, Session, User, IpAddr, Principal);
-- Post the user creation event once the user is registered.
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("email", Email.Get_Email);
Model.Send_Alert (User_Create_Event.Kind, User, Event);
end;
Ctx.Commit;
exception
when ADO.Objects.NOT_FOUND =>
Log.Warn ("No user linked to access key {0}", Key);
raise Not_Found with "No user for access key: " & Key;
end Verify_User;
-- ------------------------------
-- Verify that the user session identified by <b>Id</b> is valid and still active.
-- Returns the user and the session objects.
-- Raises Not_Found if the session does not exist or was closed.
-- ------------------------------
procedure Verify_Session (Model : in User_Service;
Id : in ADO.Identifier;
User : out User_Ref'Class;
Session : out Session_Ref'Class) is
pragma Unreferenced (Model);
Sid : constant String := ADO.Identifier'Image (Id);
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Session := AWA.Services.Contexts.Get_Session (Ctx);
Query : ADO.SQL.Query;
Found : Boolean;
begin
Log.Info ("Verify user session {0}", Sid);
Query.Set_Filter ("id = ? AND end_date IS NULL");
Query.Bind_Param (1, Id);
Session.Find (Session => DB,
Query => Query,
Found => Found);
if not Found then
Log.Warn ("Session {0} is not found or closed", Sid);
raise Not_Found with "Session not found: " & Sid;
end if;
User := Session.Get_User;
end Verify_Session;
-- ------------------------------
-- Closes the session identified by <b>Id</b>. The session identified should refer to
-- a valid and not closed connection session.
-- When <b>Logout</b> is set, the authenticate session is also closed. The connection
-- sessions associated with the authenticate session are also closed.
-- Raises <b>Not_Found</b> if the session is invalid or already closed.
-- ------------------------------
procedure Close_Session (Model : in User_Service;
Id : in ADO.Identifier;
Logout : in Boolean := False) is
pragma Unreferenced (Model);
Sid : constant String := ADO.Identifier'Image (Id);
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Session : Session_Ref;
Found : Boolean;
begin
Log.Info ("Closing user session {0}", Sid);
Ctx.Start;
Session.Load (DB, Id, Found);
if not Found then
Log.Warn ("Session {0} is not found", Sid);
raise Not_Found with "Session not found: " & Sid;
end if;
-- The end date must be null. Otherwise, it means the session was closed already.
if not Session.Get_End_Date.Is_Null then
Log.Warn ("Session {0} is already closed", Sid);
raise Not_Found with "Session is closed: " & Sid;
end if;
Session.Set_End_Date (ADO.Nullable_Time '(Value => Ada.Calendar.Clock, Is_Null => False));
Session.Save (DB);
-- When logging out, close the authenticate session.
if Logout then
declare
Auth_Session : Session_Ref'Class := Session.Get_Auth;
begin
Auth_Session.Set_End_Date (Session.Get_End_Date);
Auth_Session.Save (DB);
Session := Session_Ref (Auth_Session);
end;
end if;
-- When closing the authenticate session, close any connection session that is still open.
if Session.Get_Stype = Users.Models.AUTH_SESSION then
declare
Stmt : ADO.Statements.Update_Statement
:= DB.Create_Statement (AWA.Users.Models.SESSION_TABLE);
begin
Stmt.Save_Field (Name => "end_date", Value => Session.Get_End_Date);
Stmt.Set_Filter ("auth_id = :auth AND end_date IS NULL");
Stmt.Bind_Param ("auth", Session.Get_Id);
Stmt.Execute;
end;
end if;
Ctx.Commit;
end Close_Session;
-- ------------------------------
-- Initialize the user service.
-- ------------------------------
overriding
procedure Initialize (Model : in out User_Service;
Module : in AWA.Modules.Module'Class) is
DEFAULT_KEY : constant String := "8ef60aad66977c68b12f4f8acab5a4e00a77f6e8";
begin
AWA.Modules.Module_Manager (Model).Initialize (Module);
Model.Server_Id := Module.Get_Config ("app.server.id", 1);
Set_Unbounded_String (Model.Auth_Key,
Module.Get_Config ("app.server.key", DEFAULT_KEY));
if Model.Auth_Key = DEFAULT_KEY then
Log.Info ("The 'app.server.key' configuration property not found. Using default key.");
end if;
Log.Info ("User server associated with server id {0}", Integer'Image (Model.Server_Id));
-- Close the connection sessions that have not been closed correctly.
declare
DB : ADO.Sessions.Master_Session := Module.Get_Master_Session;
Stmt : ADO.Statements.Update_Statement
:= DB.Create_Statement (AWA.Users.Models.SESSION_TABLE);
begin
DB.Begin_Transaction;
Stmt.Save_Field (Name => "end_date",
Value => ADO.Nullable_Time '(Value => Ada.Calendar.Clock,
Is_Null => False));
Stmt.Set_Filter ("server_id = :server AND end_date IS NULL AND stype = :type");
Stmt.Bind_Param ("server", Model.Server_Id);
Stmt.Bind_Param ("type", CONNECT_SESSION_TYPE);
Stmt.Execute;
DB.Commit;
end;
end Initialize;
begin
Integer_Random.Reset (Random_Generator);
end AWA.Users.Services;
|
32kb_flash_cartridge/programmer/tester.asm | kant/myelin-acorn-electron-hardware | 42 | 12043 | <reponame>kant/myelin-acorn-electron-hardware
; Copyright 2017 Google Inc.
;
; 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.
; flash cartridge test code
; TO DO
; PCBv2: hardware write protect jumper option
; programming limits
; PAGE=E00
; HIMEM=1100 because i've *RUN something which loads in there
; mode 6 screen start = 6000
; 6000-1000 = 5000h
; hopper is 283A long
; we can load a 16k rom at $2000 and have it fit between us and screen memory!
; zero page addresses
zp_lo := $90
zp_hi := $91
; constants
OSWRCH := $FFEE
; program entry point
entry_point:
JMP main
; 'puts' macro
puts_pos: .byte $00 ; string position
.macro puts addr
.proc
lda #0
sta puts_pos
write_byte:
ldx puts_pos
lda addr, x
cmp #0
beq done
jsr OSWRCH
inc puts_pos
jmp write_byte
done:
.endproc
.endmacro
probing_cart0_msg:
.byte "Probing cart 0"
.byte $0D
.byte $0A
.byte $00
probing_cart2_msg:
.byte "Probing cart 2"
.byte $0D
.byte $0A
.byte $00
programming_bank_msg:
.byte "Programming bank "
.byte $00
all_done_msg:
.byte "All done!"
.byte $0D
.byte $0A
.byte $00
programming_msg:
.byte "Programming..."
.byte $0D
.byte $0A
.byte $00
blank_msg:
.byte "ROM is blank!"
.byte $0D
.byte $0A
.byte $00
waiting_msg:
.byte "Waiting..."
.byte $0D
.byte $0A
.byte $00
erasing_msg:
.byte "Erasing..."
.byte $0D
.byte $0A
.byte $00
done_msg:
.byte "Done."
.byte $0D
.byte $0A
.byte $00
crlf:
.byte $0D
.byte $0A
.byte $00
previous_rom: .byte $00
erase_cart_first: .byte $00 ; erases if 1
rom_to_program: .byte $01 ; bank 00 or 01
main:
; stash initial ROM ID
lda $f4
sta previous_rom
; probe cartridge 0,1
puts probing_cart0_msg
LDA #0
JSR identify_flash_chip
puts programming_bank_msg
lda rom_to_program
jsr write_hex_byte
puts crlf
; do we need to erase the chip first?
lda erase_cart_first
cmp #0
beq main__erase_done
jsr erase_whole_chip
main__erase_done:
lda rom_to_program
jsr select_rom
jsr program_16k_rom
jsr blank_check
; probe cartridge 2,3
;puts probing_cart2_msg
;LDA #2
;JSR select_rom
;JSR identify_flash_chip
back_to_basic:
puts all_done_msg
lda previous_rom
jsr select_rom
RTS
hang:
puts all_done_msg
JMP hang
; A = number to write (0-15)
write_hex_char:
CMP #10
BCC less_than_ten
CLC
ADC #55 ; add 'A' - 10
JMP print_it
less_than_ten:
CLC
ADC #48 ; add '0'
print_it:
jsr OSWRCH
RTS
; A = byte to write
write_hex_byte:
PHA ; stash a copy of the char
AND #$F0
LSR
LSR
LSR
LSR
JSR write_hex_char ; write high nybble
PLA ; get the char back in A
AND #$0F
JSR write_hex_char ; write low nybble
RTS
; X, Y = address to write
; roughly: printf("%02x%02x\r\n", y, x)
write_hex_address:
; stash x and y for later
txa
pha
tya
pha
; and stash x (low byte) again
txa
pha
; now write y (high byte)
tya
jsr write_hex_byte
; and x
pla
jsr write_hex_byte
puts crlf
; and get x and y back
pla
tay
pla
tax
rts
; put the cartridge in the 0/1 slot
; A = rom ID to select (0-3)
select_rom:
STA zp_lo ; save ROM ID
LDA #12 ; deselect BASIC
STA $F4
STA $FE05
LDA zp_lo ; load ROM ID
STA $F4
STA $FE05
RTS
; we need to be able to write to addresses 2AAA and 5555 (A14-A0; don't care about A15+)
; A16 = ROMQA (bank ID)
; A15 = 0
; A14 = A12
; A13-A0 map into $8000-$BFFF
; so we select the low bank (rom_id), then:
; 2AAA = 010 1010 1010 1010, i.e. A13:0 = 2AAA, + 8000 = AAAA
; 5555 = 101 0101 0101 0101, i.e. A13:0 = 1555, + 8000 = 9555
; flash chip identification
; A = base rom ID to select (0 or 2)
rom_id: .byte $00
chip_id: .byte $00
identify_flash_chip:
STA rom_id
JSR select_rom
; * enter flash ID mode
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write 90 to 5555
LDA #zp_lo
STA $9555
; * read chip identifying info
; read 0000, should be $BF
LDA $8000
JSR write_hex_byte
puts crlf
; read 0001, should be $B5 (or B6 for 39SF020A, B7 for 39SF040)
LDA $8001
JSR write_hex_byte
puts crlf
; * exit flash ID mode
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write F0 to 5555
LDA #$F0
STA $9555
RTS
blank_check:
; counter
lda #0
sta zp_lo
lda #$80
sta zp_hi
blank_check__loop:
ldy #0
lda (zp_lo), y
cmp #0
bne blank_check__not_blank ; not blank
; increment zp_lo, zp_hi
clc
lda zp_lo
adc #1
sta zp_lo
lda zp_hi
adc #1
sta zp_hi
; are we at the end of the rom space?
cmp #$c0
bne blank_check__loop
puts blank_msg ; if we get here, it's blank!
blank_check__done:
RTS
blank_check__not_blank:
ldx #0
ldy zp_hi
jmp dump_page
; --- programming ---
; A = byte to write
; X, Y = low/high bytes of address to write to (in 8000-BFFF)
; this assumes the correct bank is already selected and the sector is erased
program_byte:
STX zp_lo ; write X,Y,A to zp_lo
STY zp_hi
STA $03
; * write four command bytes
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write A0 to 5555
LDA #$A0
STA $9555
; * write data to address
LDA $03
LDX #0
STA (zp_lo, X)
; * poll toggle bit until the program operation is complete
JSR wait_until_operation_done
RTS
; --- program 16kB rom from $2000 into bank 0 ---
; this assumes the correct bank is already selected
; and the data to program is from $2000-$6000
; (you probably want to be in MODE 6)
; source ($2000)
src_hi: .byte $00
src_lo: .byte $00
; dest ($8000)
dest_hi: .byte $00
dest_lo: .byte $00
; counter ($0000 - $4000)
pos_hi: .byte $00
pos_lo: .byte $00
; dest + counter
op_hi: .byte $00
op_lo: .byte $00
program_16k_rom:
; start by trying to program from 4000-40ff -> a000-a0ff
puts programming_msg
; store src and dest addresses
lda #$20
sta src_hi
clc
adc #$60 ; 0x6000 = 0x8000 - 0x2000
sta dest_hi
lda #$00
sta src_lo
sta dest_lo
; reset offset
lda #$00
sta pos_hi
sta pos_lo
; now loop and program 00 into every byte, to test
program_16k_rom__loop:
; work out our destination address
clc
lda dest_lo
adc pos_lo
sta op_lo
lda dest_hi
adc pos_hi
sta op_hi
; write destination address if op_lo==0
lda op_lo
cmp #0
bne program_16k_rom__done_writing_addr
ldx op_lo
ldy op_hi
jsr write_hex_address
program_16k_rom__done_writing_addr:
; get byte from memory
clc
lda pos_lo
adc src_lo
sta zp_lo
lda pos_hi
adc src_hi
sta zp_hi
; debug
;ldx zp_lo
;ldy zp_hi
;jsr write_hex_address
; /debug
ldy #0
lda (zp_lo), y
; make byte programming call
ldx op_lo
ldy op_hi
jsr program_byte
; increment position
clc
lda pos_lo
adc #1
sta pos_lo
bcc program_16k_rom__loop ; inside a 256 byte block
; dump the page we just wrote
clc
lda pos_lo ; should be 0
adc dest_lo ; should be 0
tax
lda pos_hi
adc dest_hi
tay
;jsr dump_page
; see if we're done otherwise go back and program another page
clc
lda pos_hi
adc #1
sta pos_hi
cmp #$40 ; are we done programming $4000 bytes?
bne program_16k_rom__loop
puts done_msg
RTS
; --- 4kB sector erase ---
; X, Y = low, high address of a byte in the sector to erase
; this assumes the correct bank is already selected
erase_sector:
STX zp_lo ; write X,Y to zp_lo
STY zp_hi
; * six byte command load sequence
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write 80 to 5555
LDA #$80
STA $9555
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write 30 to SAx (uses Ams-A12 lines!!)
LDA #$30
LDX #0
STA (zp_lo, X)
; * poll toggle bit until the sector erase is complete
JSR wait_until_operation_done
RTS
; --- chip erase ---
erase_whole_chip:
puts erasing_msg
; * six byte command
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write 80 to 5555
LDA #$80
STA $9555
; write AA to 5555
LDA #$AA
STA $9555
; write 55 to 2AAA
LDA #$55
STA $AAAA
; write 10 to 5555
LDA #$10
STA $9555
puts waiting_msg
; * poll toggle bit until the chip erase is complete
JSR wait_until_operation_done
puts done_msg
RTS
; --- dump data from a page on the rom ---
; address in X, Y (low in X, high in Y)
dump_page:
STX zp_lo ; page lo = zp_lo
STY zp_hi ; page hi = zp_hi
JSR write_hex_address
LDA #0 ; loop counter (0-FF)
dump_page__next:
PHA
TAY
LDA (zp_lo), Y
JSR write_hex_byte
LDA #32
JSR OSWRCH
PLA
CMP #$FF
BEQ dump_page__done
CLC
ADC #1
JMP dump_page__next
dump_page__done:
puts crlf
RTS
; --- data# / toggle bit detection ---
wait_until_operation_done:
; keep reading DQ6 until it stops toggling
LDA $8000
EOR $8000
AND #$40
BNE wait_until_operation_done
RTS
|
projects/batfish/src/main/antlr4/org/batfish/grammar/f5_bigip_structured/F5BigipStructured_ltm_rule.g4 | zabrewer/batfish | 763 | 6109 | <gh_stars>100-1000
parser grammar F5BigipStructured_ltm_rule;
import F5BigipStructured_common;
options {
tokenVocab = F5BigipStructuredLexer;
}
l_rule
:
RULE_SPECIAL name = structure_name BRACE_LEFT
(
NEWLINE
(
proc
| when
)*
)? BRACE_RIGHT NEWLINE
;
proc
:
PROC name = CHARS BRACE_LEFT
(
args += CHARS
)* BRACE_RIGHT BRACE_LEFT
(
NEWLINE command_sequence?
)? BRACE_RIGHT NEWLINE
;
when
:
WHEN w_event BRACE_LEFT
(
NEWLINE command_sequence?
)? BRACE_RIGHT NEWLINE
;
w_event
:
EVENT
;
command_sequence
:
whitespace? command_separator*
(
commands += command command_separator+
)* commands += command whitespace? command_separator*
;
command
:
words += i_word
(
WS words += i_word
)*
;
command_separator
:
whitespace?
(
SEMICOLON
| NEWLINE
) whitespace?
;
whitespace
:
(COMMENT | WS)+
;
command_substitution
:
BRACKET_LEFT command_sequence? BRACKET_RIGHT
;
variable_substitution
:
DOLLAR
(
ivs_braces
| ivs_name
)
;
ivs_braces
:
BRACE_LEFT braced_variable_name BRACE_RIGHT
;
braced_variable_name
:
CHARS
;
ivs_name
:
scalar_variable_name index = variable_index?
;
scalar_variable_name
:
CHARS
;
variable_index
:
PAREN_LEFT i_word PAREN_RIGHT
;
i_word
:
segments+=iw_segment+
;
iw_segment
:
iws_braces
| iws_chars
| command_substitution
| iws_double_quotes
| backslash_substitution
| variable_substitution
;
iws_braces
:
BRACE_LEFT iwsb_segment+ BRACE_RIGHT
;
iwsb_segment
:
iws_braces
| iwsbs_chars
| iwsbs_escape_sequence
;
iwsbs_chars
:
CHARS
;
iwsbs_escape_sequence
:
BACKSLASH_NEWLINE_WS
;
iws_chars
:
CHARS
;
iws_double_quotes
:
DOUBLE_QUOTE iwsd_segment* DOUBLE_QUOTE
;
iwsd_segment
:
iwsds_chars
| command_substitution
| backslash_substitution
| variable_substitution
// may occur when breaking out of nested lexer mode
| NEWLINE
| WS
;
iwsds_chars
:
CHARS
;
backslash_substitution
:
BACKSLASH_CARRIAGE_RETURN
| BACKSLASH_CHAR
| BACKSLASH_NEWLINE
| BACKSLASH_NEWLINE_WS
;
|
Library/AnsiC/malloc_asm.asm | steakknife/pcgeos | 504 | 247586 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved
PROJECT: PC/GEOS
MODULE: AnsiC library
FILE: malloc_asm.asm
AUTHOR: <NAME>, Sep 17, 1991
ROUTINES:
Name Description
---- -----------
_Malloc allocs fixed memory
_ReAlloc resizes fixed memory
_Free frees fixed memory
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/17/91 Initial revision
schoon 6/11/92 Revised for ANSI C standards
DESCRIPTION:
This file contains the PC/GEOS implementations of the C routines
malloc(), calloc(), realloc(), cfree(), and free().
NOTES:
There are 2 allocation strategies used by this code. If the block size
is below MALLOC_LARGE_THRESHOLD, then it is allocated in one of the
fixed LMem heaps kept for this purpose. If the block size is above
the threshold, then the memory is allocated in a global memory block
by itself. Since the pointer to memory returned by the "large" strategy
is below any of the valid pointers returned by the "small" strategy
(due to the fact that the small blocks all lie beyond the
LMemBlockHeader at the start of the lmem blocks, while the large
blocks all lie at LARGE_BLOCK_OFFSET, which is less than the
LMemBlockHeader), we are able to tell which type of block it is just
by looking at the address.
When we free these blocks, we have a different strategy for each.
When we free a large block, we just call MemFree on the block. If
it is a small block, we free the chunk, and then check to see if that
LMem block is now empty. If it isn't, we just exit. If it is, we scan
through the list of lmem blocks to see if it is the only lmem block.
if it isn't, we free it up (so we have at most one empty lmem block
hanging around per geode).
In the GeodePrivData for each geode we keep 2 words - the first one
is the handle of a block containing a list of handles of lmem blocks
used for the small allocation scheme. The second one is the handle
of a block containing a list of handles of global memory blocks
containing blocks allocated via the large allocation scheme.
The format of these blocks is as follows:
word numberOfEntriesInList ;This includes any empty slots
word entry1
word entry2
word entry3
.
.
.
$Id: malloc_asm.asm,v 1.1 97/04/04 17:42:12 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include ansicGeode.def
;RESIDENT segment word public 'CODE'
;MAINCODE segment word public 'CODE'
MAINCODE segment public 'CODE'
.model medium, pascal
GeodePrivReadOneWord proc near ;Returns value in CX
mov cx, 1 ;Read one word
push ax
segmov ds, ss
mov si, sp ;DS:SI <- ptr to word on stack
call GeodePrivRead
pop cx ;
ret
GeodePrivReadOneWord endp
GeodePrivWriteOneWord proc near ;Pass value to write in CX
push cx
mov cx, 1 ;Write one word
segmov ds, ss
mov si, sp ;DS:SI <- ptr to word on stack
call GeodePrivWrite
pop cx ;
ret
GeodePrivWriteOneWord endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AddHandleToMallocList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Adds a handle to the associated list of handles.
CALLED BY: GLOBAL
PASS: ds:[LMBH_handle] - handle to add
bx - geode whose privData we should use
di - offset to pass to GeodePrivRead/GeodePrivWrite
RETURN: carry set if error
DESTROYED: bx, cx, dx, di, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SLOT_INCREMENT equ 8
AddHandleToMallocList proc near uses ds, es, bp, ax
.enter
; Read in the handle of the block containing the list of blocks
mov dx, ds:[LMBH_handle]
call GeodePrivReadOneWord
jcxz doMalloc ;If no block, allocate a new one
; Scan through the block looking for an empty slot to store the new
; handle.
mov bx, cx
call MemLock
mov es, ax
scanTop:
mov di, 2
mov cx, es:[0] ;CX <- # items in block
clr ax
repne scasw ;Look for an empty spot
jne reAlloc ;Branch if no empty slots found
mov es:[di][-2], dx ;Save handle in empty slot
clc ;Signify no errors
unlockExit:
call MemUnlock ;Unlock the block
exit:
.leave
ret
reAlloc:
; No empty slots found, so reallocate the block bigger (create some).
mov ax, es:[0]
inc ax ;AX <- # words in block currently
shl ax, 1 ;AX <- # bytes in block
add ax, SLOT_INCREMENT*2 ;Add room for 8 more slots
mov ch, mask HAF_ZERO_INIT
call MemReAlloc
jc unlockExit ;If error reallocing, branch
mov es, ax
add {word} es:[0], SLOT_INCREMENT ;
jmp scanTop
doMalloc:
; ALLOCATE A NEW BLOCK TO HOLD DATA
mov bp, bx ;BP <- geode handle
mov ax, SLOT_INCREMENT*2 ;
mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE or (mask HAF_ZERO_INIT shl 8)
call MemAllocSetOwnerOrDefault
jc exit ;If we could not allocate the block,
; branch.
mov es, ax ;
mov {word} es:[0], SLOT_INCREMENT-1;
mov cx, bx ;
mov bx, bp ;BX <- GeodeHandle
call GeodePrivWriteOneWord ;Store the handle in the GeodePrivData
mov bx, cx ; area.
jnc scanTop ;If no error, branch
call MemFree ;Else, free up this block and exit.
stc
jmp exit
AddHandleToMallocList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RemoveHandleFromMallocList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Removes a handle from the associated list of handles.
CALLED BY: GLOBAL
PASS: ds:[LMBH_handle] - handle to remove
bx - geode whose privData we should use
di - offset to pass to GeodePrivRead/GeodePrivWrite
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
RemoveHandleFromMallocList proc near uses es, ds
.enter
; Read in the handle of the block containing the list of blocks
mov dx, ds:[LMBH_handle]
call GeodePrivReadOneWord
EC < jcxz nullError ;If no block, allocate a new one >
; Scan through the block looking for the passed handle.
mov bx, cx
call MemLock
mov es, ax
mov di, 2
mov cx, es:[0] ;CX <- # items in block
mov ax, dx
repne scasw ;Look for an empty spot
EC < ERROR_NZ HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS >
mov {word} es:[di][-2], 0 ;Nuke handle
call MemUnlock
.leave
ret
EC <nullError: >
EC < ERROR FREE_CALLED_BEFORE_MALLOC >
RemoveHandleFromMallocList endp
if ERROR_CHECK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCountFreeBlocksOnMallocList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Counts total number of malloc heaps with no items
CALLED BY: _Free
PASS: bx - geode whose privData we should use
di - offset to pass to GeodePrivRead/GeodePrivWrite
RETURN: dx - # free blocks
DESTROYED: ax, bx, cx, di, si, ds, es
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ECCountFreeBlocksOnMallocList proc near
.enter
; Read in the handle of the block containing the list of blocks
call GeodePrivReadOneWord
jcxz nullError ;If no block, fail
; Traverse the block counting the # empty blocks
mov bx, cx
call MemLock
push bx
mov ds, ax
mov si, 2
mov cx, ds:[0] ;CX <- # items in block
clr dx
findNext:
lodsw
tst ax
jz next
xchg ax, bx
call MemDerefES
cmp es:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader
jne next ;If not empty, branch
inc dx ;Else, increment count of empty blocks
next:
loop findNext
pop bx
call MemUnlock ;
.leave
ret
nullError:
ERROR FREE_CALLED_BEFORE_MALLOC
ECCountFreeBlocksOnMallocList endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AllocInSmallList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Traverses the list of lmem blocks and tries to allocate
the passed # bytes in each one until it is successful
CALLED BY: GLOBAL
PASS: bx - geode whose privData we should use
cx - # bytes to allocate
RETURN: ds:ax <- pointer to block allocated
carry set if unsuccessful
DESTROYED: ax, bx, cx, di, si, ds
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AllocInSmallList proc near
.enter
; Read in the handle of the block containing the list of blocks
mov dx, cx ;DX <- size
push ds
NOFXIP< segmov ds, dgroup, di >
FXIP < push bx >
FXIP < mov bx, handle dgroup >
FXIP < call MemDerefDS ; ds = dgroup >
FXIP < pop bx >
mov di, ds:[mallocOffset] ;
pop ds
call GeodePrivReadOneWord
stc
jcxz exit ;If no blocks allocated, exit
; Traverse the block and attempt to allocate in each one (ignoring
; empty slots).
mov bx, cx
mov cx, dx ;CX <- # bytes to allocate
push bx
call MemLock
mov ds, ax
mov si, 2
mov dx, ds:[0] ;CX <- # items in block
findNext:
lodsw
tst ax
jz next ;If handle is null, branch (empty slot)
mov di, ds ;.
xchg ax, bx ;BX <- handle of this lmem block
call MemDerefDS ;DS <- segment of this lmem block
call LMemAlloc ;Try to allocate here
jnc success ;Branch if no error allocating
mov ds, di ;
next:
dec dx ;Decrement # handles to try
jnz findNext ;
stc ;Unsuccessful, so unlock and exit w/carry set
success:
pop bx ;Unlock list of blocks
call MemUnlock ;
exit:
.leave
ret
AllocInSmallList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MemAllocFixed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Just a front end to MemAlloc
CALLED BY: GLOBAL
PASS: ax - size of block to alloc
bx - owner of block
RETURN: ds - segment of block
+ rest of MemAlloc return values
DESTROYED: cx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MemAllocFixed proc near
mov cx, mask HF_FIXED or mask HF_SHARABLE
call MemAllocSetOwnerOrDefault
mov ds, ax
ret
MemAllocFixed endp
MemAllocSetOwnerOrDefault proc near
tst bx ;If an owner is passed in,
jnz setOwner ; then set the owner.
call MemAlloc ;Else, use current process
jmp exit
setOwner:
call MemAllocSetOwner ;Try to allocate memory
exit:
ret
MemAllocSetOwnerOrDefault endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
_Malloc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: This routine allocates fixed memory for C programs to use.
C DECLARATION:
extern void _far _pascal
*_Malloc(size_t blockSize, GeodeHandle geodeHan, word zeroInit)
NOTES: geodeHan can be 0, if you just want to use the current process'
malloc heap.
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/17/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MALLOC_LARGE_THRESHOLD equ 511
MALLOC_SMALL_BLOCK_SIZE equ 1024
LARGE_BLOCK_OFFSET equ size hptr
global _Malloc:far
_Malloc proc far blockSize:word, geodeHan:hptr, zinit:word
uses ds, di, si
.enter
mov cx, blockSize
EC < tst cx >
EC < ERROR_Z GEO_MALLOC_PASSED_SIZE_OF_ZERO >
; Mallocs of over MALLOC_LARGE_THRESHOLD should be put in their own
; fixed block.
cmp cx, MALLOC_LARGE_THRESHOLD
ja largeAlloc
; Scan through the list of fixed lmem blocks to allocate this
; small block.
mov bx, geodeHan
call AllocInSmallList ;Try to allocate in various blocks
; in small list (returns pointer in
; DS:AX).
jnc zinitAndExit ;Branch if successful
; Could not allocate in already existing lmem block, so allocate a new
; lmem block and allocate in it.
mov ax, MALLOC_SMALL_BLOCK_SIZE
mov bx, geodeHan
call MemAllocFixed ;Try to allocate new lmem block.
jc errRet ;If unsuccessful, branch to exit.
mov ax, LMEM_TYPE_GENERAL
mov dx, size LMemBlockHeader
mov di, mask LMF_NO_HANDLES or mask LMF_NO_ENLARGE or mask LMF_RETURN_ERRORS
push bp
clr bp
call LMemInitHeap
pop bp
; Allocate a new chunk on the just-allocated lmem heap.
mov cx, blockSize
call LMemAlloc
EC < ERROR_C COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT >
clr di
jmp mallocCommon ;Branch to add block to list, and
; to return pointer to block
largeAlloc:
; Allocate a fixed block on the heap with the handle of the block at the
; start, and the remainder of the block to be returned for use by the
; caller.
add cx, LARGE_BLOCK_OFFSET ;These blocks have the handle of the
xchg ax, cx ; block at the start. Put size in AX.
mov bx, geodeHan
call MemAllocFixed ;
jc errRet ;If we couldn't, branch
mov dx, bx ;DX <- handle of new block
mov ds:[0], bx ;Save handle of block
mov di, 2 ;DI <- offset to handle of block
; containing list of large data blocks
; (in the GeodePrivData area reserved
; for the malloc routines).
mov ax, LARGE_BLOCK_OFFSET ;DS:AX <- pointer to data just alloc'd
mallocCommon:
; Get the offset to the GeodePriv area reserved for the malloc routines.
push ds
NOFXIP< segmov ds, <segment udata>, bx >
FXIP < mov bx, handle dgroup >
FXIP < call MemDerefDS ; ds = dgroup >
add di, ds:[mallocOffset] ;
pop ds
mov bx, geodeHan ;
call AddHandleToMallocList ;Add handle at DS:0 to malloc list
jc freeError ;If couldn't add to list, branch and
; exit.
zinitAndExit: ;
mov dx, ds ;DX:AX <- pointer to data
tst zinit ;If no zero-init desired, just branch
jz exit
push es, ax
mov es, dx ;ES:DI <- pointer to block
xchg di, ax
clr ax
mov cx, blockSize
shr cx, 1
jnc 80$
stosb
80$:
rep stosw
pop es, ax ;DX:AX <- pointer to block
exit:
.leave
ret
freeError:
mov bx, dx ;Free up the block
call MemFree
errRet:
clr dx
clr ax
jmp exit
_Malloc endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
_Free
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Frees up a block previously returned from _Malloc.
CALLED BY: GLOBAL
C DECLARATION:
extern void _far _pascal _Free(void *blockPtr, GeodeHandle geodeHan);
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
global _Free:far
_Free proc far blockPtr:fptr, geodeHan:hptr
uses ds, di, si
.enter
EC < tst blockPtr.high >
EC < ERROR_Z NULL_PTR_PASSED_TO_GEO_FREE >
cmp blockPtr.low, LARGE_BLOCK_OFFSET
jne smallBlockFree
; The free block was large (allocated as a single block on the global
; heap). Remove the block from the list, and free it up.
NOFXIP< segmov ds, <segment udata>, di >
FXIP < mov bx, handle dgroup >
FXIP < call MemDerefDS ; ds = dgroup >
mov di, ds:[mallocOffset] ;DI <- ptr to handle of large
add di, 2 ; block list in GeodePrivData
freeAndRemoveBlock:
mov bx, geodeHan ;
mov ds, blockPtr.segment
call RemoveHandleFromMallocList ;
mov bx, ds:[0]
call MemFree ;Free up the handle
jmp exit
smallBlockFree:
lds ax, blockPtr ;If small block, just free
call LMemFree ; up the chunk. We never
; return this memory to the
; global heap.
; If the block is now empty, free it.
cmp ds:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader
jne exit ; Branch if block is non-empty
push ds
NOFXIP< segmov ds, <segment udata>, di >
FXIP < mov bx, handle dgroup >
FXIP < call MemDerefDS ; ds = dgroup >
mov di, ds:[mallocOffset] ;DI <- ptr to handle of small
pop ds ; block list in GeodePrivData
EC < mov bx, geodeHan ; >
EC < call ECCountFreeBlocksOnMallocList ; >
EC < cmp dx, 2 ; >
EC < ERROR_A MORE_THAN_ONE_FREE_MALLOC_BLOCK >
jmp freeAndRemoveBlock
exit:
.leave
ret
_Free endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
_ReAlloc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: ReAllocates a previously _Malloc'd block of memory.
CALLED BY: GLOBAL
C DECLARATION: extern void _far _pascal
*_ReAlloc(void *blockPtr, size_t newSize, GeodeHandle geodeHan);
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
*
* 1) If the space is resized larger, new space is *not* zero-initialized.
*
* 2) If realloc() is called to resize the memory *smaller*, it will
* always succeed.
*
* 3) If realloc() does not succeed, it will return NULL, and the original
* memory block will be unaffected.
*
* 4) If the passed blockPtr is NULL, realloc() acts like malloc().
*
* 5) If the passed newSize is 0, the passed blockPtr is freed, and
* NULL is returned.
*
* 6) The block *may* move.
*
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 9/18/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
global _ReAlloc:far
_ReAlloc proc far blockPtr:fptr, newSize:word, geodeHan:hptr
uses ds
.enter
; Handle special goofy cases (null size or block ptr passed in)
mov cx, newSize
tst blockPtr.high ;If null block ptr, pass off to malloc()
jz doMalloc ;
jcxz doFree ;If zero new size, pass off to free()
mov ds, blockPtr.high
cmp blockPtr.low, LARGE_BLOCK_OFFSET;If large block, use
je largeBlockReAlloc ; appropriate realloc method
; If this is a "small" block, then try to LMemReAlloc it. If that fails,
; then try malloc-ing a new block, and copying the data over.
mov ax, blockPtr.low ;DS:AX <- ptr to block
call LMemReAlloc ;
mov dx, ds ;DX:AX <- ptr to block
if 0
jc 20$ ;Error
; Copy data from blockptr to new chunk and delete blockptr.
; LMemRealloc does not always resize blockptr, instead it may
; allocate a new chunk.
;
cmp ax, blockPtr.low
je exit ;No new chunk, so done
push es, di, si
jmp 30$ ;Copy and delete.
else
;
; For LMF_NO_HANDLES, if LMemReAlloc has to allocate a new chunk, it will
; copy over the data itself and delete the old chunk, so we don't need to
; do this -- brianc 11/17/98 (yes, '98)
;
jnc exit
endif
; Simple allocation failed. malloc() new block and copy the data over.
20$:
push es, di, si
push newSize
push geodeHan
clr ax
push ax
call _Malloc
tst dx ;If malloc failed, branch
jz mallocFailed
; Copy the data from the old block into the newly alloc'd block.
30$:
mov si, blockPtr.low ;DS:SI <- ptr to original block
ChunkSizePtr ds, si, cx ;CX <- size of original block (data to
; copy over).
EC < cmp cx, newSize >
EC < ERROR_AE LMEM_REALLOC_FAILED_WHEN_MAKING_CHUNK_SMALLER >
mov es, dx
mov di, ax
shr cx, 1
jnc 10$
movsb
10$:
rep movsw
; Free the old block up.
push dx, ax
push blockPtr.high
push blockPtr.low
push geodeHan
call _Free
pop dx, ax
mallocFailed:
pop es, di, si
exit:
.leave
ret
doFree:
push blockPtr.high
push blockPtr.low
push geodeHan
call _Free
jmp clrRet
doMalloc:
EC < tst blockPtr.low >
EC < ERROR_NZ INVALID_PTR_PASSED_TO_GEO_REALLOC >
push cx ; newSize
push geodeHan
clr ax ;Do not zero init
push ax
call _Malloc
jmp exit
; For large blocks, the data lies in a global memory block by itself.
; Just call MemReAlloc routine.
largeBlockReAlloc:
mov ds, blockPtr.high
mov_tr ax, cx
add ax, LARGE_BLOCK_OFFSET
clr ch
mov bx, ds:[0] ;ReAllocate the block
call MemReAlloc
xchg dx, ax ;DX <- segment of fixed block
mov ax, LARGE_BLOCK_OFFSET ;DX:AX <- ptr to large block
jnc exit ;If no error in the realloc, branch
clrRet:
clr ax, dx
jmp exit
_ReAlloc endp
;RESIDENT ends
MAINCODE ends
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.