mirror of https://github.com/aamine/cbc
* net/loveruby/cflat/type/TypeTable.java (semanticCheck): check all types by checkRecursiveDefinition. It is not efficient because checking char, short, int, long, ... is not needed, but is more reliable.
* net/loveruby/cflat/type/TypeTable.java (checkRecursiveDefinition): should traverse ArrayType. * net/loveruby/cflat/type/TypeTable.java (checkRecursiveDefinition): should traverse ComplexType and ArrayType (and UserType which points these types) *at the same time*. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3903 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
1d06aa2e2a
commit
6849a2f05a
15
ChangeLog
15
ChangeLog
|
|
@ -1,3 +1,18 @@
|
|||
Tue Feb 12 06:23:21 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/type/TypeTable.java (semanticCheck): check
|
||||
all types by checkRecursiveDefinition. It is not efficient
|
||||
because checking char, short, int, long, ... is not needed, but is
|
||||
more reliable.
|
||||
|
||||
* net/loveruby/cflat/type/TypeTable.java
|
||||
(checkRecursiveDefinition): should traverse ArrayType.
|
||||
|
||||
* net/loveruby/cflat/type/TypeTable.java
|
||||
(checkRecursiveDefinition): should traverse ComplexType and
|
||||
ArrayType (and UserType which points these types) *at the same
|
||||
time*.
|
||||
|
||||
Tue Feb 12 00:45:47 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/TypeResolver.java: extract method
|
||||
|
|
|
|||
|
|
@ -133,15 +133,11 @@ public class TypeTable {
|
|||
if (t instanceof ComplexType) {
|
||||
checkVoidMembers((ComplexType)t, h);
|
||||
checkDuplicatedMembers((ComplexType)t, h);
|
||||
checkRecursiveDefinition((ComplexType)t, h);
|
||||
}
|
||||
else if (t instanceof ArrayType) {
|
||||
// FIXME: check on the fly
|
||||
checkVoidMembers((ArrayType)t, h);
|
||||
}
|
||||
else if (t instanceof UserType) {
|
||||
checkRecursiveDefinition((UserType)t, h);
|
||||
}
|
||||
checkRecursiveDefinition(t, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,34 +178,35 @@ public class TypeTable {
|
|||
static final protected Object checking = new Object();
|
||||
static final protected Object checked = new Object();
|
||||
|
||||
protected void _checkRecursiveDefinition(Type t, Map seen,
|
||||
protected void _checkRecursiveDefinition(Type t, Map marks,
|
||||
ErrorHandler h) {
|
||||
if (seen.get(t) == checking) {
|
||||
if (marks.get(t) == checking) {
|
||||
h.error(((NamedType)t).location(),
|
||||
"recursive type definition: " + t);
|
||||
return;
|
||||
}
|
||||
else if (seen.get(t) == checked) {
|
||||
else if (marks.get(t) == checked) {
|
||||
return;
|
||||
}
|
||||
seen.put(t, checking);
|
||||
if (t instanceof ComplexType) {
|
||||
ComplexType ct = (ComplexType)t;
|
||||
Iterator membs = ct.members();
|
||||
while (membs.hasNext()) {
|
||||
Slot slot = (Slot)membs.next();
|
||||
if (slot.type().isComplexType()) {
|
||||
_checkRecursiveDefinition(slot.type().getComplexType(),
|
||||
seen, h);
|
||||
else {
|
||||
marks.put(t, checking);
|
||||
if (t instanceof ComplexType) {
|
||||
ComplexType ct = (ComplexType)t;
|
||||
Iterator membs = ct.members();
|
||||
while (membs.hasNext()) {
|
||||
Slot slot = (Slot)membs.next();
|
||||
_checkRecursiveDefinition(slot.type(), marks, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t instanceof UserType) {
|
||||
UserType ut = (UserType)t;
|
||||
if (ut.realType() instanceof UserType) {
|
||||
_checkRecursiveDefinition(ut.realType(), seen, h);
|
||||
else if (t instanceof ArrayType) {
|
||||
ArrayType at = (ArrayType)t;
|
||||
_checkRecursiveDefinition(at.baseType(), marks, h);
|
||||
}
|
||||
else if (t instanceof UserType) {
|
||||
UserType ut = (UserType)t;
|
||||
_checkRecursiveDefinition(ut.realType(), marks, h);
|
||||
}
|
||||
marks.put(t, checked);
|
||||
}
|
||||
seen.put(t, checked);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue