initial commit
This commit is contained in:
75
MicroJava Compiler/TestProgram.mj
Normal file
75
MicroJava Compiler/TestProgram.mj
Normal file
@@ -0,0 +1,75 @@
|
||||
program Test
|
||||
|
||||
class Inner {
|
||||
int i;
|
||||
char[] a;
|
||||
char ch;
|
||||
}
|
||||
|
||||
int ii, jj;
|
||||
int[] arr;
|
||||
char a, b;
|
||||
char[] arr2;
|
||||
|
||||
final int const1 = 3;
|
||||
final char const2 = 'w';
|
||||
{
|
||||
int Func (int i) { return i*2; }
|
||||
|
||||
void Math ()
|
||||
int i, j, k, l, m;
|
||||
Inner in;
|
||||
Inner[] arr;
|
||||
{
|
||||
arr = new Inner[12];
|
||||
arr[7] = new Inner;
|
||||
arr[7].i = 17;
|
||||
|
||||
in = new Inner;
|
||||
in.i = 5;
|
||||
i = 2; j=3; k=4;
|
||||
l = i*j*k*4*Func(2)*Func(k);
|
||||
m = l+i-k+(const1%ord(const2))*in.i;
|
||||
i = m+arr[7].i;
|
||||
i += ii;
|
||||
if (i == 3119) print(1);
|
||||
}
|
||||
|
||||
void Structs ()
|
||||
int i;
|
||||
{
|
||||
while (i<17) {
|
||||
if (i>10) ii++;
|
||||
else if (i<5) ii--;
|
||||
else ii+=8;
|
||||
i++;
|
||||
}
|
||||
ii++;
|
||||
if (ii == 67) print(2);
|
||||
i = 3;
|
||||
while (i<15) {
|
||||
ii*=2;
|
||||
if (i == 10) break;
|
||||
i++;
|
||||
}
|
||||
if(ii == 17152) print(3);
|
||||
}
|
||||
|
||||
int Call(int val)
|
||||
int i;
|
||||
{
|
||||
if (val<10) val = Call(val+1)-1;
|
||||
else val = -2;
|
||||
return val;
|
||||
}
|
||||
|
||||
void main () {
|
||||
ii = 17;
|
||||
Math();
|
||||
Structs();
|
||||
ii = 1;
|
||||
ii = Call(ii);
|
||||
if (ii == -11) print(4);
|
||||
print('\n');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user