Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYSTEM.THISREC, SYSTEM.THISARR and SYSTEM.TYP support #104

Closed
Oleg-N-Cher opened this issue Jul 28, 2021 · 3 comments
Closed

SYSTEM.THISREC, SYSTEM.THISARR and SYSTEM.TYP support #104

Oleg-N-Cher opened this issue Jul 28, 2021 · 3 comments

Comments

@Oleg-N-Cher
Copy link
Owner

Oleg-N-Cher commented Jul 28, 2021

To prevent the introduction of dangerous code, where even this is not very clearly noticeable, in -7, - C and -3 modes were removed:

  1. Compatibility a value of any type with ARRAY OF [SYSTEM].BYTE:
PROCEDURE ReadBuf* (VAR b: ARRAY OF BYTE); (* In Oberon/Oberon-2 it is SYSTEM.BYTE *)
END ReadBuf;

PROCEDURE Read* (VAR ch: SHORTCHAR);
BEGIN
  (* Ofront/voc and ETH Oberon allow such code. BlackBox does not: *)
  ReadBuf(SYSTEM.VAL(BYTE, ch)); (* <-- err 67: actual parameter corresponding to open array is not an array *)
END Read;
  1. Compatibility of any ARRAY with ARRAY OF [SYSTEM].BYTE:
PROCEDURE Unpack (VAR d: ARRAY OF BYTE); (* In Oberon/Oberon-2 it is SYSTEM.BYTE *)
END Unpack;
  
PROCEDURE ConvertH* (VAR d: ARRAY OF SHORTCHAR); (* In Oberon/Oberon-2 it is ARRAY OF CHAR *)
BEGIN
  (* Ofront/voc and ETH Oberon allow such code. BlackBox does not: *)
  Unpack(d) (* <-- err 66: element types of actual array and formal open array differ *)
END ConvertH;

Allowing of such tricks can be justified by the fact that the BYTE type in Oberon/Oberon-2 is system, but not in Component Pascal and Oberon-07. Therefore, we should keep the ability to pass arrays of incompatible types and simple elements as arrays, but we will do it more explicitly. BlackBox suggests the undocumented functions SYSTEM.THISRECORD and SYSTEM.THISARRAY. I implemented their full support in Ofront+. I also implemented SYSTEM.TYP.

Advantages:

  • improved compatibility with BlackBox;
  • removed warnings when build the Ofront+ library.
@sgreenhill
Copy link
Collaborator

sgreenhill commented Jul 28, 2021 via email

@Oleg-N-Cher
Copy link
Owner Author

    Name            Argument types    Result type          Description

SYSTEM.TYP(T)        record type        ADRINT       type tag of record type T

SYSTEM.THISARRAY(adr: ADRINT; len: INTEGER): ARRAY OF ... - used in a list of actual parameters. Allows to pass the memory area at the address adr as array of expected type. The element type will match the required element type of the array parameter. The length of the array (the number of elements) will be len.

SYSTEM.THISRECORD(adr, type_tag: ADRINT): RECORD ... - allows to pass the memory area as record of the specified type. See example in BlackBox/System/Meta

Oleg-N-Cher added a commit that referenced this issue Jul 28, 2021
@Oleg-N-Cher
Copy link
Owner Author

Eh... I like the names THISARR / THISREC better than THISARRAY / THISRECORD. But for compatibility with BlackBox, I need to follow the second way. Although in the BlackBox itself there is ANYREC type, and not ANYRECORD.

@Oleg-N-Cher Oleg-N-Cher changed the title SYSTEM.THISRECORD, SYSTEM.THISARRAY and SYSTEM.TYP support SYSTEM.THISREC, SYSTEM.THISARR and SYSTEM.TYP support Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants