I'm having problems figuring out how to pass parameters to a function with the current imcc. It either segfaults (in hash_str() from find_basic_blocks()) or gives me 'No entries on the UserStack', depending on how I do it wrong. :)
Does anyone have a minimal example of using imcc to call a function with parameters with the current cvs of parrot? (I can get it to work without parameters) I've tried with many different variations (to no avail), and also tried running the tests, which all seem to fail here...
-Sterling
--first tries--
.sub _b saveall .param int bar print bar print "\n" restoreall .end
.sub _main prototyped .arg 10 call _b end .end
Gives 'No Entries on UserStack!'
And
.pcc_sub _b .param int var print variable print "\n" .pcc_begin_return .pcc_end_return .end .sub _main .local Sub b newsub b, .Sub, _b .pcc_begin prototyped .arg 10 .pcc_call b ret: .pcc_end .end
Gives a segmentation fault: (gdb) r 9.imc Starting program: /data/home/shughes/work/2did/parrot/parrot 9.imc [New Thread 16384 (LWP 28861)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 28861)]
0x0812aac0 in hash_str (str=0x0) at imcc/symreg.c:538
538 for(s=str; *s; s++)
(gdb) where
#0 0x0812aac0 in hash_str (str=0x0) at imcc/symreg.c:538
#1 0x0812a791 in _get_sym (hsh=0x81dbc60, name=0x0) at imcc/symreg.c:440
#2 0x0812a81c in get_sym (name=0x0) at imcc/symreg.c:451
#3 0x0812be7a in find_basic_blocks (interpreter=0x81e3510, unit=0x826b3e8, first=1) at imcc/cfg.c:158
#4 0x0812d872 in imc_reg_alloc (interpreter=0x81e3510, unit=0x826b3e8) at imcc/reg_alloc.c:97
#5 0x0812958c in imc_compile_unit (interp=0x81e3510, unit=0x826b3e8) at imcc/imc.c:38
#6 0x08129546 in imc_compile_all_units (interp=0x81e3510) at imcc/imc.c:24
#7 0x08070a7f in main (argc=1, argv=0xbffffb78) at imcc/main.c:495