use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class CompleteCommand method findInstanceMembers.
private static void findInstanceMembers(IType type, Set<IField> fields, Set<IProperty> properties, Set<IMethod> methods, String start, Set<IClass> dejaVu) {
final IClass iclass = type.getTheClass();
if (iclass == null || dejaVu.contains(iclass)) {
return;
}
dejaVu.add(iclass);
// Add members
final ParameterList parameterList = iclass.getParameters();
for (int i = 0, count = parameterList.size(); i < count; i++) {
checkMember(fields, (IField) parameterList.get(i), start, false);
}
findMembers(type, fields, properties, methods, start, false);
// Recursively scan super types
final IType superType = iclass.getSuperType();
if (superType != null) {
findInstanceMembers(superType.getConcreteType(type), fields, properties, methods, start, dejaVu);
}
for (IType interfaceType : iclass.getInterfaces()) {
findInstanceMembers(interfaceType.getConcreteType(type), fields, properties, methods, start, dejaVu);
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class LambdaExpr method isType.
@Override
public boolean isType(IType type) {
if (this.type != null && Types.isSuperType(type, this.type)) {
return true;
}
final IClass interfaceClass = type.getTheClass();
if (interfaceClass == null) {
return false;
}
if (interfaceClass == Types.OBJECT_CLASS) {
return true;
}
final IMethod method = interfaceClass.getFunctionalMethod();
if (method == null) {
return false;
}
final ParameterList methodParameters = method.getParameters();
final int parameterCount = this.parameters.size();
if (parameterCount != methodParameters.size()) {
return false;
}
for (int i = 0; i < parameterCount; i++) {
final IType lambdaParameterType = this.parameters.get(i).getCovariantType();
if (lambdaParameterType.isUninferred()) {
continue;
}
final IType methodParameterType = methodParameters.get(i).getCovariantType();
if (!Types.isSuperType(methodParameterType, lambdaParameterType)) {
return false;
}
}
return true;
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class EnumConstant method check.
@Override
public void check(MarkerList markers, IContext context) {
final IClass enclosingClass = this.getEnclosingClass();
final IType classType = enclosingClass.getClassType();
if (!enclosingClass.hasModifier(Modifiers.ENUM_CLASS)) {
final Marker marker = Markers.semanticError(this.position, "field.enum.class", this.name);
marker.addInfo(Markers.getSemantic("method.enclosing_class", classType));
markers.add(marker);
}
super.check(markers, context);
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class Field method writeGet.
@Override
public void writeGet(@NonNull MethodWriter writer, WriteableExpression receiver, int lineNumber) throws BytecodeException {
this.writeReceiver(writer, receiver);
final IClass enclosingClass = this.getEnclosingClass();
final String owner = enclosingClass.getInternalName();
final String name = this.getInternalName();
final String desc = this.getDescriptor();
writer.visitLineNumber(lineNumber);
switch(this.getAttributes().flags() & (Modifiers.STATIC | Modifiers.LAZY)) {
case // neither static nor lazy
0:
writer.visitFieldInsn(Opcodes.GETFIELD, owner, name, desc);
return;
case Modifiers.STATIC:
writer.visitFieldInsn(Opcodes.GETSTATIC, owner, name, desc);
return;
case Modifiers.LAZY:
writer.visitMethodInsn(this.hasModifier(Modifiers.PRIVATE) ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL, owner, name + "$lazy", "()" + desc, this.enclosingClass.isInterface());
return;
case // both static and lazy
Modifiers.STATIC | Modifiers.LAZY:
writer.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name + "$lazy", "()" + desc, enclosingClass.isInterface());
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class ThisExpr method checkTypes.
@Override
public void checkTypes(MarkerList markers, IContext context) {
this.type.checkType(markers, context, TypePosition.SUPER_TYPE);
if (!context.isThisAvailable()) {
markers.add(Markers.semanticError(this.position, "this.access.static"));
return;
}
if (!this.type.isResolved()) {
return;
}
final IClass theClass = this.type.getTheClass();
this.getter = context.getAccessibleThis(theClass);
if (this.getter == null) {
markers.add(Markers.semanticError(this.position, "this.instance", this.type));
}
}
Aggregations