Some corrections
This commit is contained in:
parent
715dd4ef0f
commit
8ffaf72dfa
2 changed files with 218 additions and 110 deletions
|
@ -311,7 +311,7 @@ call name (acc, cc, apc or pc) or by the \fB\-.suffix\fP flag.
|
||||||
.IP \fIneed\fP
|
.IP \fIneed\fP
|
||||||
.br
|
.br
|
||||||
This \-~optional~\- keyword indicates that the rest of the line must be
|
This \-~optional~\- keyword indicates that the rest of the line must be
|
||||||
concatenated to the NEEDS variable.
|
concatenated to the HEAD and TAIL variables.
|
||||||
This is done once for every transformation used or indicated
|
This is done once for every transformation used or indicated
|
||||||
by one of the program call names mentioned above or indicated
|
by one of the program call names mentioned above or indicated
|
||||||
by the \fB\-.suffix\fP flag.
|
by the \fB\-.suffix\fP flag.
|
||||||
|
|
324
doc/m2ref.doc
324
doc/m2ref.doc
|
@ -15,28 +15,41 @@ The Netherlands
|
||||||
Introduction
|
Introduction
|
||||||
.PP
|
.PP
|
||||||
This document describes the implementation-specific features of the
|
This document describes the implementation-specific features of the
|
||||||
ACK Modula-2 compiler. It is not intended to teach Modula-2 programming.
|
ACK Modula-2 compiler.
|
||||||
For a description of the Modula-2 language, the reader is referred to [1].
|
It is not intended to teach Modula-2 programming.
|
||||||
|
For a description of the Modula-2 language,
|
||||||
|
the reader is referred to [1].
|
||||||
.PP
|
.PP
|
||||||
The ACK Modula-2 compiler is currently available for use with the VAX,
|
The ACK Modula-2 compiler is currently available for use with the VAX,
|
||||||
Motorola MC68020, Motorola MC68000,
|
Motorola MC68020,
|
||||||
PDP-11, and Intel 8086 code-generators.
|
Motorola MC68000,
|
||||||
For the 8086, MC68000, and MC68020,
|
PDP-11,
|
||||||
floating point emulation is used. This is made available with the \fI-fp\fP
|
and Intel 8086 code-generators.
|
||||||
option, which must be passed to \fIack\fP[4,5].
|
For the 8086,
|
||||||
|
MC68000,
|
||||||
|
and MC68020,
|
||||||
|
floating point emulation is used.
|
||||||
|
This is made available with the \fI-fp\fP
|
||||||
|
option,
|
||||||
|
which must be passed to \fIack\fP[4,5].
|
||||||
.NH
|
.NH
|
||||||
The language implemented
|
The language implemented
|
||||||
.PP
|
.PP
|
||||||
This section discusses the deviations from the Modula-2 language as described
|
This section discusses the deviations from the Modula-2 language as described
|
||||||
in the "Report on The Programming Language Modula-2", as it appeared in [1],
|
in the "Report on The Programming Language Modula-2",
|
||||||
|
as it appeared in [1],
|
||||||
from now on referred to as "the Report".
|
from now on referred to as "the Report".
|
||||||
Also, the Report sometimes leaves room for interpretation. The section numbers
|
Also,
|
||||||
|
the Report sometimes leaves room for interpretation.
|
||||||
|
The section numbers
|
||||||
mentioned are the section numbers of the Report.
|
mentioned are the section numbers of the Report.
|
||||||
.NH 2
|
.NH 2
|
||||||
Syntax (section 2)
|
Syntax (section 2)
|
||||||
.PP
|
.PP
|
||||||
The syntax recognized is that of the Report, with some extensions to
|
The syntax recognized is that of the Report,
|
||||||
also recognize the syntax of an earlier definition, given in [2].
|
with some extensions to
|
||||||
|
also recognize the syntax of an earlier definition,
|
||||||
|
given in [2].
|
||||||
Only one compilation unit per file is accepted.
|
Only one compilation unit per file is accepted.
|
||||||
.NH 2
|
.NH 2
|
||||||
Vocabulary and Representation (section 3)
|
Vocabulary and Representation (section 3)
|
||||||
|
@ -51,8 +64,10 @@ ARRAY [0 .. 0] OF CHAR
|
||||||
.DE
|
.DE
|
||||||
and contains one character: \f(CW0C\fP.
|
and contains one character: \f(CW0C\fP.
|
||||||
.PP
|
.PP
|
||||||
When the text of a comment starts with a '\f(CW$\fP', it may be a pragma.
|
When the text of a comment starts with a '\f(CW$\fP',
|
||||||
Currently, the following pragmas exist:
|
it may be a pragma.
|
||||||
|
Currently,
|
||||||
|
the following pragmas exist:
|
||||||
.DS
|
.DS
|
||||||
.ft CW
|
.ft CW
|
||||||
(*$F (F stands for Foreign) *)
|
(*$F (F stands for Foreign) *)
|
||||||
|
@ -64,52 +79,81 @@ Currently, the following pragmas exist:
|
||||||
The Foreign pragma is only meaningful in a \f(CWDEFINITION MODULE\fP,
|
The Foreign pragma is only meaningful in a \f(CWDEFINITION MODULE\fP,
|
||||||
and indicates that this
|
and indicates that this
|
||||||
\f(CWDEFINITION MODULE\fP describes an interface to a module written in another
|
\f(CWDEFINITION MODULE\fP describes an interface to a module written in another
|
||||||
language (for instance C, Pascal, or EM).
|
language (for instance C,
|
||||||
|
Pascal,
|
||||||
|
or EM).
|
||||||
Runtime checks that can be disabled are:
|
Runtime checks that can be disabled are:
|
||||||
range checks,
|
range checks,
|
||||||
\f(CWCARDINAL\fP overflow checks,
|
\f(CWCARDINAL\fP overflow checks,
|
||||||
checks when assigning a \f(CWCARDINAL\fP to an \f(CWINTEGER\fP and vice versa,
|
checks when assigning a \f(CWCARDINAL\fP to an \f(CWINTEGER\fP and vice versa,
|
||||||
and checks that \f(CWFOR\fP-loop control-variables are not changed
|
and checks that \f(CWFOR\fP-loop control-variables are not changed
|
||||||
in the body of the loop.
|
in the body of the loop.
|
||||||
Array bound checks can be enabled, because many EM implementations do not
|
Array bound checks can be enabled,
|
||||||
|
because many EM implementations do not
|
||||||
implement the array bound checking of the EM array instructions.
|
implement the array bound checking of the EM array instructions.
|
||||||
When enabled, the compiler generates a check before generating an
|
When enabled,
|
||||||
|
the compiler generates a check before generating an
|
||||||
EM array instruction.
|
EM array instruction.
|
||||||
Even when underscores are enabled, they still may not start an identifier.
|
Even when underscores are enabled,
|
||||||
|
they still may not start an identifier.
|
||||||
.PP
|
.PP
|
||||||
Constants of type \f(CWLONGINT\fP are integers with a suffix letter \f(CWD\fP
|
Constants of type \f(CWLONGINT\fP are integers with a suffix letter \f(CWD\fP
|
||||||
(for instance \f(CW1987D\fP).
|
(for instance \f(CW1987D\fP).
|
||||||
Constants of type \f(CWLONGREAL\fP have suffix \f(CWD\fP if a scale factor is missing,
|
Constants of type \f(CWLONGREAL\fP have suffix \f(CWD\fP if a scale factor is missing,
|
||||||
or have \f(CWD\fP in place of \f(CWE\fP in the scale factor (f.i. \f(CW1.0D\fP,
|
or have \f(CWD\fP in place of \f(CWE\fP in the scale factor (f.i. \f(CW1.0D\fP,
|
||||||
\f(CW0.314D1\fP).
|
\f(CW0.314D1\fP).
|
||||||
This addition was made, because there was no way to indicate long constants,
|
This addition was made,
|
||||||
|
because there was no way to indicate long constants,
|
||||||
and also because the addition was made in Wirth's newest Modula-2 compiler.
|
and also because the addition was made in Wirth's newest Modula-2 compiler.
|
||||||
.NH 2
|
.NH 2
|
||||||
Declarations and scope rules (section 4)
|
Declarations and scope rules (section 4)
|
||||||
.PP
|
.PP
|
||||||
Standard identifiers are considered to be predeclared, and valid in all
|
Standard identifiers are considered to be predeclared,
|
||||||
parts of a program. They are called \fIpervasive\fP.
|
and valid in all
|
||||||
Unfortunately, the Report does not state how this pervasiveness is accomplished.
|
parts of a program.
|
||||||
However, page 87 of [1] states: "Standard identifiers are automatically
|
They are called \fIpervasive\fP.
|
||||||
imported into all modules". Our implementation therefore allows
|
Unfortunately,
|
||||||
redeclarations of standard identifiers within procedures, but not within
|
the Report does not state how this pervasiveness is accomplished.
|
||||||
|
However,
|
||||||
|
page 87 of [1] states: "Standard identifiers are automatically
|
||||||
|
imported into all modules".
|
||||||
|
Our implementation therefore allows
|
||||||
|
redeclarations of standard identifiers within procedures,
|
||||||
|
but not within
|
||||||
modules.
|
modules.
|
||||||
.NH 2
|
.NH 2
|
||||||
Constant expressions (section 5)
|
Constant expressions (section 5)
|
||||||
.PP
|
.PP
|
||||||
Each operand of a constant expression must be a constant:
|
Each operand of a constant expression must be a constant:
|
||||||
a string, a number, a set, an enumeration literal, a qualifier denoting a
|
a string,
|
||||||
constant expression, a typetransfer with a constant argument, or
|
a number,
|
||||||
one of the standard procedures
|
a set,
|
||||||
\f(CWABS\fP, \f(CWCAP\fP, \f(CWCHR\fP, \f(CWLONG\fP, \f(CWMAX\fP, \f(CWMIN\fP,
|
an enumeration literal,
|
||||||
\f(CWODD\fP, \f(CWORD\fP,
|
a qualifier denoting a
|
||||||
\f(CWSIZE\fP, \f(CWSHORT\fP, \f(CWTSIZE\fP, or \f(CWVAL\fP, with constant argument(s);
|
constant expression,
|
||||||
|
a type transfer with a constant argument,
|
||||||
|
or one of the standard procedures
|
||||||
|
\f(CWABS\fP,
|
||||||
|
\f(CWCAP\fP,
|
||||||
|
\f(CWCHR\fP,
|
||||||
|
\f(CWLONG\fP,
|
||||||
|
\f(CWMAX\fP,
|
||||||
|
\f(CWMIN\fP,
|
||||||
|
\f(CWODD\fP,
|
||||||
|
\f(CWORD\fP,
|
||||||
|
\f(CWSIZE\fP,
|
||||||
|
\f(CWSHORT\fP,
|
||||||
|
\f(CWTSIZE\fP,
|
||||||
|
or \f(CWVAL\fP,
|
||||||
|
with constant argument(s);
|
||||||
\f(CWTSIZE\fP and \f(CWSIZE\fP may also have a variable as argument.
|
\f(CWTSIZE\fP and \f(CWSIZE\fP may also have a variable as argument.
|
||||||
.PP
|
.PP
|
||||||
Floating point expressions are never evaluated compile time, because
|
Floating point expressions are never evaluated compile time,
|
||||||
the compiler basically functions as a cross-compiler, and thus cannot
|
because the compiler basically functions as a cross-compiler,
|
||||||
|
and thus cannot
|
||||||
use the floating point instructions of the machine on which it runs.
|
use the floating point instructions of the machine on which it runs.
|
||||||
Also, \f(CWMAX(REAL)\fP and \f(CWMIN(REAL)\fP are not allowed.
|
Also,
|
||||||
|
\f(CWMAX(REAL)\fP and \f(CWMIN(REAL)\fP are not allowed.
|
||||||
.NH 2
|
.NH 2
|
||||||
Type declarations (section 6)
|
Type declarations (section 6)
|
||||||
.NH 3
|
.NH 3
|
||||||
|
@ -117,7 +161,8 @@ Basic types (section 6.1)
|
||||||
.PP
|
.PP
|
||||||
The type \f(CWCHAR\fP includes the ASCII character set as a subset.
|
The type \f(CWCHAR\fP includes the ASCII character set as a subset.
|
||||||
Values range from
|
Values range from
|
||||||
\f(CW0C\fP to \f(CW377C\fP, not from \f(CW0C\fP to \f(CW177C\fP.
|
\f(CW0C\fP to \f(CW377C\fP,
|
||||||
|
not from \f(CW0C\fP to \f(CW177C\fP.
|
||||||
.NH 3
|
.NH 3
|
||||||
Enumerations (section 6.2)
|
Enumerations (section 6.2)
|
||||||
.PP
|
.PP
|
||||||
|
@ -127,16 +172,22 @@ is \f(CWMAX(INTEGER)\fP.
|
||||||
Record types (section 6.5)
|
Record types (section 6.5)
|
||||||
.PP
|
.PP
|
||||||
The syntax of variant sections in [1] is different from the one in [2].
|
The syntax of variant sections in [1] is different from the one in [2].
|
||||||
Our implementation recognizes both, giving a warning for the older one.
|
Our implementation recognizes both,
|
||||||
However, see section 3.
|
giving a warning for the older one.
|
||||||
|
However,
|
||||||
|
see section 3.
|
||||||
.NH 3
|
.NH 3
|
||||||
Set types (section 6.6)
|
Set types (section 6.6)
|
||||||
.PP
|
.PP
|
||||||
The only limitation imposed by the compiler is that the base type of the
|
The only limitation imposed by the compiler is that the base type of the
|
||||||
set must be a subrange type, an enumeration type, \f(CWCHAR\fP, or
|
set must be a subrange type,
|
||||||
\f(CWBOOLEAN\fP.
|
an enumeration type,
|
||||||
So, the lower bound may be negative.
|
\f(CWCHAR\fP,
|
||||||
However, if a negative lower bound is used,
|
or \f(CWBOOLEAN\fP.
|
||||||
|
So,
|
||||||
|
the lower bound may be negative.
|
||||||
|
However,
|
||||||
|
if a negative lower bound is used,
|
||||||
the compiler gives a warning of the \fIrestricted\fP class (see the manual
|
the compiler gives a warning of the \fIrestricted\fP class (see the manual
|
||||||
page of the compiler).
|
page of the compiler).
|
||||||
.PP
|
.PP
|
||||||
|
@ -173,26 +224,30 @@ or
|
||||||
(-1) + 1
|
(-1) + 1
|
||||||
.ft P
|
.ft P
|
||||||
.DE
|
.DE
|
||||||
I have seen some compilers that implement the first alternative, and others
|
I have seen some compilers that implement the first alternative,
|
||||||
that implement the second. Our compiler implements the second, which is
|
and others that implement the second.
|
||||||
suggested by the fact that their priority is not specified, which might
|
Our compiler implements the second,
|
||||||
indicate that it is the same as that of their binary counterparts.
|
which is suggested by the fact that their priority is not specified,
|
||||||
|
which might indicate that it is the same as that of their binary counterparts.
|
||||||
And then the rule about left to right decides for the second.
|
And then the rule about left to right decides for the second.
|
||||||
On the other hand, one might argue that, since the grammar only allows
|
On the other hand one might argue that,
|
||||||
for one unary operator in a simple expression, it must apply to the
|
since the grammar only allows for one unary operator in a simple expression,
|
||||||
whole simple expression, not just the first term.
|
it must apply to the whole simple expression,
|
||||||
|
not just the first term.
|
||||||
.NH 2
|
.NH 2
|
||||||
Statements (section 9)
|
Statements (section 9)
|
||||||
.NH 3
|
.NH 3
|
||||||
Assignments (section 9.1)
|
Assignments (section 9.1)
|
||||||
.PP
|
.PP
|
||||||
The Report does not define the evaluation order in an assignment.
|
The Report does not define the evaluation order in an assignment.
|
||||||
Our compiler certainly chooses an evaluation order, but it is explicitly
|
Our compiler certainly chooses an evaluation order,
|
||||||
left undefined. Therefore, programs that depend on it, may cease to
|
but it is explicitly left undefined.
|
||||||
work later.
|
Therefore,
|
||||||
|
programs that depend on it may cease to work later.
|
||||||
.PP
|
.PP
|
||||||
The types \f(CWINTEGER\fP and \f(CWCARDINAL\fP are assignment-compatible with
|
The types \f(CWINTEGER\fP and \f(CWCARDINAL\fP are assignment-compatible with
|
||||||
\f(CWLONGINT\fP, and \f(CWREAL\fP is assignment-compatible with \f(CWLONGREAL\fP.
|
\f(CWLONGINT\fP,
|
||||||
|
and \f(CWREAL\fP is assignment-compatible with \f(CWLONGREAL\fP.
|
||||||
.NH 3
|
.NH 3
|
||||||
Case statements (section 9.5)
|
Case statements (section 9.5)
|
||||||
.PP
|
.PP
|
||||||
|
@ -200,14 +255,17 @@ The size of the type of the case-expression must be less than or equal to
|
||||||
the word-size.
|
the word-size.
|
||||||
.PP
|
.PP
|
||||||
The Report does not specify what happens if the value of the case-expression
|
The Report does not specify what happens if the value of the case-expression
|
||||||
does not occur as a label of any case, and there is no \f(CWELSE\fP-part.
|
does not occur as a label of any case,
|
||||||
In our implementation, this results in a runtime error.
|
and there is no \f(CWELSE\fP-part.
|
||||||
|
In our implementation,
|
||||||
|
this results in a runtime error.
|
||||||
.NH 3
|
.NH 3
|
||||||
For statements (section 9.8)
|
For statements (section 9.8)
|
||||||
.PP
|
.PP
|
||||||
The Report does not specify the legal types for a control variable.
|
The Report does not specify the legal types for a control variable.
|
||||||
Our implementation allows the basic types (except \f(CWREAL\fP),
|
Our implementation allows the basic types (except \f(CWREAL\fP),
|
||||||
enumeration types, and subranges.
|
enumeration types,
|
||||||
|
and subranges.
|
||||||
A runtime warning is generated when the value of the control variable
|
A runtime warning is generated when the value of the control variable
|
||||||
is changed by the statement sequence that forms the body of the loop,
|
is changed by the statement sequence that forms the body of the loop,
|
||||||
unless runtime checking is disabled.
|
unless runtime checking is disabled.
|
||||||
|
@ -219,82 +277,105 @@ Our implementation allows any result type.
|
||||||
.NH 2
|
.NH 2
|
||||||
Procedure declarations (section 10)
|
Procedure declarations (section 10)
|
||||||
.PP
|
.PP
|
||||||
Function procedures must exit through a RETURN statement, or a runtime error
|
Function procedures must exit through a RETURN statement,
|
||||||
occurs.
|
or a runtime error occurs.
|
||||||
.NH 3
|
.NH 3
|
||||||
Standard procedures (section 10.2)
|
Standard procedures (section 10.2)
|
||||||
.PP
|
.PP
|
||||||
Our implementation supports \f(CWNEW\fP and \f(CWDISPOSE\fP
|
Our implementation supports \f(CWNEW\fP and \f(CWDISPOSE\fP
|
||||||
for backwards compatibility,
|
for backwards compatibility,
|
||||||
but issues warnings for their use. However, see section 3.
|
but issues warnings for their use.
|
||||||
|
However,
|
||||||
|
see section 3.
|
||||||
.PP
|
.PP
|
||||||
Also, some new standard procedures were added, similar to the new standard
|
Also,
|
||||||
procedures in Wirth's newest compiler:
|
some new standard procedures were added,
|
||||||
|
similar to the new standard procedures in Wirth's newest compiler:
|
||||||
.IP \-
|
.IP \-
|
||||||
\f(CWLONG\fP converts an argument of type \f(CWINTEGER\fP or \f(CWREAL\fP to the
|
\f(CWLONG\fP converts an argument of type \f(CWINTEGER\fP or \f(CWREAL\fP to the
|
||||||
types \f(CWLONGINT\fP or \f(CWLONGREAL\fP.
|
types \f(CWLONGINT\fP or \f(CWLONGREAL\fP.
|
||||||
.IP \-
|
.IP \-
|
||||||
\f(CWSHORT\fP performs the inverse transformation, without range checks.
|
\f(CWSHORT\fP performs the inverse transformation,
|
||||||
|
without range checks.
|
||||||
.IP \-
|
.IP \-
|
||||||
\f(CWFLOATD\fP is analogous to \f(CWFLOAT\fP, but yields a result of type
|
\f(CWFLOATD\fP is analogous to \f(CWFLOAT\fP,
|
||||||
|
but yields a result of type
|
||||||
\f(CWLONGREAL\fP.
|
\f(CWLONGREAL\fP.
|
||||||
.IP \-
|
.IP \-
|
||||||
\f(CWTRUNCD\fP is analogous to \f(CWTRUNC\fP, but yields a result of type
|
\f(CWTRUNCD\fP is analogous to \f(CWTRUNC\fP,
|
||||||
|
but yields a result of type
|
||||||
\f(CWLONGINT\fP.
|
\f(CWLONGINT\fP.
|
||||||
.NH 2
|
.NH 2
|
||||||
System-dependent facilities (section 12)
|
System-dependent facilities (section 12)
|
||||||
.PP
|
.PP
|
||||||
The type \f(CWBYTE\fP is added to the \f(CWSYSTEM\fP module.
|
The type \f(CWBYTE\fP is added to the \f(CWSYSTEM\fP module.
|
||||||
It occupies a storage unit of 8 bits.
|
It occupies a storage unit of 8 bits.
|
||||||
\f(CWARRAY OF BYTE\fP has a similar effect to \f(CWARRAY OF WORD\fP, but is
|
\f(CWARRAY OF BYTE\fP has a similar effect to \f(CWARRAY OF WORD\fP,
|
||||||
safer. In some obscure cases the \f(CWARRAY OF WORD\fP mechanism does not quite
|
but is safer.
|
||||||
|
In some obscure cases the \f(CWARRAY OF WORD\fP mechanism does not quite
|
||||||
work properly.
|
work properly.
|
||||||
.PP
|
.PP
|
||||||
The procedure \f(CWIOTRANSFER\fP is not implemented.
|
The procedure \f(CWIOTRANSFER\fP is not implemented.
|
||||||
.NH 1
|
.NH 1
|
||||||
Backwards compatibility
|
Backwards compatibility
|
||||||
.PP
|
.PP
|
||||||
Besides recognizing the language as described in [1], the compiler recognizes
|
Besides recognizing the language as described in [1],
|
||||||
most of the language described in [2], for backwards compatibility.
|
the compiler recognizes most of the language described in [2],
|
||||||
|
for backwards compatibility.
|
||||||
It warns the user for old-fashioned
|
It warns the user for old-fashioned
|
||||||
constructions (constructions that [1] does not allow).
|
constructions (constructions that [1] does not allow).
|
||||||
If the \fI-Rm2-3\fP option (see [6]) is passed to \fIack\fP, this backwards
|
If the \fI-Rm2-3\fP option (see [6]) is passed to \fIack\fP,
|
||||||
compatibility feature is disabled. Also, it may not be present on some
|
this backwards compatibility feature is disabled.
|
||||||
smaller machines, like the PDP-11.
|
Also,
|
||||||
|
it may not be present on some
|
||||||
|
smaller machines,
|
||||||
|
like the PDP-11.
|
||||||
.NH 1
|
.NH 1
|
||||||
Compile time errors
|
Compile time errors
|
||||||
.PP
|
.PP
|
||||||
The compile time error messages are intended to be self-explanatory,
|
The compile time error messages are intended to be self-explanatory,
|
||||||
and not listed here. The compiler also sometimes issues warnings,
|
and not listed here.
|
||||||
|
The compiler also sometimes issues warnings,
|
||||||
recognizable by a warning-classification between parentheses.
|
recognizable by a warning-classification between parentheses.
|
||||||
Currently, there are 3 classifications:
|
Currently,
|
||||||
|
there are 3 classifications:
|
||||||
.IP "(old-fashioned use)"
|
.IP "(old-fashioned use)"
|
||||||
.br
|
.br
|
||||||
These warnings are given on constructions that are not allowed by [1], but are
|
These warnings are given on constructions that are not allowed by [1],
|
||||||
allowed by [2].
|
but are allowed by [2].
|
||||||
.IP (strict)
|
.IP (strict)
|
||||||
.br
|
.br
|
||||||
These warnings are given on constructions that are supported by the
|
These warnings are given on constructions that are supported by the
|
||||||
ACK Modula-2 compiler, but might not be supported by others.
|
ACK Modula-2 compiler,
|
||||||
Examples: functions returning structured types, SET types of subranges with
|
but might not be supported by others.
|
||||||
|
Examples: functions returning structured types,
|
||||||
|
SET types of subranges with
|
||||||
negative lower bound.
|
negative lower bound.
|
||||||
.IP (warning)
|
.IP (warning)
|
||||||
.br
|
.br
|
||||||
The other warnings, such as warnings about variables that are never assigned,
|
The other warnings,
|
||||||
never used, etc.
|
such as warnings about variables that are never assigned,
|
||||||
|
never used,
|
||||||
|
etc.
|
||||||
.NH 1
|
.NH 1
|
||||||
Runtime errors
|
Runtime errors
|
||||||
.PP
|
.PP
|
||||||
The ACK Modula-2 compiler produces code for an EM machine as defined in [3].
|
The ACK Modula-2 compiler produces code for an EM machine as defined in [3].
|
||||||
Therefore, it depends on the implementation
|
Therefore,
|
||||||
|
it depends on the implementation
|
||||||
of the EM machine for detection some of the runtime errors that could occur.
|
of the EM machine for detection some of the runtime errors that could occur.
|
||||||
.PP
|
.PP
|
||||||
The \fITraps\fP module enables the user to install his own runtime
|
The \fITraps\fP module enables the user to install his own runtime
|
||||||
error handler.
|
error handler.
|
||||||
The default one just displays what happened and exits.
|
The default one just displays what happened and exits.
|
||||||
Basically, a trap handler is just a procedure that takes an INTEGER as
|
Basically,
|
||||||
parameter. The INTEGER is the trap number. This INTEGER can be one of the
|
a trap handler is just a procedure that takes an INTEGER as
|
||||||
EM trap numbers, listed in [3], or one of the numbers listed in the
|
parameter.
|
||||||
|
The INTEGER is the trap number.
|
||||||
|
This INTEGER can be one of the
|
||||||
|
EM trap numbers,
|
||||||
|
listed in [3],
|
||||||
|
or one of the numbers listed in the
|
||||||
\fITraps\fP definition module.
|
\fITraps\fP definition module.
|
||||||
.PP
|
.PP
|
||||||
The following runtime errors may occur:
|
The following runtime errors may occur:
|
||||||
|
@ -303,7 +384,8 @@ The following runtime errors may occur:
|
||||||
The detection of this error depends on the EM implementation.
|
The detection of this error depends on the EM implementation.
|
||||||
.IP "range bound error"
|
.IP "range bound error"
|
||||||
.br
|
.br
|
||||||
Range bound errors are always detected, unless runtime checks are disabled.
|
Range bound errors are always detected,
|
||||||
|
unless runtime checks are disabled.
|
||||||
.IP "set bound error"
|
.IP "set bound error"
|
||||||
.br
|
.br
|
||||||
The detection of this error depends on the EM implementation.
|
The detection of this error depends on the EM implementation.
|
||||||
|
@ -313,10 +395,12 @@ The current implementations detect this error.
|
||||||
The detection of this error depends on the EM implementation.
|
The detection of this error depends on the EM implementation.
|
||||||
.IP "cardinal overflow"
|
.IP "cardinal overflow"
|
||||||
.br
|
.br
|
||||||
This error is detected, unless runtime checks are disabled.
|
This error is detected,
|
||||||
|
unless runtime checks are disabled.
|
||||||
.IP "cardinal underflow"
|
.IP "cardinal underflow"
|
||||||
.br
|
.br
|
||||||
This error is detected, unless runtime checks are disabled.
|
This error is detected,
|
||||||
|
unless runtime checks are disabled.
|
||||||
.IP "real overflow"
|
.IP "real overflow"
|
||||||
.br
|
.br
|
||||||
The detection of this error depends on the EM implementation.
|
The detection of this error depends on the EM implementation.
|
||||||
|
@ -339,9 +423,10 @@ The detection of this error depends on the EM implementation.
|
||||||
.br
|
.br
|
||||||
This error occurs when assigning a negative value of type INTEGER to a
|
This error occurs when assigning a negative value of type INTEGER to a
|
||||||
variable of type CARDINAL,
|
variable of type CARDINAL,
|
||||||
or when assigning a value of CARDINAL, that is > MAX(INTEGER), to a
|
or when assigning a value of CARDINAL that is > MAX(INTEGER),
|
||||||
variable of type INTEGER.
|
to a variable of type INTEGER.
|
||||||
It is detected, unless runtime checking is disabled.
|
It is detected,
|
||||||
|
unless runtime checking is disabled.
|
||||||
.IP "stack overflow"
|
.IP "stack overflow"
|
||||||
.br
|
.br
|
||||||
The detection of this error depends on the EM implementation.
|
The detection of this error depends on the EM implementation.
|
||||||
|
@ -358,17 +443,22 @@ All current EM implementations detect this error.
|
||||||
.IP "stack size of process too large"
|
.IP "stack size of process too large"
|
||||||
.br
|
.br
|
||||||
This is most likely to happen if the reserved space for a coroutine stack
|
This is most likely to happen if the reserved space for a coroutine stack
|
||||||
is too small. In this case, increase the size of the area given to
|
is too small.
|
||||||
\fCWNEWPROCESS\fP. It can also happen if the stack needed for the main
|
In this case,
|
||||||
process is too large and there are coroutines. In this case, the only fix is
|
increase the size of the area given to
|
||||||
to reduce the stack size needed by the main process, f.i. by avoiding local
|
\f(CWNEWPROCESS\fP.
|
||||||
arrays.
|
It can also happen if the stack needed for the main
|
||||||
|
process is too large and there are coroutines.
|
||||||
|
In this case,
|
||||||
|
the only fix is to reduce the stack size needed by the main process,
|
||||||
|
f.i. by avoiding local arrays.
|
||||||
.IP "too many nested traps + handlers"
|
.IP "too many nested traps + handlers"
|
||||||
.br
|
.br
|
||||||
This error can only occur when the user has installed his own trap handler.
|
This error can only occur when the user has installed his own trap handler.
|
||||||
It means that during execution of the trap handler another trap has occurred,
|
It means that during execution of the trap handler another trap has occurred,
|
||||||
and that several times.
|
and that several times.
|
||||||
In some cases, this is an error because of overflow of some internal tables.
|
In some cases,
|
||||||
|
this is an error because of overflow of some internal tables.
|
||||||
.IP "no RETURN from function procedure"
|
.IP "no RETURN from function procedure"
|
||||||
.br
|
.br
|
||||||
This error occurs when a function procedure does not return properly
|
This error occurs when a function procedure does not return properly
|
||||||
|
@ -378,35 +468,53 @@ This error occurs when a function procedure does not return properly
|
||||||
This error might occur when you use floating point operations on an
|
This error might occur when you use floating point operations on an
|
||||||
implementation that does not have floating point.
|
implementation that does not have floating point.
|
||||||
.PP
|
.PP
|
||||||
In addition, some of the library modules may give error messages.
|
In addition,
|
||||||
|
some of the library modules may give error messages.
|
||||||
The \fBTraps\fP-module has a suitable mechanism for this.
|
The \fBTraps\fP-module has a suitable mechanism for this.
|
||||||
.NH 1
|
.NH 1
|
||||||
Calling the compiler
|
Calling the compiler
|
||||||
.PP
|
.PP
|
||||||
See [4,5,6] for a detailed explanation.
|
See [4,5,6] for a detailed explanation.
|
||||||
.PP
|
.PP
|
||||||
Ths compiler itself has no version checking mechanism. A special linker
|
The compiler itself has no version checking mechanism.
|
||||||
would be needed to do that. Therefore, a makefile generator is included [7].
|
A special linker
|
||||||
|
would be needed to do that.
|
||||||
|
Therefore,
|
||||||
|
a makefile generator is included [7].
|
||||||
.NH 1
|
.NH 1
|
||||||
The procedure call interface
|
The procedure call interface
|
||||||
.PP
|
.PP
|
||||||
Parameters are pushed on the stack in reversed order, so that the EM AB
|
Parameters are pushed on the stack in reversed order,
|
||||||
|
so that the EM AB
|
||||||
(argument base) register indicates the first parameter.
|
(argument base) register indicates the first parameter.
|
||||||
For VAR parameters, its address is passed, for value parameters its value.
|
For VAR parameters,
|
||||||
|
its address is passed,
|
||||||
|
for value parameters its value.
|
||||||
The only exception to this rule is with conformant arrays.
|
The only exception to this rule is with conformant arrays.
|
||||||
For conformant arrays, the address is passed, and an array descriptor is
|
For conformant arrays,
|
||||||
passed. The descriptor is an EM array descriptor. It consists of three
|
the address is passed,
|
||||||
fields: the lower bound (always 0), upper bound - lower bound, and the
|
and an array descriptor is
|
||||||
size of the elements.
|
passed.
|
||||||
|
The descriptor is an EM array descriptor.
|
||||||
|
It consists of three
|
||||||
|
fields: the lower bound (always 0),
|
||||||
|
upper bound - lower bound,
|
||||||
|
and the size of the elements.
|
||||||
The descriptor is pushed first.
|
The descriptor is pushed first.
|
||||||
If the parameter is a value parameter, the called routine must make sure
|
If the parameter is a value parameter,
|
||||||
that its value is never changed, for instance by making its own copy
|
the called routine must make sure
|
||||||
of the array. The Modula-2 compiler does exactly this.
|
that its value is never changed,
|
||||||
|
for instance by making its own copy
|
||||||
|
of the array.
|
||||||
|
The Modula-2 compiler does exactly this.
|
||||||
.PP
|
.PP
|
||||||
When the size of the return value of a function procedure is larger than
|
When the size of the return value of a function procedure is larger than
|
||||||
the maximum of \fCWSIZE(LONGREAL)\fP and twice the pointer-size, the caller
|
the maximum of \f(CWSIZE(LONGREAL)\fP and twice the pointer-size,
|
||||||
reserves this space on the stack, above the parameters. Callee then stores
|
the caller reserves this space on the stack,
|
||||||
its result there, and returns no other value.
|
above the parameters.
|
||||||
|
Callee then stores
|
||||||
|
its result there,
|
||||||
|
and returns no other value.
|
||||||
.NH 1
|
.NH 1
|
||||||
References
|
References
|
||||||
.IP [1]
|
.IP [1]
|
||||||
|
|
Loading…
Reference in a new issue