Search in sources :

Example 1 with ICallableMember

use of dyvilx.tools.compiler.ast.method.ICallableMember in project Dyvil by Dyvil.

the class IParameter method writeGetDefaultValue.

default void writeGetDefaultValue(MethodWriter writer) {
    final ICallableMember method = this.getMethod();
    final IClass enclosingClass = this.getEnclosingClass();
    final String name = (method == null ? DEFAULT_PREFIX_INIT : method.getInternalName() + DEFAULT_PREFIX) + this.getInternalName();
    final String desc = "()" + this.getDescriptor();
    writer.visitMethodInsn(Opcodes.INVOKESTATIC, enclosingClass.getInternalName(), name, desc, enclosingClass.isInterface());
}
Also used : ICallableMember(dyvilx.tools.compiler.ast.method.ICallableMember) IClass(dyvilx.tools.compiler.ast.classes.IClass)

Example 2 with ICallableMember

use of dyvilx.tools.compiler.ast.method.ICallableMember in project Dyvil by Dyvil.

the class IParameter method writeDefaultValue.

default void writeDefaultValue(ClassWriter writer) {
    final IValue value = this.getValue();
    assert value != null;
    final ICallableMember method = this.getMethod();
    final IType type = this.getType();
    final String name;
    final int access;
    if (method == null) {
        name = "init$paramDefault$" + this.getInternalName();
        access = Modifiers.STATIC;
    } else {
        name = method.getInternalName() + "$paramDefault$" + this.getInternalName();
        access = (method.getAttributes().flags() & Modifiers.MEMBER_MODIFIERS) | Modifiers.STATIC;
    }
    final String desc = "()" + this.getDescriptor();
    final String signature = "()" + this.getSignature();
    final MethodWriter mw = new MethodWriterImpl(writer, writer.visitMethod(access, name, desc, signature, null));
    mw.visitCode();
    value.writeExpression(mw, type);
    mw.visitEnd(type);
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) MethodWriterImpl(dyvilx.tools.compiler.backend.MethodWriterImpl) MethodWriter(dyvilx.tools.compiler.backend.MethodWriter) ICallableMember(dyvilx.tools.compiler.ast.method.ICallableMember) IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

ICallableMember (dyvilx.tools.compiler.ast.method.ICallableMember)2 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IValue (dyvilx.tools.compiler.ast.expression.IValue)1 IType (dyvilx.tools.compiler.ast.type.IType)1 MethodWriter (dyvilx.tools.compiler.backend.MethodWriter)1 MethodWriterImpl (dyvilx.tools.compiler.backend.MethodWriterImpl)1