#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 ! This shows that the icode does not distinguish the two declarations,
// 3 ! and the initialisation relies on finding the declaration on the stack.
// 4 ! I suspect we can get by with having a single flex array for the
// 5 ! current declarations initial values.
// 6 !
// 7 ! When we pop the stack at codegen time, we'll either hit an INIT
// 8 ! first (at which point we save them up, in reverse order) or
// 9 ! we hit the $DEF and there's no initialisation needed.
// 10
// 11 %ownintegerarray one(0:3)
static int ONE[4];
_imp_create_constdv(static, int, ONE, 0, 3);
// 12
// 13 %ownintegerarray two(0:3) = 1, 2, 3, 4
static int TWO[4] = {1, 2, 3, 4};
_imp_create_constdv(static, int, TWO, 0, 3);
// 14
// 15 one(2) = two(1)
ONE[2] = TWO[1];
// 16
// 17 %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_end_backtrace();
_imp_stop(0);
}