Skip to content

Commit d29ba7e

Browse files
committed
Added Ada source, FSF licensing, README.md.
1 parent 37d360d commit d29ba7e

25 files changed

+2223
-0
lines changed

COPYING.RUNTIME

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
GCC RUNTIME LIBRARY EXCEPTION
2+
3+
Version 3.1, 31 March 2009
4+
5+
Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
6+
7+
Everyone is permitted to copy and distribute verbatim copies of this
8+
license document, but changing it is not allowed.
9+
10+
This GCC Runtime Library Exception ("Exception") is an additional
11+
permission under section 7 of the GNU General Public License, version
12+
3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
13+
bears a notice placed by the copyright holder of the file stating that
14+
the file is governed by GPLv3 along with this Exception.
15+
16+
When you use GCC to compile a program, GCC may combine portions of
17+
certain GCC header files and runtime libraries with the compiled
18+
program. The purpose of this Exception is to allow compilation of
19+
non-GPL (including proprietary) programs to use, in this way, the
20+
header files and runtime libraries covered by this Exception.
21+
22+
0. Definitions.
23+
24+
A file is an "Independent Module" if it either requires the Runtime
25+
Library for execution after a Compilation Process, or makes use of an
26+
interface provided by the Runtime Library, but is not otherwise based
27+
on the Runtime Library.
28+
29+
"GCC" means a version of the GNU Compiler Collection, with or without
30+
modifications, governed by version 3 (or a specified later version) of
31+
the GNU General Public License (GPL) with the option of using any
32+
subsequent versions published by the FSF.
33+
34+
"GPL-compatible Software" is software whose conditions of propagation,
35+
modification and use would permit combination with GCC in accord with
36+
the license of GCC.
37+
38+
"Target Code" refers to output from any compiler for a real or virtual
39+
target processor architecture, in executable form or suitable for
40+
input to an assembler, loader, linker and/or execution
41+
phase. Notwithstanding that, Target Code does not include data in any
42+
format that is used as a compiler intermediate representation, or used
43+
for producing a compiler intermediate representation.
44+
45+
The "Compilation Process" transforms code entirely represented in
46+
non-intermediate languages designed for human-written code, and/or in
47+
Java Virtual Machine byte code, into Target Code. Thus, for example,
48+
use of source code generators and preprocessors need not be considered
49+
part of the Compilation Process, since the Compilation Process can be
50+
understood as starting with the output of the generators or
51+
preprocessors.
52+
53+
A Compilation Process is "Eligible" if it is done using GCC, alone or
54+
with other GPL-compatible software, or if it is done without using any
55+
work based on GCC. For example, using non-GPL-compatible Software to
56+
optimize any GCC intermediate representations would not qualify as an
57+
Eligible Compilation Process.
58+
59+
1. Grant of Additional Permission.
60+
61+
You have permission to propagate a work of Target Code formed by
62+
combining the Runtime Library with Independent Modules, even if such
63+
propagation would otherwise violate the terms of GPLv3, provided that
64+
all Target Code was generated by Eligible Compilation Processes. You
65+
may then convey such a combination under terms of your choice,
66+
consistent with the licensing of the Independent Modules.
67+
68+
2. No Weakening of GCC Copyleft.
69+
70+
The availability of this Exception does not imply any general
71+
presumption that third-party software is unaffected by the copyleft
72+
requirements of the license of GCC.
73+

COPYING3

+674
Large diffs are not rendered by default.

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Analytical Engine Emulator
2+
3+
This is an Ada translation of the Java emulator at
4+
[Fourmilab](http://www.fourmilab.ch/babbage/).
5+
6+
In due course, it is hoped to create a web-based emulator (using
7+
[Gnoga](http://www.gnoga.com)). In the mean time, there is a command
8+
line based version.
9+
10+
## Copying
11+
12+
The Java source of the Fourmilab emulator is included in this
13+
repository for reference (in the <tt>java/</tt> subdirectory); the
14+
Analytical Engine code's author states _Emulator source code is
15+
intended for experienced Java developers, and is utterly
16+
unsupported. The program is in the public domain and you can do
17+
anything you like with it, but you're entirely on your own._, while
18+
<tt>BigInt.java</tt> is copyrighted by the Massachusetts Institute of
19+
Technology.
20+
21+
The Ada source is licensed under the
22+
[GNU General Public License (version 3)][] with the
23+
[GCC Runtime Library exception][].
24+
25+
[GNU General Public License (version 3)]: http://www.gnu.org/licenses/gpl.html
26+
[GCC Runtime Library exception]: http://www.gnu.org/licenses/gcc-exception-faq.html
27+
28+
## Building
29+
30+
The Ada emulator is written using [Ada2012][], and uses the
31+
[GNU Multiple Precision Arithmetic library][], via the
32+
[GMP binding in GNATCOLL][] (note, the actual binding used was that in
33+
AdaCore's GPL 2015 version, for reasons).
34+
35+
If you have the [FSF GCC 6.1.0 binary for OS X][] a suitable library
36+
is provided. GMP and GNATCOLL (at least the 2015 version) are
37+
reasonably straightforward to build.
38+
39+
[Ada2012]: http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-TOC.html
40+
41+
[GNU Multiple Precision Arithmetic library]: https://gmplib.org
42+
43+
[GMP binding in GNATCOLL]: https://github.com/AdaCore/gnatcoll/blob/master/src/gmp/gnatcoll-gmp-integers.ads
44+
45+
[FSF GCC 6.1.0 binary for OS X]: https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/6.1.0/
46+
47+
## Programming Cards
48+
49+
The implementation here is as in the
50+
[Fourmilab Java implementation][]. To date only the card types up to
51+
and including Comment Cards have been implemented.
52+
53+
As a minor change, lower case can be used: <tt>n001 42</tt> is acceptable.
54+
55+
Multiplication and division can only be indicated by the <tt>*</tt>
56+
and <tt>/</tt> symbols (× and ÷ aren't supported).
57+
58+
[Fourmilab Java implementation]: https://www.fourmilab.ch/babbage/cards.html

aes.gpr

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
with "gnatcoll_gmp";
2+
3+
project Aes is
4+
5+
for Source_Dirs use ("src");
6+
for Object_Dir use ".build";
7+
for Exec_Dir use ".";
8+
9+
for Main use ("aes.adb");
10+
11+
package Builder is
12+
for Default_Switches ("ada") use ("-g", "-O0");
13+
end Builder;
14+
15+
package Compiler is
16+
for Default_Switches ("ada") use
17+
(
18+
"-gnatwa",
19+
"-gnatqQafoy"
20+
);
21+
end Compiler;
22+
23+
package Binder is
24+
for Default_Switches ("ada") use ("-E");
25+
end Binder;
26+
27+
end Aes;

src/aes.adb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
with Ada.Exceptions;
2+
with Ada.IO_Exceptions;
3+
with Ada.Text_IO; use Ada.Text_IO;
4+
with GNAT.Command_Line;
5+
6+
with Analytical_Engine.Annunciator_Panel.Command_Line;
7+
with Analytical_Engine.Card_Reader;
8+
with Analytical_Engine.Framework;
9+
with Analytical_Engine.Output.Printer;
10+
11+
use Analytical_Engine;
12+
13+
procedure Aes is
14+
15+
Command_Line_Config : GNAT.Command_Line.Command_Line_Configuration;
16+
17+
Panel : constant Annunciator_Panel.Class_P
18+
:= new Annunciator_Panel.Command_Line.Instance;
19+
F : Framework.Instance
20+
:= Framework.Create
21+
(With_Panel => Panel,
22+
With_Output => new Output.Printer.Instance (Panel));
23+
R : constant Card_Reader.Instance_P := F.Card_Reader;
24+
25+
begin
26+
27+
GNAT.Command_Line.Set_Usage (Command_Line_Config,
28+
Usage => "card-file",
29+
Help => "Run the chain of cards");
30+
-- There are no specific switches as yet, and there's a bug in
31+
-- Getopt.
32+
-- GNAT.Command_Line.Getopt (Command_Line_Config);
33+
34+
declare
35+
Chain_File_Name : constant String := GNAT.Command_Line.Get_Argument;
36+
begin
37+
if Chain_File_Name = "" then
38+
R.Add_Cards (Ada.Text_IO.Standard_Input);
39+
else
40+
declare
41+
Chain_File : Ada.Text_IO.File_Type;
42+
begin
43+
Ada.Text_IO.Open (Chain_File,
44+
Name => Chain_File_Name,
45+
Mode => Ada.Text_IO.In_File);
46+
R.Add_Cards (Chain_File);
47+
Ada.Text_IO.Close (Chain_File);
48+
exception
49+
when E :
50+
Ada.IO_Exceptions.Name_Error | Ada.IO_Exceptions.Use_Error =>
51+
Ada.Text_IO.Put_Line
52+
(Ada.Text_IO.Standard_Error,
53+
"Couldn't open " & Ada.Exceptions.Exception_Message (E));
54+
return;
55+
end;
56+
end if;
57+
F.Run;
58+
end;
59+
end Aes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
with Ada.Text_IO; use Ada.Text_IO;
2+
package body Analytical_Engine.Annunciator_Panel.Command_Line is
3+
4+
procedure Log_Attendant_Message (Panel : Instance; Msg : String)
5+
is
6+
pragma Unreferenced (Panel);
7+
begin
8+
Put_Line (Msg);
9+
end Log_Attendant_Message;
10+
11+
procedure Log_Trace_Message (Panel : Instance; Msg : String)
12+
is
13+
pragma Unreferenced (Panel);
14+
begin
15+
Put_Line (Msg);
16+
end Log_Trace_Message;
17+
18+
procedure Initialize (This : in out Instance)
19+
is
20+
pragma Unreferenced (This);
21+
begin
22+
Put_Line ("annunciator_panel.command_line initialized");
23+
end Initialize;
24+
25+
end Analytical_Engine.Annunciator_Panel.Command_Line;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package Analytical_Engine.Annunciator_Panel.Command_Line is
2+
3+
type Instance is new Annunciator_Panel.Instance with private;
4+
5+
overriding
6+
procedure Log_Attendant_Message (Panel : Instance; Msg : String);
7+
8+
overriding
9+
procedure Log_Trace_Message (Panel : Instance; Msg : String);
10+
11+
private
12+
13+
type Instance is new Annunciator_Panel.Instance with null record;
14+
15+
overriding
16+
procedure Initialize (This : in out Instance);
17+
18+
end Analytical_Engine.Annunciator_Panel.Command_Line;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package body Analytical_Engine.Annunciator_Panel is
2+
3+
procedure Set_Tracing (This : in out Instance; To : Boolean) is
4+
begin
5+
This.Tracing := To;
6+
end Set_Tracing;
7+
8+
end Analytical_Engine.Annunciator_Panel;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
private with Ada.Finalization;
2+
package Analytical_Engine.Annunciator_Panel is
3+
4+
type Instance is abstract tagged limited private;
5+
type Class_P is access all Instance'Class;
6+
7+
procedure Log_Attendant_Message
8+
(This : Instance; Msg : String) is abstract;
9+
10+
procedure Log_Trace_Message
11+
(This : Instance; Msg : String) is abstract;
12+
13+
procedure Set_Tracing (This : in out Instance; To : Boolean);
14+
15+
function Tracing (This : Instance) return Boolean;
16+
17+
private
18+
19+
type Instance
20+
is abstract new Ada.Finalization.Limited_Controlled with record
21+
Tracing : Boolean := False;
22+
end record;
23+
24+
function Tracing (This : Instance) return Boolean is (This.Tracing);
25+
26+
end Analytical_Engine.Annunciator_Panel;

src/analytical_engine-attendant.adb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package body Analytical_Engine.Attendant is
2+
3+
procedure Initialize (This : in out Instance)
4+
is
5+
begin
6+
This.Panel.Log_Attendant_Message ("attendant initialized");
7+
end Initialize;
8+
9+
end Analytical_Engine.Attendant;

src/analytical_engine-attendant.ads

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
with Analytical_Engine.Annunciator_Panel;
2+
private with Ada.Finalization;
3+
package Analytical_Engine.Attendant is
4+
5+
type Instance (Panel : not null Annunciator_Panel.Class_P)
6+
is tagged limited private;
7+
8+
type Instance_P is access all Instance;
9+
10+
private
11+
12+
type Instance (Panel : not null Annunciator_Panel.Class_P)
13+
is new Ada.Finalization.Limited_Controlled with null record;
14+
15+
overriding
16+
procedure Initialize (This : in out Instance);
17+
18+
end Analytical_Engine.Attendant;

0 commit comments

Comments
 (0)