DEADSOFTWARE

28d8c466df99d528685380520b5429a2248a18e5
[dsw-obn.git] / 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 ix = LEN(x);
23 int iv = v.length - 1;
25 int i = 0;
26 int len = (ix < iv) ? (ix) : (iv);
27 while(i < len)
28 {
29 v[i] = x[i];
30 i += 1;
31 }
32 v[i] = 0;
33 }
35 public static int STRCMP(byte[] a, byte[] b)
36 {
37 int i = 0;
38 while(a[i] != 0 && a[i] == b[i])
39 {
40 i += 1;
41 }
42 return a[i] - b[i];
43 }
45 public static void HALT(long n)
46 {
47 System.exit((int) n);
48 }
50 public static void ASSERT(boolean x)
51 {
52 assert x;
53 }
55 public static void ASSERT(boolean x, long n)
56 {
57 assert x : n;
58 }
60 public static void TRAP(long n)
61 {
62 if(n == -1)
63 {
64 throw new RuntimeException("CASE TRAP");
65 }
66 else if(n == -2)
67 {
68 throw new RuntimeException("WITH TRAP");
69 }
70 else
71 {
72 throw new RuntimeException("TRAP CODE " + n);
73 }
74 }
75 }