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>
|
Tue Feb 12 00:45:47 2008 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* net/loveruby/cflat/compiler/TypeResolver.java: extract method
|
* net/loveruby/cflat/compiler/TypeResolver.java: extract method
|
||||||
|
|
|
||||||
|
|
@ -133,15 +133,11 @@ public class TypeTable {
|
||||||
if (t instanceof ComplexType) {
|
if (t instanceof ComplexType) {
|
||||||
checkVoidMembers((ComplexType)t, h);
|
checkVoidMembers((ComplexType)t, h);
|
||||||
checkDuplicatedMembers((ComplexType)t, h);
|
checkDuplicatedMembers((ComplexType)t, h);
|
||||||
checkRecursiveDefinition((ComplexType)t, h);
|
|
||||||
}
|
}
|
||||||
else if (t instanceof ArrayType) {
|
else if (t instanceof ArrayType) {
|
||||||
// FIXME: check on the fly
|
|
||||||
checkVoidMembers((ArrayType)t, h);
|
checkVoidMembers((ArrayType)t, h);
|
||||||
}
|
}
|
||||||
else if (t instanceof UserType) {
|
checkRecursiveDefinition(t, h);
|
||||||
checkRecursiveDefinition((UserType)t, h);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,34 +178,35 @@ public class TypeTable {
|
||||||
static final protected Object checking = new Object();
|
static final protected Object checking = new Object();
|
||||||
static final protected Object checked = 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) {
|
ErrorHandler h) {
|
||||||
if (seen.get(t) == checking) {
|
if (marks.get(t) == checking) {
|
||||||
h.error(((NamedType)t).location(),
|
h.error(((NamedType)t).location(),
|
||||||
"recursive type definition: " + t);
|
"recursive type definition: " + t);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (seen.get(t) == checked) {
|
else if (marks.get(t) == checked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seen.put(t, checking);
|
else {
|
||||||
if (t instanceof ComplexType) {
|
marks.put(t, checking);
|
||||||
ComplexType ct = (ComplexType)t;
|
if (t instanceof ComplexType) {
|
||||||
Iterator membs = ct.members();
|
ComplexType ct = (ComplexType)t;
|
||||||
while (membs.hasNext()) {
|
Iterator membs = ct.members();
|
||||||
Slot slot = (Slot)membs.next();
|
while (membs.hasNext()) {
|
||||||
if (slot.type().isComplexType()) {
|
Slot slot = (Slot)membs.next();
|
||||||
_checkRecursiveDefinition(slot.type().getComplexType(),
|
_checkRecursiveDefinition(slot.type(), marks, h);
|
||||||
seen, h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (t instanceof ArrayType) {
|
||||||
else if (t instanceof UserType) {
|
ArrayType at = (ArrayType)t;
|
||||||
UserType ut = (UserType)t;
|
_checkRecursiveDefinition(at.baseType(), marks, h);
|
||||||
if (ut.realType() instanceof UserType) {
|
|
||||||
_checkRecursiveDefinition(ut.realType(), seen, 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