use of dyvilx.tools.compiler.ast.type.compound.ImplicitNullableType in project Dyvil by Dyvil.
the class PostfixType method resolveType.
@Override
public IType resolveType(MarkerList markers, IContext context) {
final String unqualified = this.name.unqualified;
final IType argument = this.arguments.get(0);
if (unqualified.length() == 1) {
switch(unqualified.charAt(0)) {
case '?':
return NullableType.apply(argument).resolveType(markers, context);
case '!':
return new ImplicitNullableType(argument).resolveType(markers, context);
case '*':
return new ReferenceType(argument).resolveType(markers, context);
case '^':
return new ImplicitReferenceType(argument).resolveType(markers, context);
}
}
return super.resolveType(markers, context);
}
use of dyvilx.tools.compiler.ast.type.compound.ImplicitNullableType in project Dyvil by Dyvil.
the class EnumClassMetadata method updateConstructor.
private void updateConstructor(IConstructor constructor) {
constructor.getAttributes().addFlag(Modifiers.PRIVATE_PROTECTED);
// Prepend parameters and set super initializer
final CodeParameter nameParam = new CodeParameter(constructor, null, Names.name, new ImplicitNullableType(Types.STRING), AttributeList.of(Modifiers.SYNTHETIC));
final CodeParameter ordParam = new CodeParameter(constructor, null, Names.ordinal, Types.INT, AttributeList.of(Modifiers.SYNTHETIC));
constructor.getParameters().insert(0, nameParam);
constructor.getParameters().insert(1, ordParam);
final IConstructor enumConstructor = Types.ENUM_CLASS.getBody().getConstructor(0);
final InitializerCall initializer = constructor.getInitializer();
if (initializer == null) {
final ArgumentList arguments = new ArgumentList(new FieldAccess(nameParam), new FieldAccess(ordParam));
final SourcePosition position = constructor.position();
final InitializerCall init = new InitializerCall(position, true, arguments, this.theClass.getSuperType(), enumConstructor);
constructor.setInitializer(init);
return;
}
// Prepend access to new parameters
final ArgumentList arguments = initializer.getArguments();
arguments.insert(0, new FieldAccess(nameParam));
arguments.insert(1, new FieldAccess(ordParam));
}
Aggregations