19f74024d9b59e8fc4ab57f6d0bf33b3e56c172b
[IRC.git] / Robust / src / ClassLibrary / SSJava / SSJAVA.java
1 import Benchmarks.SSJava.EyeTracking.LOC;
2
3 public class SSJAVA {
4
5   // Definitely written analysis assumes that the first parameter may have write
6   // effects through the below methods
7
8   static void arrayinit(float array[], float value) {
9     for (int i = 0; i < array.length; i++) {
10       array[i] = value;
11     }
12   }
13
14   static void arrayinit(int array[], int value) {
15     for (int i = 0; i < array.length; i++) {
16       array[i] = value;
17     }
18   }
19
20   static void arrayinit(float array[][][], int size_1, int size_2, int size_3, float value) {
21
22     for (int idx1 = 0; idx1 < size_1; idx1++) {
23       if (array[idx1].length != size_2) {
24         throw new Error("Array initilizatiion failed to assign to all of elements.");
25       }
26       for (int idx2 = 0; idx2 < size_2; idx2++) {
27         if (array[idx1][idx2].length != size_3) {
28           throw new Error("Array initilizatiion failed to assign to all of elements.");
29         }
30         for (int idx3 = 0; idx3 < size_3; idx3++) {
31           array[idx1][idx2][idx3] = value;
32         }
33       }
34     }
35   }
36
37   static void arrayinit(float array[][], int size_1, int size_2, float value) {
38
39     for (int idx1 = 0; idx1 < size_1; idx1++) {
40       if (array[idx1].length != size_2) {
41         throw new Error("Array initilizatiion failed to assign to all of elements.");
42       }
43       for (int idx2 = 0; idx2 < size_2; idx2++) {
44         array[idx1][idx2] = value;
45       }
46     }
47   }
48
49   static void arraycopy(float array[][], float src[][], int size_1, int size_2) {
50
51     for (int idx1 = 0; idx1 < size_1; idx1++) {
52       if (array[idx1].length != size_2 || src[idx1].length != size_2) {
53         throw new Error("Array initilizatiion failed to assign to all of elements.");
54       }
55       for (int idx2 = 0; idx2 < size_2; idx2++) {
56         array[idx1][idx2] = src[idx1][idx2];
57       }
58     }
59   }
60
61   static void append(Object array[], Object item) {
62     for (int i = 1; i < array.length; i++) {
63       array[i - 1] = array[i];
64       array[i] = null;
65     }
66     array[array.length - 1] = item;
67   }
68   
69   static void append(int array[], int item) {
70     for (int i = 1; i < array.length; i++) {
71       array[i - 1] = array[i];
72       array[i] = 0;
73     }
74     array[array.length - 1] = item;
75   }
76
77
78   static void arrayinit(Object array[]) {
79     for (int i = 1; i < array.length; i++) {
80       array[i] = null;
81     }
82   }
83
84 }