use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class SimpleMethodVisitor method visitEnd.
@Override
public void visitEnd() {
if (this.intrinsicData != null && !this.unsupportedInline) {
this.method.setIntrinsicData(this.intrinsicData);
}
int localIndex = this.method.hasModifier(Modifiers.STATIC) ? 0 : 1;
final ParameterList parameters = this.method.getExternalParameterList();
for (int i = 0, count = parameters.size(); i < count; i++) {
final IParameter param = parameters.get(i);
param.setLocalIndex(localIndex);
if (param.getName() == null) {
param.setName(this.getName(localIndex));
}
localIndex += param.getLocalSlots();
}
}
use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class CompleteCommand method findInstanceMembers.
private static void findInstanceMembers(IType type, Set<IField> fields, Set<IProperty> properties, Set<IMethod> methods, String start, Set<IClass> dejaVu) {
final IClass iclass = type.getTheClass();
if (iclass == null || dejaVu.contains(iclass)) {
return;
}
dejaVu.add(iclass);
// Add members
final ParameterList parameterList = iclass.getParameters();
for (int i = 0, count = parameterList.size(); i < count; i++) {
checkMember(fields, (IField) parameterList.get(i), start, false);
}
findMembers(type, fields, properties, methods, start, false);
// Recursively scan super types
final IType superType = iclass.getSuperType();
if (superType != null) {
findInstanceMembers(superType.getConcreteType(type), fields, properties, methods, start, dejaVu);
}
for (IType interfaceType : iclass.getInterfaces()) {
findInstanceMembers(interfaceType.getConcreteType(type), fields, properties, methods, start, dejaVu);
}
}
use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class Template method makeMainMethod.
private void makeMainMethod() {
// func main(args: [String]) -> void = new TemplateName().mainImpl(args)
final ParameterList params = this.mainMethod.getParameters();
final CodeParameter argsParam = new CodeParameter(this.mainMethod, null, Name.fromRaw("args"), new ArrayType(Types.STRING));
params.add(argsParam);
final IValue newTemplate = new ConstructorCall(null, this.templateClass.getClassType(), ArgumentList.EMPTY);
this.mainMethod.setValue(new MethodCall(null, newTemplate, Name.fromRaw("mainImpl"), new ArgumentList(new FieldAccess(argsParam))));
}
use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class CaseClasses method writeHashCode.
public static void writeHashCode(MethodWriter writer, IClass theClass) throws BytecodeException {
writer.visitLdcInsn(31);
final ParameterList parameters = theClass.getParameters();
for (int i = 0, count = parameters.size(); i < count; i++) {
final IDataMember parameter = parameters.get(i);
// Load the value of the field
writer.visitVarInsn(ALOAD, 0);
parameter.writeGet(writer, null, 0);
// Write the hashing strategy for the parameter
writeHashCode(writer, parameter.getType());
// Add the hash to the previous result
writer.visitInsn(IADD);
writer.visitLdcInsn(31);
// Multiply the result by 31
writer.visitInsn(IMUL);
}
writer.visitInsn(IRETURN);
}
use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class ClassMetadata method resolveTypesBody.
@Override
public void resolveTypesBody(MarkerList markers, IContext context) {
// Check if a constructor needs to be generated
final ClassBody body = this.theClass.getBody();
if (body == null) {
return;
}
this.checkMembers(body);
if (body.constructorCount() <= 0) {
return;
}
final ParameterList parameters = this.theClass.getParameters();
final IConstructor constructor = body.getConstructor(parameters);
if (constructor != null) {
this.constructor = constructor;
this.members |= CONSTRUCTOR;
return;
}
if (parameters.isEmpty()) {
// Do not generate an empty default constructor if there is any other constructor defined
this.members |= CONSTRUCTOR;
}
}
Aggregations