Skip to content

Commit

Permalink
Some more significant ReadMe work.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwbrown committed Jun 27, 2016
1 parent a359e16 commit b495b27
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 3,003 deletions.
69 changes: 60 additions & 9 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ orders of magnitude smaller than found in contemporary systems.
implementation of the Oberon-2 language compiler and libraries for use on
current operating systems such as Linux, BSD, Android, Mac and Windows.

The language is an evolution of the Pascal and Modula languages, following the
Vishap's Oberon Compiler (voc) uses a C backend to compile
Oberon programs under Unix or Windows. Vishap Oberon includes
libraries from the Ulm, oo2c and Ofront Oberon compilers, as well as
default libraries complying with the Oakwood Guidelines for Oberon-2 compilers.

The Oberon language is an evolution of the Pascal and Modula languages, following the
principals of Einstein and Antoine de Saint-Exupéry:

> Make it as simple as possible, but not simpler. (A. Einstein)
Expand All @@ -19,6 +24,60 @@ principals of Einstein and Antoine de Saint-Exupéry:
> when there is no longer anything to take away. (Antoine de Saint-Exupéry,
> Terre des Hommes, 1939, translated by Lewis Galantière.)
#### Installation

1. `git clone https://github.com/vishaps/voc`
2. `cd voc`
3. `[sudo] make full`

Since 'make full' will install the compiler and libraries, it needs root (unix) or administrator (windows) privileges.

Then set your path to the installed compiler binary location as reported
by make full, e.g.

| System | Set path |
| --------- | -------------------------------------- |
| Linux | `export PATH="/opt/voc/bin:$PATH"` |
| BSD | `export PATH="/usr/local/share/voc/bin:$PATH"` |
| Windows | See [Installation](/doc/Installation.md) |
| Termux | `export PATH="/data/data/com.termux/files/opt/voc/bin:$PATH"` |

Also see [Installation](/doc/Installation.md).

#### A 'Hello' application

Anything appended to Oberon.Log is automatically displayed on the console, so the
following conventional Oberon program will display 'Hello.':

MODULE hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
BEGIN
Texts.OpenWriter(W);
Texts.WriteString(W, "Hello."); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END hello.

Alternatively the Console may be accessed directly as follows:

MODULE hello;
IMPORT Console;
BEGIN
Console.String("Hello."); Console.Ln;
END hello.

Compile as follows:

voc hello.mod -m

The -m parameter tells voc that this is a main module, and to generate an
executable binary.

Execute as usual on Linux ('./hello') or Windows ('hello').


Also see [Compiling](/doc/Compiling.md).

#### Licensing

Vishap Oberon's frontend and C backend engine is a fork of Josef Templ’s Ofront, which has been released
Expand Down Expand Up @@ -65,14 +124,6 @@ Some other freely redistributable libraries are available as a part of voc distr

See [Features](/doc/Features.md).

#### Installation

See [Installation](/doc/Installation.md).

#### Compiling Oberon modules

See [Compiling](/doc/Compiling.md).

#### Porting to new platforms

See [Porting](/doc/Porting.md).
Expand Down
16 changes: 15 additions & 1 deletion doc/Features.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
The following Oberon types are independent of compiler size:

| Types | Size |
| ----- | -------|
| CHAR, SHORTINT | 8 bit |
| REAL | 32 bit |
| LONGREAL | 64 bit |

The following type sizes follow the built compiler size:

| Types | 32 bit builds | 64 bit builds |
| ----- | ------------- | ------------- |
| INTEGER | 16 bit | 32 bit |
| LONGINT, SET | 32 bit | 16 bit |

HALT/exit code has been simplified. Exit now just calls the system exit API rather than calling the kill API and passing our own process ID. For runtime errors it now displayes the appropriate error message (e.g. Index out of range).

Compilation errors now include the line number at the start of the displayed source line. The pos (character offset) is still displayed on the error message line. The error handling code was already doing some walking of the source file to find start and end of line - I changed this to walk through the source file from the start identifying line end positions, counting lines and caching the position at the start of the last error line. The resultant code is simpler, and displays the line number without losing the pos. The performance cost of walking the source file is not an issue.
Expand All @@ -6,4 +21,3 @@ Compilation errors now include the line number at the start of the displayed sou
- In his latest specs (around 2013) Wirth removed the 'COPY(a, b)' character array copy procedure, replacing it with 'b := a'. I have accordingly enabled 'b := a' in voc as an alternative to 'COPY(a, b)' (COPY is still supported.).

- Oberon code often writes to Oberon.Log expecting the text to appear on the screen. While voc has an Oberon.DumpLog procedure, I looked into making the behaviour automatic. Interestingly the voc source declares the Text notifier constants replace, insert and delete, but omits implementation of the notifier calls. The implementation turned out to be very little code, and I have used it to echo all text written to Oberon.Log to the console. This has the advantage over DumpLog that text is written immediately rather than only when DumpLog is called, and allows existing program source to work unchanged.

5 changes: 3 additions & 2 deletions doc/History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### History


#### Changes from 1.2 to 2.0

The biggest changes relative to Vishap Oberon 1.2 are in the build system and in the implementation of platform specific support. Where possible platform specific code has removed or replaced by platform agnostic code.
Expand Down Expand Up @@ -104,5 +107,3 @@ Linux is currently compiled using PlatfromUnix.Mod, but the integration of Windo

##### Issue 14 - 'separate rtl from SYSTEM?'.
OS specific code is now all in Platformxxx.Mod. Memory management (including the loaded module list) is now in Heap.Mod. SYSTEM.h is platform independent, with minimal ifdefs to allow compiling on all platforms. For example, when SYSTEM.h/SYSTEM.c need to allocate memory, or to halt, they call into Platform.Mod.


45 changes: 3 additions & 42 deletions doc/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#### Building and installation summary

1. git clone https://github.com/dcwbrown/olang
2. cd olang
3. make full
1. git clone https://github.com/vishaps/voc
2. cd voc
3. [sudo] make full

Since 'make full' will install the compiler and libraries, it needs root (unix) or administrator (windows) privileges.

Expand All @@ -24,14 +24,6 @@ Since 'make full' will install the compiler and libraries, it needs root (unix)
The size of compiler built is determined by the C compiler that runs, which is in turn determined by
the shell or command prompt configuration you are running under.

The following Oberon types are independent of compiler size:

| Types | Size |
| ----- | -------|
| CHAR, SHORTINT | 8 bit |
| REAL | 32 bit |
| LONGREAL | 64 bit |

The following type sizes follow the built compiler size:

| Types | 32 bit builds | 64 bit builds |
Expand Down Expand Up @@ -102,37 +94,6 @@ And select

More / Administrative Command Prompt

#### A 'Hello' application

Anything appended to Oberon.Log is automatically displayed on the console, so the
following conventional Oberon program will display 'Hello.':

MODULE hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
BEGIN
Texts.OpenWriter(W);
Texts.WriteString(W, "Hello."); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END hello.

Alternatively the Console may be accessed directly as follows:

MODULE hello;
IMPORT Console;
BEGIN
Console.String("Hello."); Console.Ln;
END hello.

Compile as follows:

voc hello.mod -m

The -m parameter tells voc that this is a main module, and to generate an
executable binary.

Execute as usual on Linux ('./hello') or Windows ('hello').

#### How make adapts to each platform

On all platforms other than Visual C on Windows, make runs from a bash shell,
Expand Down
107 changes: 73 additions & 34 deletions doc/Porting.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,78 @@
==how to port to a new platform==
0) generate voc.par file for the target platform(if it does not exist in src/par).
you can do it by compiling vocparam, and running it as "./vocparam > voc.par"
1) generate voc, ocat, showdef source for target platform by running
make -f makefile.gcc.<arch> port0
(or copy corresponding voc.par to the source directory yourself, remove stage2 from port0 section of the makefile, and run make port0)
2) transfer source to a target platform and write
make port1
(or use a crosscompiler)
now you have voc, showdef, and ocat binaries for your target platform
3) cp voc vocstatic
make -f makefile for your target.
that's how I've done x86 port.
voc was originally run on x86_64.

notes** in practice everything is not always simple, because you may need to edit Unix.Mod, Args.Mod and SYSTEM.h, and put them to src/lib/system/gcc/<yourtarget>, and create new makefile for your target.


==how to add a new option==

define it in OPM as a constant before defopt is defined.
define a BOOLEAN variable in OPM which will describe if setting is set.
add handling of a new option in OPM.ScanOptions
set your BOOLEAN value in OPM.OpenPari (or in ScanOptions, after the CASE) so you can check it later.
check your boolean when necessary, (see useParFile in OPM.GetOptions)
add it in OPC.GenHeaderMsg function.

==known bugs==

when using SYSTEM.LSH(s, n) where s is SET,
c compiler generates an error like
"error: duplicate 'unsigned'",
### Porting to a new platform

Porting to a new 32 or 64 bits platform is usually automatically handled
by `make full`:

- The makefile compiles `src/tools/make/configure.c` with the
platform's default C compiler.
- `configure.c` determines which types to use for 32 and 64 bit
variables, and their alignment.
- `configure.c` uses a number of strategies to determine the
operating system it is running on and what the appropriate
installation directory will be.
- `configure.c` sets makefile variables that are used to select
which of 5 sets of preprepared C source files to build to create
the bootstrap compiler.

On most systems this will be sufficient for `make full` to build
and install the compiler and libraries.

`make full` will terminate with a message such as:

`--- Branch v2docs freebsd gcc LP64 confidence tests passed ---`

#### Updating configure.c

It should only be necessary to change `configure.c` if it
cannot determine the correct install directory.

In this case add code to `src/tools/make/configure.c`'s
function `determineOS()` to set the `os` variable to the name
of the new OS platform.

The following variables are also set by `determineOS()` to the
followind defaults:

variable | set to | example
-------- | ------ | -------
`platform` | Base platform | `"unix"`
`binext` | Binary file extension | `""`
`staticlink` | Static linking option | `"-static"`

If your new platform does not support static removing, set the
`staticlink` variable to `""`.

Then modify `determineInstallDirectory()` to select the correct
instalation root based on the changes you have made to `determineOS()`.

The `platform` variable selects which variety of the Platform
module is compiled. Vishap provides two varieties, one specific
to the Windows API (`Platformwindows.Mod`), and one suitable for
Unix-like systems including Linux, BSD, Android and cygwin
(`Platformunix.Mod`).


#### How to add a new compiler option

- Define it in OPM as a constant before defopt is defined.
- Define a BOOLEAN variable in OPM which will describe if setting is set.
- Add handling of a new option in OPM.ScanOptions
- Set your BOOLEAN value in OPM.OpenPari (or in ScanOptions, after the
CASE) so you can check it later.
- Check your boolean when necessary, (see useParFile in OPM.GetOptions)
- Add it in OPC.GenHeaderMsg function.

#### Known bugs

When using SYSTEM.LSH(s, n) where s is SET,
the C compiler generates an error like
`error: duplicate 'unsigned'`,
that's because SET is defined as unsigned in SYSTEM.h,
while LSH is defined in SYSTEM.h as ((t)((unsigned t)(x)<<(n))),
while LSH is defined in SYSTEM.h as ((t)((unsigned t)(x)<<(n))),
and it makes not possible to make SYSTEM.LSH with type SET.
I don't want to prohibit it at the parser level

I don't want to prohibit it at the parser level
because C backend is only one of possible backends.

The solution currently is to cast set type to longint before lsh-ing it.
And then casting it back to set if necessary.
Loading

0 comments on commit b495b27

Please sign in to comment.