use of dyvilx.tools.compiler.ast.parameter.ClassParameter in project Dyvil by Dyvil.
the class ExternalClass method visitField.
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
IType type = ClassFormat.readFieldType(signature == null ? desc : signature);
if (this.classParameters != null && this.classParameters.contains(name)) {
final ClassParameter param = new ExternalClassParameter(this, Name.fromQualified(name), desc, type, readModifiers(access));
this.parameters.add(param);
return new SimpleFieldVisitor(param);
}
final ExternalField field = new ExternalField(this, Name.fromQualified(name), desc, type, readModifiers(access));
if (value != null) {
field.setConstantValue(value);
}
this.body.addDataMember(field);
return new SimpleFieldVisitor(field);
}
use of dyvilx.tools.compiler.ast.parameter.ClassParameter in project Dyvil by Dyvil.
the class CaseClassMetadata method resolveTypesPre.
@Override
public void resolveTypesPre(MarkerList markers, IContext context) {
super.resolveTypesPre(markers, context);
for (IParameter param : this.theClass.getParameters()) {
final ClassParameter classParameter = (ClassParameter) param;
if (classParameter.isOverride() || classParameter.getProperty() != null) {
// Ignore override class parameters and class parameters that already have a property
continue;
}
// Create a property with getter
final IProperty property = classParameter.createProperty();
property.getAttributes().addFlag(Modifiers.GENERATED);
property.initGetter();
if (!classParameter.hasModifier(Modifiers.FINAL)) {
// and setter, for non-final class parameters
property.initSetter();
}
}
}
use of dyvilx.tools.compiler.ast.parameter.ClassParameter in project Dyvil by Dyvil.
the class ExternalClass method visitMethod.
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if ((access & Modifiers.SYNTHETIC) != 0) {
return null;
}
switch(name) {
case "<clinit>":
return null;
case "<init>":
if (this.hasModifier(Modifiers.ENUM)) {
return null;
}
final ExternalConstructor ctor = new ExternalConstructor(this, readModifiers(access));
if (signature != null) {
readConstructorType(signature, ctor);
} else {
readConstructorType(desc, ctor);
if (exceptions != null) {
readExceptions(exceptions, ctor.getExceptions());
}
}
if ((access & Modifiers.ACC_VARARGS) != 0) {
final ParameterList parameterList = ctor.getExternalParameterList();
parameterList.get(parameterList.size() - 1).setVarargs();
}
this.body.addConstructor(ctor);
return new SimpleMethodVisitor(ctor);
}
if (this.isAnnotation() && (access & Modifiers.STATIC) == 0) {
final ClassParameter param = new ExternalClassParameter(this, Name.fromQualified(name), desc.substring(2), readReturnType(desc), readModifiers(access));
this.parameters.add(param);
return new AnnotationClassVisitor(param);
}
final ExternalMethod method = new ExternalMethod(this, name, desc, signature, readModifiers(access));
if (signature != null) {
readMethodType(signature, method);
} else {
readMethodType(desc, method);
if (exceptions != null) {
readExceptions(exceptions, method.getExceptions());
}
}
if ((access & Modifiers.ACC_VARARGS) != 0) {
final ParameterList parameterList = method.getExternalParameterList();
parameterList.get(parameterList.size() - 1).setVarargs();
}
this.body.addMethod(method);
return new SimpleMethodVisitor(method);
}
Aggregations