} }); }
if (type.isArrayType()) { JExpression[] dims = ((CArrayType)type).getDims(); if (dims.length == 1 && dims[0] instanceof JIntLiteral) { noticeArrayCreation (ident, ((JIntLiteral)dims[0]).intValue()); } else { invalidateField(ident); } } } }); }
    private void findCandidates(SIRStream filter)    {        JFieldDeclaration[] fields = filter.getFields();        for (int i = 0; i < fields.length; i++)        {            // WTF: the visitor should only be necessary if             // field declarations can be nested.  Else simple            // loop should do.            fields[i].accept(new SLIREmptyVisitor() {                    public void visitFieldDeclaration(JFieldDeclaration self,                                                      int modifiers,                                                      CType type,                                                      String ident,                                                      JExpression expr)                    {                        // add entry to name->type mapping                        types.put(ident, type);                    }                });        }        JMethodDeclaration[] meths = filter.getMethods();        for (int i = 0; i < meths.length; i++)        {            meths[i].accept(new SLIREmptyVisitor() {                    public void visitAssignmentExpression                        (JAssignmentExpression self,                         JExpression left,                         JExpression right)                    {                        super.visitAssignmentExpression(self, left, right);                        if (left instanceof JFieldAccessExpression)                        {                            JFieldAccessExpression fae =                                (JFieldAccessExpression)left;                            String name = fae.getIdent();                            // Look inside of fae; the left-hand side should                            // be this.                            if (!(fae.getPrefix() instanceof JThisExpression))                                return;                            // Okay; what's the right hand side?  Notice                            // if it's a literal or (new type[]); invalidate                            // otherwise.                            if (right instanceof JLiteral)                                noticeFieldAssignment(name, right);                            else if (right instanceof JNewArrayExpression)                            {                                JNewArrayExpression nae =                                    (JNewArrayExpression)right;                                JExpression[] dims = nae.getDims();                                if (dims.length == 1 &&                                    dims[0] instanceof JIntLiteral)                                {                                    noticeArrayCreation                                        (name,                                         ((JIntLiteral)dims[0]).intValue());                                }                                else                                    invalidateField(name);                            }                            else                                invalidateField(name);                        }                        else if (left instanceof JArrayAccessExpression)                        {                            JArrayAccessExpression aae =                                (JArrayAccessExpression)left;                            // Check that the prefix is a FieldAccessExpr.                            // Same rules as above.                            JExpression prefix = aae.getPrefix();                            if (!(prefix instanceof JFieldAccessExpression))                                return;                            JFieldAccessExpression fae =                                (JFieldAccessExpression)prefix;                            String name = fae.getIdent();                            if (!(fae.getPrefix() instanceof JThisExpression))                                return;                            // Also check that the offset is constant.                            // If it's not, invalidate the whole thing.                            JExpression accessor = aae.getAccessor();                            if (!(accessor instanceof JIntLiteral))                            {                                invalidateField(name);                                return;                            }                            int slot = ((JIntLiteral)accessor).intValue();                            // Now look at the right-hand side.                            if (right instanceof JLiteral)                                noticeArrayAssignment(name, slot, right);                            else                                invalidateArray(name, slot);                        }                    }                    public void visitCompoundAssignmentExpression                        (JCompoundAssignmentExpression self,                         int oper,                         JExpression left,                         JExpression right)                    {                        super.visitCompoundAssignmentExpression                            (self, oper, left, right);                        // Instant death.                        invalidateExpression(left);                    }                    public void visitPrefixExpression                        (JPrefixExpression self,                         int oper,                         JExpression expr)                    {                        super.visitPrefixExpression(self, oper, expr);                        // Again, instant death.                        invalidateExpression(expr);                    }                    public void visitPostfixExpression                        (JPostfixExpression self,                         int oper,                         JExpression expr)                    {                        super.visitPostfixExpression(self, oper, expr);                        // Again, instant death.                        invalidateExpression(expr);                    }                });        }    }