use of dyvilx.tools.compiler.ast.field.Field in project Dyvil by Dyvil.
the class ObjectClassMetadata method createInstanceField.
private Field createInstanceField() {
final int flags = Modifiers.PUBLIC | Modifiers.CONST | (this.theClass.isImplicit() ? Modifiers.IMPLICIT : 0);
final IType classType = this.theClass.getClassType();
final Field field = new Field(this.theClass, Names.instance, classType, AttributeList.of(flags));
final ConstructorCall call = new ConstructorCall(this.theClass.position(), classType, ArgumentList.EMPTY);
field.setValue(call);
return field;
}
use of dyvilx.tools.compiler.ast.field.Field in project Dyvil by Dyvil.
the class ObjectClassMetadata method resolveTypesGenerate.
@Override
public void resolveTypesGenerate(MarkerList markers, IContext context) {
super.resolveTypesGenerate(markers, context);
if ((this.members & CONSTRUCTOR) == 0) {
this.constructor.setAttributes(AttributeList.of(Modifiers.PRIVATE | Modifiers.GENERATED));
}
if ((this.members & INSTANCE_FIELD) == 0) {
final Field field = this.createInstanceField();
this.instanceField = field;
this.theClass.createBody().addDataMember(field);
} else {
markers.add(Markers.semanticError(this.instanceField.getPosition(), "class.object.field", this.theClass.getName()));
}
}
use of dyvilx.tools.compiler.ast.field.Field in project Dyvil by Dyvil.
the class EnumClassMetadata method createValuesField.
private Field createValuesField() {
final SourcePosition position = this.theClass.position();
final ArrayType type = new ArrayType(this.theClass.getClassType(), Mutability.IMMUTABLE);
final AttributeList attributes = AttributeList.of(Modifiers.PRIVATE | Modifiers.CONST | Modifiers.SYNTHETIC);
final Field field = new Field(this.theClass, position, Names.$VALUES, type, attributes);
field.setValue(this.createValuesArray());
return field;
}
Aggregations