protected Node superConstruct(ErrorListener context)
{
consumeSymbol();
ClassType classtype = _statement.getClassStatement();
boolean in_method = (_statement.getFunctionStatement() != null);
if (classtype == null) {
context.error(_location, "Cannot use 'super' outside the scope of class");
return null;
}
if (classtype.getBase() == null) {
context.error(_location, "Cannot use 'super' in classes without base class");
return null;
}
if ((symbolsLeft() == 0) && hasArgs() && in_method) {
if (_role != SUPER) {
context.error(_location, "Superclass constructor invoke must appear as first statement in the body of constructor");
return null;
}
ClassType base = classtype.getBaseClass();
CompilableFunction constructor = base.getConstructor();
if (constructor == null) {
context.error(_location, "Base class '"+base+"' does not have constructor");
return null;
}
checkArguments(context, constructor);