Location location = toLocation(t);
String document = t.document;
String name = s.image;
DefinitionStatement target = flowPeek().getDefinitionStatement();
ClassStatement parent = flowPeek().getClassStatement();
FunctionStatement context = flowPeek().getFunctionStatement();
if (context != null) {
if (context.getType() == Type.FUNCTION) {
is_static = true;
}
}
if (is_static) {
if (name.equals(parent.getName())) {
error(location, "Static methods may not used as constructors");
}
FunctionStatement function = new FunctionStatement(location, parent, context, is_synchronized, name, document, parameters);
function.setParentStatement(flowPeek());
if (target.lookupDeclaration(name) == null) {
parent.declare(function);
if (context != null) {
context.declare(name, function);
}
} else {
error(location, "Entity '" + name + "' is already declared");
}
flowPush(function);
flowPush(function.getChildStatement());
} else {
MethodStatement method;
if ((context == null) && name.equals(parent.getName())) {
is_constructor = true;
method = new ConstructorStatement(location, parent, is_synchronized, name, document, parameters);
if (parent.getConstructor() != null) {
error(location, "Constructor is already declared for class '"+parent+"'");
}
} else {
method = new MethodStatement(location, parent, context, is_synchronized, name, document, parameters);
}
method.setParentStatement(flowPeek());
if (target.lookupLocalDeclaration(name) == null) {
parent.declare(method);
if (context != null) {
context.declare(name, method);
}
} else {
error(location, "Entity '" + name + "' is already declared");