use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class TupleExpr method writeExpression.
@Override
public void writeExpression(MethodWriter writer, IType type) throws BytecodeException {
final IType thisType = this.getType();
final String internal = thisType.getInternalName();
writer.visitTypeInsn(Opcodes.NEW, internal);
writer.visitInsn(Opcodes.DUP);
final int arity = this.values.size();
for (int i = 0; i < arity; i++) {
this.values.get(i).writeExpression(writer, Types.OBJECT);
}
final String desc = TupleType.getConstructorDescriptor(arity);
writer.visitMethodInsn(Opcodes.INVOKESPECIAL, internal, "<init>", desc, false);
if (type != null) {
thisType.writeCast(writer, type, this.lineNumber());
}
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class ExternalClass method getMethodMatches.
@Override
public void getMethodMatches(MatchList<IMethod> list, IValue receiver, Name name, ArgumentList arguments) {
this.resolveGenerics();
/*
Note: unlike AbstractClass.getMethodMatches, this does not check the Class Parameter Properties, because
External classes do not have any class parameters with associated properties
*/
this.body.getMethodMatches(list, receiver, name, arguments);
if (list.hasCandidate()) {
return;
}
this.resolveSuperTypes();
if (this.superType != null) {
this.superType.getMethodMatches(list, receiver, name, arguments);
}
if (list.hasCandidate() || this.interfaces == null) {
return;
}
for (IType type : this.interfaces) {
type.getMethodMatches(list, receiver, name, arguments);
}
}
use of dyvilx.tools.compiler.ast.type.IType 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.type.IType in project Dyvil by Dyvil.
the class ClassConstructorCall method resolveCall.
@Override
public IValue resolveCall(MarkerList markers, IContext context, boolean report) {
if (!this.type.isResolved()) {
return this;
}
final IClass theClass = this.type.getTheClass();
if (theClass == null) {
return this;
}
final IType type = theClass.isInterface() ? Types.OBJECT : this.type;
final MatchList<IConstructor> candidates = this.resolveCandidates(context, type);
if (candidates.hasCandidate()) {
this.checkArguments(markers, context, candidates.getBestMember());
return this;
}
if (report) {
reportResolve(markers, candidates, this.position, type, this.arguments);
return this;
}
return null;
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class ConstructorCall method resolveArrayConstructor.
private void resolveArrayConstructor(MarkerList markers, IContext context, ArrayType arrayType) {
final IType elementType = arrayType.getElementType();
if (elementType.hasTag(IType.TYPE_VAR)) {
markers.add(Markers.semanticError(this.position, "constructor.access.array.typevar", elementType));
}
final int len = this.arguments.size();
final int dims = 1 + getDimensions(arrayType.getElementType());
if (len > dims) {
final Marker marker = Markers.semanticError(this.position, "constructor.access.array.length");
marker.addInfo(Markers.getSemantic("type.dimensions", dims));
marker.addInfo(Markers.getSemantic("constructor.access.array.count", len));
markers.add(marker);
return;
}
for (int i = 0; i < len; i++) {
final IValue value = this.arguments.get(i, null);
final IValue typed = TypeChecker.convertValue(value, Types.INT, ITypeContext.DEFAULT, markers, context, TypeChecker.markerSupplier("constructor.access.array.type"));
this.arguments.set(i, null, typed);
}
}
Aggregations