/*
 * Bytecode Analysis Framework
 * Copyright (C) 2003, University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.daveho.ba;

import org.apache.bcel.generic.*;

public class IsNullValueFrameModelingVisitor extends AbstractFrameModelingVisitor<IsNullValue> {

	public IsNullValueFrameModelingVisitor(IsNullValueFrame frame, ConstantPoolGen cpg) {
		super(frame, cpg);
	}

	public IsNullValue getDefaultValue() {
		return IsNullValue.doNotReportValue();
	}

	// Overrides of specific instruction visitor methods.
	// ACONST_NULL obviously produces a value that is DEFINITELY NULL.
	// If a reference value is dereferenced (by a load, store, or
	// method invocation), then afterwards it is NOT NULL.
	// LDC produces values that are NOT NULL.
	// NEW produces values that are NOT NULL.

	// Note that we don't override IFNULL and IFNONNULL.
	// Those are handled in the analysis itself, because we need
	// to produce different values in each of the control successors.

	public void visitACONST_NULL(ACONST_NULL obj) {
		Frame<IsNullValue> frame = getFrame();
		frame.pushValue(IsNullValue.nullValue());
	}

}

// vim:ts=4

@@ -1312,208 +1312,392 @@
 %09// 
-If a referen
+LDC produ
 ce
+s
  value
- is dereferenced (by a load, store, or%0A%09// method invoca
+s that are NOT NULL.%0A%09// NEW produces values that are NOT NULL.%0A%0A%09// Note that all instruc
 tion
-), then afterwards it is NOT NULL.%0A%09// LDC produces values that are NOT NULL.%0A%09// NEW produces values that are NOT NULL.
+s that have an implicit null%0A%09// check (field access, invoke, etc.) are handled in IsNullValueAnalysis,%0A%09// because handling them relies on control flow (the existence of%0A%09// an ETB and exception edge prior to the block containing the%0A%09// instruction with the null check.)
 %0A%0A%09/
@@ -1878,16 +1878,130 @@
 ssors.%0A%0A
+%09private void produce(IsNullValue value) %7B%0A%09%09Frame%3CIsNullValue%3E frame = getFrame();%0A%09%09frame.pushValue(value);%0A%09%7D%0A%0A
 %09public 
@@ -2039,30 +2039,32 @@
 LL obj) %7B%0A%09%09
-Frame%3C
+produce(
 IsNullValue%3E
@@ -2066,46 +2066,144 @@
 alue
-%3E frame = getFrame();%0A%09%09frame.pushValu
+.nullValue());%0A%09%7D%0A%0A%09public void visitNEW(NEW obj) %7B%0A%09%09produce(IsNullValue.nonNullValue());%0A%09%7D%0A%0A%09public void visitLDC(LDC obj) %7B%0A%09%09produc
 e(Is
@@ -2205,32 +2205,35 @@
 ce(IsNullValue.n
+onN
 ullValue());%0A%09%7D%0A

Changed to handle some more instruction types.