org.codehaus.groovy.ast.expr.UnaryMinusExpression Java Examples

The following examples show how to use org.codehaus.groovy.ast.expr.UnaryMinusExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ASTNodeVisitor.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
public void visitUnaryMinusExpression(UnaryMinusExpression node) {
	pushASTNode(node);
	try {
		super.visitUnaryMinusExpression(node);
	} finally {
		popASTNode();
	}
}
 
Example #2
Source File: UnaryExpressionHelper.java    From groovy with Apache License 2.0 5 votes vote down vote up
public void writeUnaryMinus(UnaryMinusExpression expression) {
    Expression subExpression = expression.getExpression();
    subExpression.visit(controller.getAcg());
    controller.getOperandStack().box();
    unaryMinus.call(controller.getMethodVisitor());
    controller.getOperandStack().replace(ClassHelper.OBJECT_TYPE);
    controller.getAssertionWriter().record(expression);
}
 
Example #3
Source File: StaticTypesUnaryExpressionHelper.java    From groovy with Apache License 2.0 5 votes vote down vote up
@Override
public void writeUnaryMinus(final UnaryMinusExpression expression) {
    expression.getExpression().visit(controller.getAcg());
    if (isPrimitiveOnTop()) {
        ClassNode top = getTopOperand();
        if (top != boolean_TYPE) {
            BytecodeExpression bytecodeExpression = bytecodeX(mv -> {
                if (int_TYPE == top || short_TYPE == top || byte_TYPE == top || char_TYPE == top) {
                    mv.visitInsn(INEG);
                    if (byte_TYPE == top) {
                        mv.visitInsn(I2B);
                    } else if (char_TYPE == top) {
                        mv.visitInsn(I2C);
                    } else if (short_TYPE == top) {
                        mv.visitInsn(I2S);
                    }
                } else if (long_TYPE == top) {
                    mv.visitInsn(LNEG);
                } else if (float_TYPE == top) {
                    mv.visitInsn(FNEG);
                } else if (double_TYPE == top) {
                    mv.visitInsn(DNEG);
                }
            });
            bytecodeExpression.visit(controller.getAcg());
            controller.getOperandStack().remove(1);
            return;
        }
    }
    // we already visited the sub expression
    super.writeUnaryMinus(EMPTY_UNARY_MINUS);
}
 
Example #4
Source File: PathFinderVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(UnaryMinusExpression node) {
    if (isInside(node, line, column)) {
        super.visitUnaryMinusExpression(node);
    }
}
 
Example #5
Source File: ASTFinder.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    super.visitUnaryMinusExpression(expression);
    tryFind(UnaryMinusExpression.class, expression);
}
 
Example #6
Source File: ContextualClassCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    pushContext(expression);
    super.visitUnaryMinusExpression(expression);
    popContext();
}
 
Example #7
Source File: SecureASTCustomizer.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    assertExpressionAuthorized(expression);
    expression.getExpression().visit(this);
}
 
Example #8
Source File: TransformingCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    super.visitUnaryMinusExpression(expression);
    trn.visitUnaryMinusExpression(expression);
}
 
Example #9
Source File: CodeVisitorSupport.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(UnaryMinusExpression expression) {
    expression.getExpression().visit(this);
}
 
Example #10
Source File: AsmClassGenerator.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    controller.getUnaryExpressionHelper().writeUnaryMinus(expression);
}
 
Example #11
Source File: OptimizingStatementWriter.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitUnaryMinusExpression(final UnaryMinusExpression expression) {
    // TODO: implement int operations for this
    super.visitUnaryMinusExpression(expression);
    addMeta(expression).type = OBJECT_TYPE;
}
 
Example #12
Source File: GroovyCodeVisitor.java    From groovy with Apache License 2.0 votes vote down vote up
void visitUnaryMinusExpression(UnaryMinusExpression expression);