From c3c7b7920e8061bd5f2820ccca1153bd2174fe01 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sun, 8 Oct 2017 17:51:22 +0300 Subject: [PATCH] =?utf8?q?=D0=92=20Files=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8?= =?utf8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20=D0=B5=D1=89=D1=91=20?= =?utf8?q?=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF?= =?utf8?q?=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- notes | 2 +- rtl/java/Files.java | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/notes b/notes index 3656a86..0aa5f4e 100644 --- a/notes +++ b/notes @@ -4,7 +4,7 @@ - Нужно передавать информацию о файле и строках в кодогенератор. - Нет процедур привязанных к типм (10.2) - Не полная реализация модуля Files - * Нет процедур ReadNum WriteReal WriteLReal WriteNum WriteSet WriteBool + * Нет процедур ReadNum WriteNum - Разршить отсутсвие RETURN в функциях без BEGIN С вкорячиванием трапа, естественно. diff --git a/rtl/java/Files.java b/rtl/java/Files.java index 1769452..9cb6aee 100644 --- a/rtl/java/Files.java +++ b/rtl/java/Files.java @@ -349,14 +349,28 @@ class Files WriteBytes(R, R$, i, 0, 4); } + public static void WriteHInt(RECORD1 R[], int R$, long x) + { + byte[][] i = new byte[1][8]; + i[0][7] = (byte) ((x >>> 56) & 0xff); + i[0][6] = (byte) ((x >>> 48) & 0xff); + i[0][5] = (byte) ((x >>> 40) & 0xff); + i[0][4] = (byte) ((x >>> 32) & 0xff); + i[0][3] = (byte) ((x >>> 24) & 0xff); + i[0][2] = (byte) ((x >>> 16) & 0xff); + i[0][1] = (byte) ((x >>> 8) & 0xff); + i[0][0] = (byte) ((x) & 0xff); + WriteBytes(R, R$, i, 0, 8); + } + public static void WriteReal(RECORD1 R[], int R$, float x) { - SYSTEM.TRAP(-3); + WriteLInt(R, R$, Float.floatToRawIntBits(x)); } public static void WriteLReal(RECORD1 R[], int R$, double x) { - SYSTEM.TRAP(-3); + WriteHInt(R, R$, Double.doubleToRawLongBits(x)); } public static void WriteNum(RECORD1 R[], int R$, int x) @@ -373,12 +387,19 @@ class Files public static void WriteSet(RECORD1 R[], int R$, int x) { - SYSTEM.TRAP(-3); + WriteLInt(R, R$, x); } public static void WriteBool(RECORD1 R[], int R$, boolean x) { - SYSTEM.TRAP(-3); + if(x) + { + Write(R, R$, (byte) 1); + } + else + { + Write(R, R$, (byte) 0); + } } public static void WriteBytes(RECORD1 r[], int r$, byte[][] x, int x$, int n) -- 2.29.2