Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Unable to compare LONGREAL with <= and >= #38

Closed hectord closed 3 years ago

hectord commented 3 years ago

It seems the compiler fails to compile files which compare LONGREAL variables with ">=" and "<=".

The error I get is: no template found for GE in SYSTEM2.k

In order to reproduce the error compile this module (I use the Windows version 3.1.0 with Windows 10):

MODULE SYSTEM2;
PROCEDURE IsVeryLarge*(i: LONGREAL): BOOLEAN;
BEGIN
    RETURN i >= MAX(LONGREAL);
END IsVeryLarge;
BEGIN
END SYSTEM2.

Output:

Oxford Oberon-2 compiler version 3.1.0 [build 4dc90e11efa9]
Oxford Oberon-2 linker version 3.1.0 [build 4dc90e11efa9]
Oxford Oberon-2 runtime system version 3.1.0 [build 4dc90e11efa9]
Running C:\Program Files (x86)\Oxford Oberon-2 compiler\obc1.exe -pl -g -I "C:\Program Files (x86)\Oxford Oberon-2 compiler" SYSTEM2.mod
Running C:\Program Files (x86)\Oxford Oberon-2 compiler\oblink.exe -L "C:\Program Files (x86)\Oxford Oberon-2 compiler" SYSTEM2.k -pl -g -o C:\Users\XXX\AppData\Local\Temp\obtmp2
C:\Program Files (x86)\Oxford Oberon-2 compiler\oblink.exe: Fatal error -- no template found for GE in SYSTEM2.k
Please report bugs to https://bitbucket.org/Spivey/obc-3/issues or mike@cs.ox.ac.uk
Oxford Oberon-2 compiler driver version 3.1.0 [build 4dc90e11efa9]
*** Command returned status 2
Removing C:\Users\XXX\AppData\Local\Temp\obtmp2
Spivoxity commented 3 years ago

Thanks for the report. This affects only LONGREAL comparisons <= and >= with a Boolean result, and not conditional branches.

A typo in keiko.iset, where DLEQ expands to DCMPG, PUSH 0, LE with LE in place of LEQ -- easily fixed! As a workaround, please use

IF x >= y THEN RETURN TRUE ELSE RETURN FALSE END

This will be fixed in release 3.1.3 .

Spivoxity commented 3 years ago

In a rare burst of semi-professionalism, I also added to iset.tcl a check that all instructions used in a macro or JIT equivalent actually exist.