protected void setupClassBody(ClassBody n) throws SemanticException { ClassBodyInfo newCDI = new ClassBodyInfo(); newCDI.outer = currCBI; currCBI = newCDI; // set up currClassFinalFieldInitCounts to contain mappings // for all the final fields of the class. Iterator classMembers = n.members().iterator(); while (classMembers.hasNext()) { ClassMember cm = (ClassMember) classMembers.next(); if (cm instanceof FieldDecl) { FieldDecl fd = (FieldDecl) cm; if (fd.flags().isFinal()) { MinMaxInitCount initCount; if (fd.init() != null) { // the field has an initializer initCount = new MinMaxInitCount(InitCount.ONE, InitCount.ONE); // do dataflow over the initialization expression // to pick up any uses of outer local variables. if (currCBI.outer != null) dataflow(fd.init()); } else { // the field does not have an initializer initCount = new MinMaxInitCount(InitCount.ZERO, InitCount.ZERO); } newCDI.currClassFinalFieldInitCounts.put(fd.fieldInstance(), initCount); } } } }
/** * Initialise the FlowGraph to be used in the dataflow analysis. * * @return null if no dataflow analysis should be performed for this code declaration; otherwise, * an apropriately initialized FlowGraph. */ protected FlowGraph initGraph(CodeDecl code, Term root) { currCBI.currCodeDecl = code; return new FlowGraph(root, forward); }