Search in sources :

Example 1 with MethodCallerMultiAdapter

use of org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter in project groovy-core by groovy.

the class AsmClassGenerator method visitAttributeExpression.

public void visitAttributeExpression(AttributeExpression expression) {
    Expression objectExpression = expression.getObjectExpression();
    MethodCallerMultiAdapter adapter;
    OperandStack operandStack = controller.getOperandStack();
    int mark = operandStack.getStackLength() - 1;
    if (controller.getCompileStack().isLHS()) {
        adapter = setField;
        if (isGroovyObject(objectExpression))
            adapter = setGroovyObjectField;
        if (usesSuper(expression))
            adapter = setFieldOnSuper;
    } else {
        adapter = getField;
        if (isGroovyObject(objectExpression))
            adapter = getGroovyObjectField;
        if (usesSuper(expression))
            adapter = getFieldOnSuper;
    }
    visitAttributeOrProperty(expression, adapter);
    if (!controller.getCompileStack().isLHS()) {
        controller.getAssertionWriter().record(expression.getProperty());
    } else {
        operandStack.remove(operandStack.getStackLength() - mark);
    }
}
Also used : MethodCallerMultiAdapter(org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter) OperandStack(org.codehaus.groovy.classgen.asm.OperandStack)

Example 2 with MethodCallerMultiAdapter

use of org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter in project groovy-core by groovy.

the class AsmClassGenerator method visitPropertyExpression.

public void visitPropertyExpression(PropertyExpression expression) {
    Expression objectExpression = expression.getObjectExpression();
    OperandStack operandStack = controller.getOperandStack();
    int mark = operandStack.getStackLength() - 1;
    MethodCallerMultiAdapter adapter;
    if (controller.getCompileStack().isLHS()) {
        //operandStack.box();
        adapter = setProperty;
        if (isGroovyObject(objectExpression))
            adapter = setGroovyObjectProperty;
        if (isThisOrSuperInStaticContext(objectExpression))
            adapter = setProperty;
    } else {
        adapter = getProperty;
        if (isGroovyObject(objectExpression))
            adapter = getGroovyObjectProperty;
        if (isThisOrSuperInStaticContext(objectExpression))
            adapter = getProperty;
    }
    visitAttributeOrProperty(expression, adapter);
    if (controller.getCompileStack().isLHS()) {
        // remove surplus values
        operandStack.remove(operandStack.getStackLength() - mark);
    } else {
        controller.getAssertionWriter().record(expression.getProperty());
    }
}
Also used : OperandStack(org.codehaus.groovy.classgen.asm.OperandStack) MethodCallerMultiAdapter(org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter)

Example 3 with MethodCallerMultiAdapter

use of org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter in project groovy by apache.

the class AsmClassGenerator method visitAttributeExpression.

public void visitAttributeExpression(AttributeExpression expression) {
    Expression objectExpression = expression.getObjectExpression();
    MethodCallerMultiAdapter adapter;
    OperandStack operandStack = controller.getOperandStack();
    int mark = operandStack.getStackLength() - 1;
    if (controller.getCompileStack().isLHS()) {
        adapter = setField;
        if (isGroovyObject(objectExpression))
            adapter = setGroovyObjectField;
        if (usesSuper(expression))
            adapter = setFieldOnSuper;
    } else {
        adapter = getField;
        if (isGroovyObject(objectExpression))
            adapter = getGroovyObjectField;
        if (usesSuper(expression))
            adapter = getFieldOnSuper;
    }
    visitAttributeOrProperty(expression, adapter);
    if (!controller.getCompileStack().isLHS()) {
        controller.getAssertionWriter().record(expression.getProperty());
    } else {
        operandStack.remove(operandStack.getStackLength() - mark);
    }
}
Also used : MethodCallerMultiAdapter(org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter) OperandStack(org.codehaus.groovy.classgen.asm.OperandStack)

Example 4 with MethodCallerMultiAdapter

use of org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter in project groovy by apache.

the class AsmClassGenerator method visitPropertyExpression.

public void visitPropertyExpression(PropertyExpression expression) {
    Expression objectExpression = expression.getObjectExpression();
    OperandStack operandStack = controller.getOperandStack();
    int mark = operandStack.getStackLength() - 1;
    MethodCallerMultiAdapter adapter;
    if (controller.getCompileStack().isLHS()) {
        //operandStack.box();
        adapter = setProperty;
        if (isGroovyObject(objectExpression))
            adapter = setGroovyObjectProperty;
        if (isThisOrSuperInStaticContext(objectExpression))
            adapter = setProperty;
    } else {
        adapter = getProperty;
        if (isGroovyObject(objectExpression))
            adapter = getGroovyObjectProperty;
        if (isThisOrSuperInStaticContext(objectExpression))
            adapter = getProperty;
    }
    visitAttributeOrProperty(expression, adapter);
    if (controller.getCompileStack().isLHS()) {
        // remove surplus values
        operandStack.remove(operandStack.getStackLength() - mark);
    } else {
        controller.getAssertionWriter().record(expression.getProperty());
    }
}
Also used : OperandStack(org.codehaus.groovy.classgen.asm.OperandStack) MethodCallerMultiAdapter(org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter)

Aggregations

MethodCallerMultiAdapter (org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter)4 OperandStack (org.codehaus.groovy.classgen.asm.OperandStack)4