git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@753 379699f6-c40d-0410-875b-85095c16579estable
parent
bcc5262d63
commit
aaf2d4ab6b
@ -0,0 +1,66 @@ |
||||
/* ThisOperator 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.type.Type; |
||||
import jode.bytecode.ClassInfo; |
||||
import jode.decompiler.TabbedPrintWriter; |
||||
|
||||
public class ThisOperator extends NoArgOperator { |
||||
boolean isInnerMost; |
||||
ClassInfo classInfo; |
||||
|
||||
public ThisOperator(ClassInfo classInfo, boolean isInnerMost) { |
||||
super(Type.tClass(classInfo)); |
||||
this.classInfo = classInfo; |
||||
this.isInnerMost = isInnerMost; |
||||
} |
||||
|
||||
public ThisOperator(ClassInfo classInfo) { |
||||
this(classInfo, false); |
||||
} |
||||
|
||||
public ClassInfo getClassInfo() { |
||||
return classInfo; |
||||
} |
||||
|
||||
public int getPriority() { |
||||
return 1000; |
||||
} |
||||
|
||||
public String toString() { |
||||
return classInfo+".this"; |
||||
} |
||||
|
||||
public boolean equals(Object o) { |
||||
return (o instanceof ThisOperator && |
||||
((ThisOperator) o).classInfo.equals(classInfo)); |
||||
} |
||||
|
||||
public void dumpExpression(TabbedPrintWriter writer, |
||||
Expression[] operands) |
||||
throws java.io.IOException { |
||||
if (!isInnerMost) { |
||||
writer.print(writer.getClassString(classInfo)); |
||||
writer.print("."); |
||||
} |
||||
writer.print("this"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,55 @@ |
||||
/* AnonymousClass 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; |
||||
|
||||
public class AnonymousClass { |
||||
class Inner { |
||||
public void test() { |
||||
class Hello { |
||||
Hello() { |
||||
System.err.println("construct"); |
||||
} |
||||
Hello(String info) { |
||||
System.err.println("construct: "+info); |
||||
} |
||||
|
||||
void hello() { |
||||
this.hashCode(); |
||||
Inner.this.hashCode(); |
||||
AnonymousClass.this.hashCode(); |
||||
System.err.println("HelloWorld"); |
||||
} |
||||
}; |
||||
final Hello hi = new Hello(); |
||||
final Hello ho = new Hello("ho"); |
||||
final Object o = new Object() { |
||||
public String toString() { |
||||
hi.hello(); |
||||
return Integer.toHexString(AnonymousClass.this.hashCode()); |
||||
} |
||||
}; |
||||
Object p = new Object() { |
||||
public String toString() { |
||||
return o.toString(); |
||||
} |
||||
}; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
package jode.test; |
||||
|
||||
/** |
||||
* This class tests name conflicts and their resolvation. |
||||
*/ |
||||
public class Conflicts { |
||||
int Conflicts; |
||||
|
||||
class Inner { |
||||
int Conflicts; |
||||
|
||||
void Conflicts() { |
||||
int Conflicts = 4; |
||||
Conflicts(); |
||||
new Object() { |
||||
void Inner() { |
||||
jode.test.Conflicts.this.Inner(); |
||||
} |
||||
}; |
||||
this.Conflicts = Conflicts; |
||||
Inner(); |
||||
jode.test.Conflicts.this.Conflicts = this.Conflicts; |
||||
} |
||||
|
||||
jode.test.Conflicts Conflicts(Inner Conflicts) { |
||||
return jode.test.Conflicts.this; |
||||
} |
||||
} |
||||
|
||||
public void Inner() { |
||||
} |
||||
|
||||
class Second { |
||||
class Inner { |
||||
} |
||||
void create() { |
||||
new Inner(); |
||||
jode.test.Conflicts.this.new Inner(); |
||||
} |
||||
} |
||||
|
||||
|
||||
public Conflicts() { |
||||
int Conflicts = this.Conflicts; |
||||
Inner Inner = new Inner(); |
||||
Inner.Conflicts = 5; |
||||
new Inner().Conflicts(Inner).Inner(); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,35 @@ |
||||
package jode.test; |
||||
|
||||
public class InnerCompat { |
||||
int x; |
||||
|
||||
private class privateNeedThis { |
||||
void a() { x = 5; } |
||||
} |
||||
protected class protectedNeedThis { |
||||
void a() { x = 5; } |
||||
} |
||||
class packageNeedThis { |
||||
void a() { x = 5; } |
||||
} |
||||
public class publicNeedThis { |
||||
void a() { x = 5; } |
||||
} |
||||
private class privateNeedNotThis { |
||||
int x; |
||||
void a() { x = 5; } |
||||
} |
||||
protected class protectedNeedNotThis { |
||||
int x; |
||||
void a() { x = 5; } |
||||
} |
||||
class packageNeedNotThis { |
||||
int x; |
||||
void a() { x = 5; } |
||||
} |
||||
public class publicNeedNotThis { |
||||
int x; |
||||
void a() { x = 5; } |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue