#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 %BEGIN
int main(int argc, char **argv) { /*%begin*/
_imp_enter(main);
_imp_initialise(argc, argv);
// 2 %RECORDFORMAT F(%INTEGER I,J,K,%INTEGERARRAY A,B,C(1:5))
struct F {
union {
struct {
int I;
int J;
int K;
int A[5];
int B[5];
int C[5];
};
};
};
// 3 %RECORD(F) R
struct F R;
// 4 %INTEGERARRAYNAME B
int *B;
struct _imp_dv B_dv = {
0}; // assignment of an array to an arrayname must copy bounds info too... (This was a 1-dimension array)
// 5 %INTEGER I
int I = 0xFEFEFEFE;
// 6 R_I='I'
R.I = 73;
// 7 R_J='J'
R.J = 74;
// 8 %CYCLE I=1,1,5
// %for I = 1, 1, 5 %cycle
{
I = 0;
L_0001:
if (I == 5) goto L_0002;
I += 1;
// 9 R_A(I)=I
R.A[I - 1] = I;
// 10 %REPEAT
goto L_0001;
}
L_0002:;
// 11 R_K=255
R.K = 255;
// 12 B==R_A
// B_dv = (_imp_dv) { R.A, <size>, <bound pairs> }; // TO DO: construct a dopevector on the fly for this array (or arrayname) which is a record field.
// 13 %CYCLE I=1,1,5
// %for I = 1, 1, 5 %cycle
{
I = 0;
L_0004:
if (I == 5) goto L_0005;
I += 1;
// 14 WRITE(B(I),5)
_imp_WRITE(_imp_aref(int, B, /* Dim 1: */ I), 5);
// 15 %REPEAT
goto L_0004;
}
L_0005:;
// 16 %ENDOFPROGRAM
_imp_stop(0);
end_0:;
_imp_begin_backtrace(main);
_imp_diagf("\n\nArguments:\n\n");
_imp_diagf("ARGC = %d\n", argc);
_imp_diagf("ARGV @[%p]\n", argv);
for (int i = 0; i < argc; i++) {
_imp_diagf(" ARGV(%d) = \"%s\"\n", i, argv[i]);
}
if (argv[argc] == 0) {
_imp_diagf(" ARGV(%d) = NULL\n", argc);
} else {
_imp_diagf(" ARGV(%d) = \"%s\"\n", argc, argv[argc]);
}
_imp_diagf("\nLocal Variables:\n\n");
_imp_diagf("R = \"<RECORD>\"\n");
_imp_bt_int(I);
_imp_end_backtrace();
_imp_stop(0);
}