A naive pass at this is:
oolong:~/research/parrot coke$ cvs diff imcc/symreg.c
Index: imcc/symreg.c
=========================================================
==========
RCS file: /cvs/public/parrot/imcc/symreg.c,v
retrieving revision 1.55
diff -b -u -r1.55 symreg.c
--- imcc/symreg.c 17 Jul 2004 08:07:27 -0000 1.55
+++ imcc/symreg.c 30 Oct 2004 04:45:21 -0000
@@ -287,6 +287,11 @@
ident->next = namespace->idents;
namespace->idents = ident;
}
+ if (_get_sym(cur_unit->hash,fullname)) {
+ fataly(1, sourcefile, line,
+ "duplicate .local or .sym: '%s'",
+ fullname);
+ }
r = mk_symreg(fullname, t);
r->type = VTIDENTIFIER;
free(name);
This causes a few tests to fail:
t/library/dumper.t 13 3328 13 13 100.00% 1-13
t/library/parrotlib.t 1 256 6 1 16.67% 3
t/library/streams.t 12 3072 21 12 57.14% 2 4-5 8 10-12 14-17 20
t/pmc/iter.t 1 256 44 1 2.27% 11
/Some/ of these seem to be valid errors. But it also seems to not like having .subs with the
same name as a .local inside that sub.
Also, the errors message isn't reporting properly.
Help?
> A naive pass at this is:
> + if (_get_sym(cur_unit->hash,fullname)) {
> + fataly(1, sourcefile, line,
While this patch isn't really wrong it's probably a bit dangerous and
might break too much existing code.
Anyway I'd prefer a more general approach:
* split PASM and PIR lexer and parser into two distinct sets
(the -p prefix option for bison is helpful here, see ast/ast.[ly])
* generate exact location information, again see above files
* Cleanup and straighten the grammar files
* fix names handling: global constants, locals per unit, subroutine
names per namespace
* get rid of support for stack calling conventions (.param and friends)
in PIR mode
* get rid of related cruft in imcc/cfg.c
* get rid of the still existing globals, move all into appropriate
structures, mostly IMC_Unit.
* and a lot more todo, e.g. create a compiler API
Imcc has too much historical ballast. Since it was a standalone language
that produced PASM files it has gone through numerous changes and hacks.
Now it's since quite a time Parrot's compiler and integrated.
These changes shouldn't really interfer with current ongoing hacks in
reg_alloc.c as long as that file isn't touched and the SymReg structure
keeps the relevant information for register allocation.
leo