|
@@ -357,6 +357,22 @@ PROCEDURE EnterPending (name: ARRAY OF CHAR; kind: INTEGER): BOOLEAN;
|
|
|
RETURN node # NIL
|
|
RETURN node # NIL
|
|
|
END EnterPending;
|
|
END EnterPending;
|
|
|
|
|
|
|
|
|
|
+PROCEDURE ArrayShapeOk (actual, formal: TypeIndex): BOOLEAN;
|
|
|
|
|
+(* TRUE when two array types have the same rank and the same leaf type,
|
|
|
|
|
+ allowing fixed levels to match open levels at any position. Used for
|
|
|
|
|
+ open-array parameter compatibility (M3). *)
|
|
|
|
|
+ VAR a, f: TypeIndex; n: CARDINAL;
|
|
|
|
|
+ BEGIN
|
|
|
|
|
+ IF (ClassOf(actual) # ClArray) OR (ClassOf(formal) # ClArray) THEN
|
|
|
|
|
+ RETURN FALSE
|
|
|
|
|
+ END;
|
|
|
|
|
+ a := actual; f := formal; n := 0;
|
|
|
|
|
+ WHILE (ClassOf(a) = ClArray) AND (ClassOf(f) = ClArray) DO
|
|
|
|
|
+ a := ArrayElem(a); f := ArrayElem(f); INC(n)
|
|
|
|
|
+ END;
|
|
|
|
|
+ RETURN (n > 0) AND SameType(a, f)
|
|
|
|
|
+ END ArrayShapeOk;
|
|
|
|
|
+
|
|
|
PROCEDURE VarParamOk (actual, formal: TypeIndex): BOOLEAN;
|
|
PROCEDURE VarParamOk (actual, formal: TypeIndex): BOOLEAN;
|
|
|
(* Addressable-designator compatibility for VAR formals: same type,
|
|
(* Addressable-designator compatibility for VAR formals: same type,
|
|
|
or fixed array into open array with same element type, or string
|
|
or fixed array into open array with same element type, or string
|
|
@@ -375,10 +391,13 @@ PROCEDURE VarParamOk (actual, formal: TypeIndex): BOOLEAN;
|
|
|
IF (actual = dAddr) AND (ClassOf(formal) = ClPtr) THEN
|
|
IF (actual = dAddr) AND (ClassOf(formal) = ClPtr) THEN
|
|
|
RETURN TRUE
|
|
RETURN TRUE
|
|
|
END;
|
|
END;
|
|
|
- IF IsOpenArray(formal)
|
|
|
|
|
- AND (ClassOf(actual) = ClArray) AND (ArrayDepth(actual) = 1) THEN
|
|
|
|
|
- fa := ArrayElem(actual); fe := ArrayElem(formal);
|
|
|
|
|
- IF SameType(fa, fe) THEN RETURN TRUE END
|
|
|
|
|
|
|
+ IF IsOpenArray(formal) AND (ClassOf(actual) = ClArray) THEN
|
|
|
|
|
+ IF IsByteBuf(formal) THEN RETURN TRUE END;
|
|
|
|
|
+ IF ArrayShapeOk(actual, formal) THEN RETURN TRUE END;
|
|
|
|
|
+ IF ArrayDepth(actual) = 1 THEN
|
|
|
|
|
+ fa := ArrayElem(actual); fe := ArrayElem(formal);
|
|
|
|
|
+ IF SameType(fa, fe) THEN RETURN TRUE END
|
|
|
|
|
+ END
|
|
|
END;
|
|
END;
|
|
|
IF IsOpenArray(formal) AND (ClassOf(actual) = ClStr) THEN
|
|
IF IsOpenArray(formal) AND (ClassOf(actual) = ClStr) THEN
|
|
|
fe := ArrayElem(formal);
|
|
fe := ArrayElem(formal);
|
|
@@ -424,11 +443,11 @@ PROCEDURE ParamTypesOk (x, y: TypeIndex): BOOLEAN;
|
|
|
BEGIN
|
|
BEGIN
|
|
|
IF SameType(x, y) THEN RETURN TRUE END;
|
|
IF SameType(x, y) THEN RETURN TRUE END;
|
|
|
IF (x = InvalidType) OR (y = InvalidType) THEN RETURN TRUE END;
|
|
IF (x = InvalidType) OR (y = InvalidType) THEN RETURN TRUE END;
|
|
|
- IF IsOpenArray(x) AND (ClassOf(y) = ClArray) AND (ArrayDepth(y) = 1) THEN
|
|
|
|
|
- RETURN SameType(ArrayElem(x), ArrayElem(y))
|
|
|
|
|
|
|
+ IF IsOpenArray(x) AND (ClassOf(y) = ClArray) THEN
|
|
|
|
|
+ RETURN ArrayShapeOk(y, x)
|
|
|
END;
|
|
END;
|
|
|
- IF IsOpenArray(y) AND (ClassOf(x) = ClArray) AND (ArrayDepth(x) = 1) THEN
|
|
|
|
|
- RETURN SameType(ArrayElem(x), ArrayElem(y))
|
|
|
|
|
|
|
+ IF IsOpenArray(y) AND (ClassOf(x) = ClArray) THEN
|
|
|
|
|
+ RETURN ArrayShapeOk(x, y)
|
|
|
END;
|
|
END;
|
|
|
RETURN FALSE
|
|
RETURN FALSE
|
|
|
END ParamTypesOk;
|
|
END ParamTypesOk;
|
|
@@ -474,7 +493,7 @@ PROCEDURE FormalOk (a, b: TypeIndex): BOOLEAN;
|
|
|
descriptor, so a DEFINITION/IMPLEMENTATION pair never shares the
|
|
descriptor, so a DEFINITION/IMPLEMENTATION pair never shares the
|
|
|
type index and SameType would otherwise reject it. *)
|
|
type index and SameType would otherwise reject it. *)
|
|
|
IF IsOpenArray(a) AND IsOpenArray(b) THEN
|
|
IF IsOpenArray(a) AND IsOpenArray(b) THEN
|
|
|
- RETURN SameType(ArrayElem(a), ArrayElem(b))
|
|
|
|
|
|
|
+ RETURN ArrayShapeOk(a, b)
|
|
|
END;
|
|
END;
|
|
|
(* Procedure types are built fresh per parse, so a
|
|
(* Procedure types are built fresh per parse, so a
|
|
|
DEFINITION/IMPLEMENTATION pair never shares the index; compare
|
|
DEFINITION/IMPLEMENTATION pair never shares the index; compare
|
|
@@ -1283,7 +1302,7 @@ PROCEDURE ByteBufOk (at, ft: TypeIndex): BOOLEAN;
|
|
|
OR (c = ClPtr) OR (c = ClLong) OR (c = ClStr)
|
|
OR (c = ClPtr) OR (c = ClLong) OR (c = ClStr)
|
|
|
OR (c = ClByte) OR (c = ClSByte)
|
|
OR (c = ClByte) OR (c = ClSByte)
|
|
|
OR (c = ClWord16) OR (c = ClSWord16)
|
|
OR (c = ClWord16) OR (c = ClSWord16)
|
|
|
- OR (c = ClWord16) OR (c = ClSWord16)
|
|
|
|
|
|
|
+ OR (c = ClArray)
|
|
|
END ByteBufOk;
|
|
END ByteBufOk;
|
|
|
|
|
|
|
|
PROCEDURE TypesOverflow (): BOOLEAN;
|
|
PROCEDURE TypesOverflow (): BOOLEAN;
|
|
@@ -3328,8 +3347,12 @@ PROCEDURE Assignable (src, dst: TypeIndex): BOOLEAN;
|
|
|
IF (ClassOf(src) = ClArray) AND (ClassOf(dst) = ClArray) THEN
|
|
IF (ClassOf(src) = ClArray) AND (ClassOf(dst) = ClArray) THEN
|
|
|
(* a fixed 1-D array is compatible with an open formal of the
|
|
(* a fixed 1-D array is compatible with an open formal of the
|
|
|
same element type (value or VAR) *)
|
|
same element type (value or VAR) *)
|
|
|
- IF IsOpenArray(dst) AND (ArrayDepth(src) = 1) THEN
|
|
|
|
|
- RETURN SameType(ArrayElem(src), ArrayElem(dst))
|
|
|
|
|
|
|
+ IF IsOpenArray(dst) THEN
|
|
|
|
|
+ IF IsByteBuf(dst) THEN RETURN TRUE END;
|
|
|
|
|
+ IF ArrayShapeOk(src, dst) THEN RETURN TRUE END;
|
|
|
|
|
+ IF ArrayDepth(src) = 1 THEN
|
|
|
|
|
+ RETURN SameType(ArrayElem(src), ArrayElem(dst))
|
|
|
|
|
+ END
|
|
|
END;
|
|
END;
|
|
|
RETURN SameType(src, dst)
|
|
RETURN SameType(src, dst)
|
|
|
END;
|
|
END;
|