use of dyvilx.tools.compiler.ast.attribute.AttributeList in project Dyvil by Dyvil.
the class REPLContext method initMember.
private void initMember(IClassMember member) {
member.setEnclosingClass(this.currentClass);
// Ensure public & static
final AttributeList modifiers = member.getAttributes();
if ((modifiers.flags() & Modifiers.VISIBILITY_MODIFIERS) == 0) {
modifiers.addFlag(Modifiers.PUBLIC);
}
modifiers.addFlag(Modifiers.STATIC);
}
use of dyvilx.tools.compiler.ast.attribute.AttributeList in project Dyvil by Dyvil.
the class VarDirectiveParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
final int type = token.type();
switch(this.mode) {
case KEYWORD:
AttributeList attributes = new AttributeList();
switch(type) {
case GenSrcSymbols.VAR:
break;
case GenSrcSymbols.CONST:
case GenSrcSymbols.LET:
attributes.addFlag(Modifiers.FINAL);
break;
default:
pm.report(token, "var.declarator");
return;
}
this.mode = OPEN_PAREN;
return;
case OPEN_PAREN:
if (type != BaseSymbols.OPEN_PARENTHESIS) {
this.directives.add(this.varDirective);
pm.popParser(true);
return;
}
pm.pushParser(new DataMemberParser<>(this).withFlags(DataMemberParser.PARSE_VALUE));
this.mode = CLOSE_PAREN;
return;
case CLOSE_PAREN:
if (type != BaseSymbols.CLOSE_PARENTHESIS) {
pm.report(token, "var.close_paren");
return;
}
this.mode = BODY;
return;
case BODY:
if (type != BaseSymbols.OPEN_CURLY_BRACKET) {
this.directives.add(this.varDirective);
pm.popParser(true);
return;
}
final StatementList body = new StatementList();
pm.pushParser(new BlockParser(body));
this.varDirective.setBlock(body);
this.mode = BODY_END;
return;
case BODY_END:
assert type == BaseSymbols.CLOSE_CURLY_BRACKET;
this.directives.add(this.varDirective);
pm.popParser();
}
}
use of dyvilx.tools.compiler.ast.attribute.AttributeList in project Dyvil by Dyvil.
the class Property method resolveTypes.
@Override
public void resolveTypes(MarkerList markers, IContext context) {
super.resolveTypes(markers, context);
if (this.getter != null) {
final AttributeList getterAttributes = this.getter.getAttributes();
// Add <generated> Modifier and copy Property Modifiers
getterAttributes.addFlag(Modifiers.GENERATED);
Field.copyModifiers(this.attributes, getterAttributes);
this.getter.setType(this.type);
this.getter.resolveTypes(markers, context);
}
if (this.setter != null) {
final AttributeList setterModifiers = this.setter.getAttributes();
// Add <generated> Modifier and copy Property Modifiers
setterModifiers.addFlag(Modifiers.GENERATED);
Field.copyModifiers(this.attributes, setterModifiers);
this.setterParameter.setPosition(this.setter.getPosition());
this.setterParameter.setType(this.type);
this.setter.resolveTypes(markers, context);
}
if (this.initializer != null) {
this.initializer.resolveTypes(markers, new CombiningContext(this, context));
}
}
use of dyvilx.tools.compiler.ast.attribute.AttributeList in project Dyvil by Dyvil.
the class ICall method toLambda.
default IValue toLambda(MarkerList markers, IContext context, int wildcards) {
SourcePosition position = this.getPosition();
final IParameter[] parameters = new IParameter[wildcards];
for (int i = 0; i < wildcards; i++) {
parameters[i] = new CodeParameter(null, position, Name.fromRaw("wildcard$" + i), Types.UNKNOWN, new AttributeList());
}
int parIndex = 0;
final IValue receiver = this.getReceiver();
if (receiver != null && receiver.isPartialWildcard()) {
this.setReceiver(receiver.withLambdaParameter(parameters[parIndex++]));
}
final ArgumentList arguments = this.getArguments();
for (int i = 0, size = arguments.size(); i < size; i++) {
final IValue argument = arguments.get(i, null);
if (argument.isPartialWildcard()) {
arguments.set(i, null, argument.withLambdaParameter(parameters[parIndex++]));
}
}
final LambdaExpr lambdaExpr = new LambdaExpr(position, parameters, wildcards);
lambdaExpr.setImplicitParameters(true);
lambdaExpr.setValue(this);
return lambdaExpr.resolve(markers, context);
}
use of dyvilx.tools.compiler.ast.attribute.AttributeList in project Dyvil by Dyvil.
the class PropertyBodyParser method configureMethod.
private void configureMethod(IMethod method, IToken token) {
method.setPosition(token.raw());
method.setAttributes(this.attributes);
this.attributes = new AttributeList();
}
Aggregations