Initial revision

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@116 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 394e733b1c
commit efbdca398f
  1. 49
      jode/jode/flow/DescriptionBlock.java
  2. 114
      jode/jode/type/UnfoundClassType.java

@ -0,0 +1,49 @@
/*
* DescriptionBlock (c) 1998 Jochen Hoenicke
*
* You may distribute under the terms of the GNU General Public License.
*
* IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
* THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
* BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* $Id$
*/
package jode.flow;
import jode.TabbedPrintWriter;
/**
* This is a block which contains a comment/description of what went
* wrong. Use this, if you want to tell the user, that a construct
* doesn't have the exspected form.
*
* @author Jochen Hoenicke
*/
public class DescriptionBlock extends StructuredBlock {
String description;
public DescriptionBlock(String description) {
this.description = description;
}
/**
* Tells if this block is empty and only changes control flow.
*/
public boolean isEmpty() {
return true;
}
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{
writer.println(description);
}
}

@ -0,0 +1,114 @@
/* UnfoundClassType Copyright (C) 1997-1998 Jochen Hoenicke.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
package jode;
import java.util.Vector;
import java.util.Stack;
/**
* This class represents a type aproximation, consisting of multiple
* interfaces and a class type.<p>
*
* If this is the bottom boundary, this specifies, which class our
* type must extend and which interfaces it must implement.
*
* If this is the top boundary, this gives all interfaces and classes
* that may extend the type. I.e. the type may be one of the
* interfaces or the class type or any of their super types.
*
* @author Jochen Hoenicke */
public class UnfoundClassType extends Type {
String clazzName;
public UnfoundClassType(String clazzName) {
super(TC_UCLASS);
this.clazzName = clazzName;
}
/**
* Create the type corresponding to the range from bottomType to
* this. Checks if the given type range may be not empty. This
* means, that bottom.clazz is extended by this.clazz and that all
* interfaces in bottom are implemented by an interface or by
* clazz.
* @param bottom the start point of the range
* @return the range type, or tError if range is empty.
*/
public Type createRangeType(Type bottomType) {
/* Unknown classes are only compatible to tObject and themself.
*/
if (bottomType == tUnknown || bottomType == tObject)
return tRange(tObject, this);
if (!bottomType.equals(this))
return tError;
return this;
}
/**
* Returns the specialized type of this and type.
* We have two classes and multiple interfaces. The result
* should be the object that extends both objects
* and the union of all interfaces.
*/
public Type getSpecializedType(Type type) {
return (type.typecode == TC_UNKNOWN
|| type == tObject || type.equals(this)) ? this : tError;
}
/**
* Returns the generalized type of this and type. We have two
* classes and multiple interfaces. The result should be the
* object that is the the super class of both objects and all
* interfaces, that one class or interface of each type
* implements. */
public Type getGeneralizedType(Type type) {
int code = type.typecode;
if (code == TC_UNKNOWN || type.equals(this))
return this;
if (code == TC_ARRAY || code == TC_CLASS || code == TC_UCLASS)
return tObject;
return tError;
}
/**
* Marks this type as used, so that the class is imported.
*/
public void useType() {
env.useClass(clazzName);
}
public String toString()
{
return env.classString(clazzName);
}
public boolean isClassType() {
return true;
}
public boolean equals(Object o) {
return o == this
|| (o instanceof UnfoundClassType
&& ((UnfoundClassType)o).clazzName.equals(clazzName));
}
}
Loading…
Cancel
Save