#include <perms.h>
// Edinburgh IMP77 Compiler - Version 8.4
//
// 1 !
// 2 ! pass1 doesn't pass the recordformatspec through, and although we can detect when
// 3 ! 'recfm' is used before it has been fully specified, we can't know the original
// 4 ! location where it was declared. We have to take care when reinserting a generated
// 5 ! recordformatspec to place it where it applies to all necessary uses.
// 6 !
// 7 %begin
int main(int argc, char **argv) { /*%begin*/
_imp_enter(main);
_imp_initialise(argc, argv);
// 8 %recordformatspec recfm { recordformat spec has to be inserted here }
// 9 %integer i = 42 { or here. NOT in nest1 because then it would }
int I = 0xFEFEFEFE;
I = 42;
// 10 %integermap nest1 { already be out of scope again before the }
int *NEST1(void) {
_imp_enter(NEST1);
// 11 %integer filler = 17 { decaration of 'another' }
int FILLER = 0xFEFEFEFE;
FILLER = 17;
// 12 %ownrecord (recfm) %name fred
static struct RECFM *FRED;
// 13 %result == INTEGER(ADDR(fred))
_imp_result(_imp_INTEGER(((_imp_address)(FRED))));
// 14 %end
_imp_begin_backtrace(NEST1);
_imp_diagf("\nLocal Variables:\n\n");
_imp_bt_int(FILLER);
_imp_diagf("FRED @[%p] = <RECORD>\n", FRED);
_imp_end_backtrace();
} /* end of NEST1 */
// ?FILLER unused
// 15 %record (recfm) %name another
struct RECFM *ANOTHER = (void *)0xFEFEFEFEFEFEFEFELL;
// 16 %recordformat recfm(%integer q)
struct RECFM {
union {
struct {
int Q;
};
};
};
// 17 nest1 = 42
*NEST1() = 42;
// 18 write(nest1, 0)
_imp_WRITE(*NEST1(), 0);
// 19 newline
_imp_NEWLINE();
// 20 %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_bt_int(I);
_imp_diagf("ANOTHER @[%p] = <RECORD>\n", ANOTHER);
_imp_end_backtrace();
_imp_stop(0);
}