Initial revision

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@859 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 25 years ago
parent 1318566f84
commit 288a4b2980
  1. 67
      jode/jode/expr/OuterLocalOperator.java
  2. 167
      jode/jode/util/SimpleSet.java
  3. 102
      jode/test/AnonymousJavac.java

@ -0,0 +1,67 @@
/* OuterLocalOperator Copyright (C) 1998-1999 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.expr;
import jode.GlobalOptions;
import jode.type.Type;
import jode.decompiler.CodeAnalyzer;
import jode.decompiler.ClassAnalyzer;
import jode.decompiler.LocalInfo;
import jode.decompiler.TabbedPrintWriter;
public class OuterLocalOperator extends Operator {
LocalInfo local;
public OuterLocalOperator(LocalInfo local) {
super(local.getType());
this.local = local;
initOperands(0);
}
public boolean isConstant() {
return true;
}
public int getPriority() {
return 1000;
}
public LocalInfo getLocalInfo() {
return local.getLocalInfo();
}
public void updateSubTypes() {
if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_TYPES) != 0)
GlobalOptions.err.println("setType of "+local.getName()+": "
+local.getType());
local.setType(type);
}
public void updateType() {
}
public Expression simplify() {
return super.simplify();
}
public void dumpExpression(TabbedPrintWriter writer)
throws java.io.IOException {
writer.print(local.getName());
}
}

@ -0,0 +1,167 @@
/* SimpleSet Copyright (C) 1998-1999 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.util;
import java.util.Dictionary;
import java.util.Enumeration;
///#ifdef JDK12
///import java.util.AbstractSet;
///import java.util.Iterator;
///#endif
public class SimpleSet
///#ifdef JDK12
/// extends AbstractSet
///#endif
implements Cloneable
{
Object[] elementObjects = new Object[2];
int count = 0;
public int size() {
return count;
}
public boolean add(Object element) {
if (element == null)
throw new NullPointerException();
for (int i=0; i< count; i++) {
if (element.equals(elementObjects[i]))
return false;
}
if (count == elementObjects.length) {
Object[] newArray = new Object[(count+1)*3/2];
System.arraycopy(elementObjects,0,newArray,0,count);
elementObjects = newArray;
}
elementObjects[count++] = element;
return true;
}
public Enumeration elements() {
return new ArrayEnum(count, elementObjects);
}
public Object clone() {
try {
SimpleSet other = (SimpleSet) super.clone();
if (count > 0) {
other.elementObjects = new Object[count];
System.arraycopy(elementObjects, 0,
other.elementObjects, 0, count);
}
return other;
} catch (CloneNotSupportedException ex) {
throw new jode.AssertError("Clone?");
}
}
///#ifdef JDK12
/// public Iterator iterator() {
/// return new Iterator() {
/// int pos = 0;
///
/// public boolean hasNext() {
/// return pos < count;
/// }
///
/// public Object next() {
/// return elementObjects[pos++];
/// }
///
/// public void remove() {
/// if (pos < count)
/// System.arraycopy(elementObjects, pos,
/// elementObjects, pos-1, count - pos);
/// count--;
/// pos--;
/// }
/// };
/// }
///#else
public boolean isEmpty() {
return count == 0;
}
public boolean addAll(SimpleSet other) {
boolean changed = false;
for (int i=0; i < other.count; i++) {
changed |= add(other.elementObjects[i]);
}
return changed;
}
public boolean contains(Object element) {
for (int i=0; i < count; i++) {
if (elementObjects[i].equals(element))
return true;
}
return false;
}
public boolean remove(Object element) {
for (int i=0; i< count; i++) {
if (elementObjects[i].equals(element)) {
count--;
if (i < count)
elementObjects[i] = elementObjects[count];
return true;
}
}
return false;
}
public boolean retainAll(SimpleSet other) {
int low = 0;
for (int high=0; high < count; high++) {
if (other.contains(elementObjects[high]))
elementObjects[low++] = elementObjects[high];
}
if (count == low)
return false;
count = low;
return true;
}
public boolean removeAll(SimpleSet other) {
int low = 0;
for (int high=0; high < count; high++) {
if (!other.contains(elementObjects[high]))
elementObjects[low++] = elementObjects[high];
}
if (count == low)
return false;
count = low;
return true;
}
public String toString() {
StringBuffer sb = new StringBuffer("{");
String komma = "";
for (int i=0; i< count; i++) {
sb.append(komma).append(elementObjects[i].toString());
komma = ", ";
}
return sb.append("}").toString();
}
///#endif
}

@ -0,0 +1,102 @@
/* AnonymousJavac Copyright (C) 1999 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.test;
import java.util.Vector;
public class AnonymousJavac {
class Inner {
int var = 3;
public void test() {
class Hello {
int var = 4;
Hello() {
System.err.println("construct");
}
Hello(String info) {
System.err.println("construct: "+info);
}
public void hello() {
this.hashCode();
Inner.this.hashCode();
Inner.this.var = var;
AnonymousJavac.this.hashCode();
System.err.println("HelloWorld");
}
};
final Hello hi = new Hello();
final Hello ho = new Hello("ho");
final Object o = new Object() {
int blah = 5;
Hello hii = hi;
public String toString() {
this.hii.hello();
hi.hello();
return Integer.toHexString(AnonymousJavac.this.hashCode()
+blah);
}
};
Object p = new Object() {
public String toString() {
return o.toString();
}
};
// Hello blah = new Hello("Hello World") {
// public void hello() {
// System.err.println("overwritten");
// }
// };
Inner blub1 = new Inner("Inner param") {
public void test() {
System.err.println("overwritten");
}
};
Inner blub2 = new AnonymousJavac().new Inner("Inner param") {
public void test() {
System.err.println("overwritten");
}
};
class Hi extends Inner {
public Hi() {
super("Hi World");
}
}
Vector v = new Vector(hi.var, var) {
public String toString() {
return super.toString();
}
};
Hi hu = new Hi();
}
Inner (String str) {
}
}
}
Loading…
Cancel
Save