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

The following examples show how to use org.codehaus.groovy.ast.expr.NotExpression. 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: StaticTypesUnaryExpressionHelper.java    From groovy with Apache License 2.0 6 votes vote down vote up
@Override
public void writeNotExpression(final NotExpression expression) {
    TypeChooser typeChooser = controller.getTypeChooser();
    Expression subExpression = expression.getExpression();
    ClassNode classNode = controller.getClassNode();
    if (typeChooser.resolveType(subExpression, classNode) == boolean_TYPE) {
        subExpression.visit(controller.getAcg());
        controller.getOperandStack().doGroovyCast(boolean_TYPE);
        BytecodeExpression bytecodeExpression = bytecodeX(mv -> {
            Label ne = new Label();
            mv.visitJumpInsn(IFNE, ne);
            mv.visitInsn(ICONST_1);
            Label out = new Label();
            mv.visitJumpInsn(GOTO, out);
            mv.visitLabel(ne);
            mv.visitInsn(ICONST_0);
            mv.visitLabel(out);
        });
        bytecodeExpression.visit(controller.getAcg());
        controller.getOperandStack().remove(1);
        return;
    }
    super.writeNotExpression(expression);
}
 
Example #2
Source File: ASTNodeVisitor.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
public void visitNotExpression(NotExpression node) {
	pushASTNode(node);
	try {
		super.visitNotExpression(node);
	} finally {
		popASTNode();
	}
}
 
Example #3
Source File: BooleanExpressionTransformer.java    From groovy with Apache License 2.0 5 votes vote down vote up
Expression transformBooleanExpression(final BooleanExpression booleanExpression) {
    if (booleanExpression instanceof NotExpression) {
        return transformer.superTransform(booleanExpression);
    }
    final Expression expression = booleanExpression.getExpression();
    if (!(expression instanceof BinaryExpression)) {
        StaticTypesTypeChooser typeChooser = transformer.getTypeChooser();
        final ClassNode type = typeChooser.resolveType(expression, transformer.getClassNode());
        BooleanExpression transformed = new OptimizingBooleanExpression(transformer.transform(expression),type);
        transformed.setSourcePosition(booleanExpression);
        transformed.copyNodeMetaData(booleanExpression);
        return transformed;
    }
    return transformer.superTransform(booleanExpression);
}
 
Example #4
Source File: BinaryExpressionHelper.java    From groovy with Apache License 2.0 5 votes vote down vote up
private void evaluateNotInstanceof(final BinaryExpression expression) {
    unaryExpressionHelper.writeNotExpression(
            new NotExpression(
                    new BinaryExpression(
                            expression.getLeftExpression(),
                            GeneralUtils.INSTANCEOF,
                            expression.getRightExpression()
                    )
            )
    );
}
 
Example #5
Source File: UnaryExpressionHelper.java    From groovy with Apache License 2.0 5 votes vote down vote up
public void writeNotExpression(NotExpression expression) {
    Expression subExpression = expression.getExpression();
    int mark = controller.getOperandStack().getStackLength();
    subExpression.visit(controller.getAcg());
    controller.getOperandStack().castToBool(mark, true);
    BytecodeHelper.negateBoolean(controller.getMethodVisitor());
    controller.getAssertionWriter().record(expression);
}
 
Example #6
Source File: PathFinderVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(NotExpression node) {
    if (isInside(node, line, column)) {
        super.visitNotExpression(node);
    }
}
 
Example #7
Source File: ASTFinder.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(final NotExpression expression) {
    super.visitNotExpression(expression);
    tryFind(NotExpression.class, expression);
}
 
Example #8
Source File: ContextualClassCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(final NotExpression expression) {
    pushContext(expression);
    super.visitNotExpression(expression);
    popContext();
}
 
Example #9
Source File: SecureASTCustomizer.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(final NotExpression expression) {
    assertExpressionAuthorized(expression);
    expression.getExpression().visit(this);
}
 
Example #10
Source File: TransformingCodeVisitor.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(final NotExpression expression) {
    super.visitNotExpression(expression);
    trn.visitNotExpression(expression);
}
 
Example #11
Source File: CodeVisitorSupport.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(NotExpression expression) {
    expression.getExpression().visit(this);
}
 
Example #12
Source File: GeneralUtils.java    From groovy with Apache License 2.0 4 votes vote down vote up
public static NotExpression notX(final Expression expr) {
    return new NotExpression(expr instanceof BooleanExpression ? expr : boolX(expr));
}
 
Example #13
Source File: AsmClassGenerator.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitNotExpression(final NotExpression expression) {
    controller.getUnaryExpressionHelper().writeNotExpression(expression);
}
 
Example #14
Source File: GroovyCodeVisitor.java    From groovy with Apache License 2.0 votes vote down vote up
void visitNotExpression(NotExpression expression);