if (hasExtends())
{
Named<?> n = parent().get( xtnds.name );
if (n == null)
throw new ParseException( String.format(
"struct %s extends %s not defined at line %d",
this.name(), xtnds.name(), xtnds.token.beginLine ) );
if (!(n instanceof Struct))
throw new ParseException( String.format(
"struct %s extends %s not a struct at line %d",
this.name(), xtnds.name(), xtnds.token.beginLine ) );
Struct s = this;
while (s != null && s.hasExtends())
{
s = s.getExtends();
if (s == this)
throw new ParseException( String.format(
"struct %s extends %s creates loop at line %d",
this.name(), xtnds.name(), xtnds.token.beginLine ) );
}
s = getExtends();
for (Parameter p: this)
{
Parameter x = s.getParameter( p.name().name );
if (x != null)
throw new ParseException( String.format(
"struct %s extends %s hides parameter %s from %s at line %d",
this.name(), xtnds.name(), x.name(), x.parent().name(),
xtnds.token.beginLine ) );
}
}