use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.
the class ExternalMethod method resolveExceptions.
private void resolveExceptions() {
if (this.exceptions == null || (this.resolved & EXCEPTIONS) != 0) {
return;
}
this.resolved |= EXCEPTIONS;
if (this.exceptions != null) {
final IContext context = this.getExternalContext();
this.exceptions.resolveTypes(null, context);
}
}
use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.
the class ClassUnit method check.
@Override
public void check() {
this.pack.check(this.packageDeclaration, this.markers);
if (this.headerDeclaration != null) {
this.headerDeclaration.check(this.markers);
}
final IContext context = this.getContext();
for (int i = 0; i < this.classCount; i++) {
this.classes[i].check(this.markers, context);
}
}
use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.
the class Initializer method resolve.
@Override
public void resolve(MarkerList markers, IContext context) {
super.resolve(markers, context);
if (this.value != null) {
final IContext context1 = new CombiningContext(this, context);
final IValue resolved = this.value.resolve(markers, context1);
this.value = TypeChecker.convertValue(resolved, Types.VOID, Types.VOID, markers, context1, TypeChecker.markerSupplier("initializer.type"));
}
}
use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.
the class IDataMember method checkAssign.
default IValue checkAssign(MarkerList markers, IContext context, SourcePosition position, IValue receiver, IValue newValue) {
if (this.hasModifier(Modifiers.FINAL) && !context.isConstructor()) {
markers.add(Markers.semanticError(position, this.getKind().getName() + ".assign.final", this.getName()));
}
final IType type = this.getType();
final ITypeContext typeContext = receiver == null ? ITypeContext.NULL : receiver.getType();
final TypeChecker.MarkerSupplier markerSupplier = (errorPosition, expected, actual) -> {
final String kindName = this.getKind().getName();
final Marker marker = Markers.semanticError(errorPosition, kindName + ".assign.type", this.getName());
marker.addInfo(Markers.getSemantic(kindName + ".type", expected));
marker.addInfo(Markers.getSemantic("value.type", actual));
return marker;
};
return TypeChecker.convertValue(newValue, type, typeContext, markers, context, markerSupplier);
}
use of dyvilx.tools.compiler.ast.context.IContext in project Dyvil by Dyvil.
the class Property method resolve.
@Override
public void resolve(MarkerList markers, IContext context) {
super.resolve(markers, context);
if (this.getter != null) {
this.getter.resolve(markers, context);
// Infer Type if necessary
if (this.type == Types.UNKNOWN) {
this.type = this.getter.getType();
if (this.setterParameter != null) {
this.setterParameter.setType(this.type);
}
}
}
if (this.type == Types.UNKNOWN) {
markers.add(Markers.semanticError(this.position, "property.type.infer", this.name));
}
if (this.setter != null) {
this.setter.resolve(markers, context);
}
if (this.initializer != null) {
final IContext context1 = new CombiningContext(this, context);
final IValue resolved = this.initializer.resolve(markers, context1);
this.initializer = TypeChecker.convertValue(resolved, Types.VOID, Types.VOID, markers, context1, TypeChecker.markerSupplier("property.initializer.type"));
}
}
Aggregations