From 9cd018a1f09fcdec49b891d84d26cad619be610f Mon Sep 17 00:00:00 2001 From: Norayr Chilingarian Date: Fri, 1 Nov 2019 02:51:57 +0400 Subject: [PATCH] fix like https://github.com/jtempl/ofront/commit/78036911d21636514f2ece6d9e9e74ecc8755f1e --- src/compiler/OPC.Mod | 5 ++++- src/compiler/OPV.Mod | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/compiler/OPC.Mod b/src/compiler/OPC.Mod index 43b86251..d1f9027a 100644 --- a/src/compiler/OPC.Mod +++ b/src/compiler/OPC.Mod @@ -1215,12 +1215,15 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) END IntLiteral; PROCEDURE Len* (obj: OPT.Object; array: OPT.Struct; dim: SYSTEM.INT64); + VAR + d: SYSTEM.INT64; BEGIN + d := dim; + WHILE d > 0 DO array := array^.BaseTyp; DEC(d) END; IF array^.comp = OPT.DynArr THEN CompleteIdent(obj); OPM.WriteString(LenExt); IF dim # 0 THEN OPM.WriteInt(dim) END ELSE (* array *) - WHILE dim > 0 DO array := array^.BaseTyp; DEC(dim) END; OPM.WriteInt(array.n) END END Len; diff --git a/src/compiler/OPV.Mod b/src/compiler/OPV.Mod index 964f60e1..a8beb6dc 100644 --- a/src/compiler/OPV.Mod +++ b/src/compiler/OPV.Mod @@ -208,10 +208,18 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 PROCEDURE^ design(n: OPT.Node; prec: INTEGER); PROCEDURE Len(n: OPT.Node; dim: SYSTEM.INT64); + VAR + d: SYSTEM.INT64; array: OPT.Struct; BEGIN WHILE (n^.class = OPT.Nindex) & (n^.typ^.comp = OPT.DynArr(*26.7.2002*)) DO INC(dim); n := n^.left END ; IF (n^.class = OPT.Nderef) & (n^.typ^.comp = OPT.DynArr) THEN - design(n^.left, 10); OPM.WriteString("->len["); OPM.WriteInt(dim); OPM.Write("]") + d := dim; array := n^.typ; + WHILE d > 0 DO array := array^.BaseTyp; DEC(d) END; + IF array^.comp = DynArr THEN + design(n^.left, 10); OPM.WriteString("->len["); OPM.WriteInt(dim); OPM.Write("]") + ELSE + OPM.WriteInt(array^.n); OPM.PromoteIntConstToLInt() + END ELSE OPC.Len(n^.obj, n^.typ, dim) END