DEADSOFTWARE

68f82bd0983c3ee348507e7903023dc63318cf8c
[dsw-obn.git] / rtl / SYSTEM.java
1 public class SYSTEM
2 {
3 /* Каркас для фреймов процедур */
4 public static abstract class FRAME
5 {
6 public FRAME up;
7 }
9 /* Длинна строки LEN(s$) */
10 public static int LEN(byte[] x)
11 {
12 int i = 0;
13 while(x[i] != 0)
14 {
15 i += 1;
16 }
17 return i;
18 }
20 public static void COPY(byte[] x, byte[] v)
21 {
22 int len_x = LEN(x);
23 int len_v = v.length - 1;
25 int len = (len_x < len_v) ? (len_x) : (len_v);
26 for(int i = 0; i < len; i++)
27 {
28 v[i] = x[i];
29 }
31 v[len] = 0;
32 }
34 public static int STRCMP(byte[] a, byte[] b)
35 {
36 int i = 0;
37 while(a[i] != 0 && a[i] == b[i])
38 {
39 i += 1;
40 }
41 return a[i] - b[i];
42 }
44 public static void HALT(long n)
45 {
46 System.exit((int) n);
47 }
49 public static void ASSERT(boolean x)
50 {
51 assert x;
52 }
54 public static void ASSERT(boolean x, long n)
55 {
56 assert x : n;
57 }
59 public static void TRAP(long n)
60 {
61 if(n == -1)
62 {
63 throw new RuntimeException("CASE TRAP");
64 }
65 else if(n == -2)
66 {
67 throw new RuntimeException("WITH TRAP");
68 }
69 else
70 {
71 throw new RuntimeException("TRAP CODE " + n);
72 }
73 }
74 }