From 317e2eb03b343f9d753990e6ed8386fd4effca60 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Fri, 15 Sep 2017 21:06:19 +0300 Subject: [PATCH] =?utf8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D0=BD=D0=BE=20=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C?= =?utf8?q?=D0=BA=D0=BE=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= =?utf8?q?=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8=20=D0=B2=20Files,=20?= =?utf8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=20=D0=B2=20S?= =?utf8?q?YSTEM=20=D0=B8=20Oberon?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Test.obn | 11 ----------- notes | 1 + obn-run.sh | 2 +- rtl/Oberon.obn | 6 +----- rtl/java/Files.java | 31 +++++++++++++++++++++++++++---- rtl/java/SYSTEM.java | 12 +++++++++++- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/Test.obn b/Test.obn index 950aa0a..6fae529 100644 --- a/Test.obn +++ b/Test.obn @@ -1,14 +1,3 @@ MODULE Test; -IMPORT Out; - -TYPE - Name = ARRAY 16 OF CHAR; - -VAR - key : ARRAY 128 OF Name; - name : Name; - -BEGIN - IF name > name THEN Out.Ln; END; END Test. diff --git a/notes b/notes index bdd35e2..3656a86 100644 --- a/notes +++ b/notes @@ -4,6 +4,7 @@ - Нужно передавать информацию о файле и строках в кодогенератор. - Нет процедур привязанных к типм (10.2) - Не полная реализация модуля Files + * Нет процедур ReadNum WriteReal WriteLReal WriteNum WriteSet WriteBool - Разршить отсутсвие RETURN в функциях без BEGIN С вкорячиванием трапа, естественно. diff --git a/obn-run.sh b/obn-run.sh index 9514a22..93f2da8 100755 --- a/obn-run.sh +++ b/obn-run.sh @@ -2,4 +2,4 @@ set -e -java -ea -cp classes Launcher $1 +java -ea -cp classes Launcher $* diff --git a/rtl/Oberon.obn b/rtl/Oberon.obn index 6282f4e..3316b85 100644 --- a/rtl/Oberon.obn +++ b/rtl/Oberon.obn @@ -29,6 +29,7 @@ BEGIN i := 1; WHILE i < Args.count DO Args.GetArg(i, str); Texts.WriteString(W, str); Texts.Write(W, " "); + Out.String("Param "); Out.Int(i, 0); Out.Char(" "); Out.String(str); Out.Ln; INC(i) END; Texts.Append(Par.text, W.buf); @@ -50,14 +51,9 @@ BEGIN END END LogNotifier; -PROCEDURE StubNotifier(T: Texts.Text; op: INTEGER; beg, end: LONGINT); -BEGIN -END StubNotifier; - BEGIN NEW(Par); NEW(Par.text); - Par.text.notify := StubNotifier; Par.pos := 0; Texts.Open(Par.text, ""); PopulateParams; diff --git a/rtl/java/Files.java b/rtl/java/Files.java index 9864ca5..c201940 100644 --- a/rtl/java/Files.java +++ b/rtl/java/Files.java @@ -376,12 +376,20 @@ class Files public static void WriteInt(RECORD1 R[], int R$, short x) { - SYSTEM.TRAP(-3); + byte[][] i = new byte[1][2]; + i[0][0] = (byte) ((x >>> 8) & 0xff); + i[0][1] = (byte) ((x) & 0xff); + WriteBytes(R, R$, i, 0, 2); } public static void WriteLInt(RECORD1 R[], int R$, int x) { - SYSTEM.TRAP(-3); + byte[][] i = new byte[1][4]; + i[0][0] = (byte) ((x >>> 24) & 0xff); + i[0][1] = (byte) ((x >>> 16) & 0xff); + i[0][2] = (byte) ((x >>> 8) & 0xff); + i[0][3] = (byte) ((x) & 0xff); + WriteBytes(R, R$, i, 0, 4); } public static void WriteReal(RECORD1 R[], int R$, float x) @@ -401,7 +409,9 @@ class Files public static void WriteString(RECORD1 R[], int R$, byte x[]) { - SYSTEM.TRAP(-3); + byte[][] i = new byte[1][]; + i[0] = x; + WriteBytes(R, R$, i, 0, SYSTEM.LEN(x)); } public static void WriteSet(RECORD1 R[], int R$, int x) @@ -416,7 +426,20 @@ class Files public static void WriteBytes(RECORD1 r[], int r$, byte[][] x, int x$, int n) { - SYSTEM.TRAP(-3); + RECORD1 rider = r[r$]; + RandomAccessFile desc = rider.base.desc; + + try + { + rider.base.SetActive(rider); + desc.write(x[x$], 0, n); + rider.position += n; + } + catch(IOException e) + { + rider.res[0] = n; + rider.eof[0] = true; + } } public static void BEGIN() diff --git a/rtl/java/SYSTEM.java b/rtl/java/SYSTEM.java index e1105c0..7e6a0f8 100644 --- a/rtl/java/SYSTEM.java +++ b/rtl/java/SYSTEM.java @@ -41,7 +41,17 @@ public class SYSTEM public static void COPY(String x, byte[] v) { - COPY(x.getBytes(), v); + int ix = x.length(); + int iv = v.length - 1; + + int i = 0; + int len = (ix < iv) ? (ix) : (iv); + while(i < len) + { + v[i] = (byte) x.charAt(i); + i += 1; + } + v[i] = 0; } public static int STRCMP(byte[] a, byte[] b) -- 2.29.2