projects
/
org.ibex.classgen.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove period between ret type and method name
[org.ibex.classgen.git]
/
src
/
org
/
ibex
/
classgen
/
JSSA.java
diff --git
a/src/org/ibex/classgen/JSSA.java
b/src/org/ibex/classgen/JSSA.java
index
b01d262
..
d14efef
100644
(file)
--- a/
src/org/ibex/classgen/JSSA.java
+++ b/
src/org/ibex/classgen/JSSA.java
@@
-321,7
+321,11
@@
public class JSSA extends MethodGen implements CGConst {
public class Return extends Op {
final Expr e;
public Return() { this(VOID_EXPR); }
public class Return extends Op {
final Expr e;
public Return() { this(VOID_EXPR); }
- public Return(Expr e) { this.e = e; }
+ public Return(Expr e) {
+ this.e = e;
+ if(Type.unify(method.getReturnType(),e.getType()) != method.getReturnType())
+ throw new IllegalArgumentException("type mismatch");
+ }
public String toString() { return e.getType() == Type.VOID ? "return" : ("return "+e.toString()); }
}
public String toString() { return e.getType() == Type.VOID ? "return" : ("return "+e.toString()); }
}
@@
-425,8
+429,9
@@
public class JSSA extends MethodGen implements CGConst {
private final Object o;
public Constant(int i) { this(new Integer(i)); }
public Constant(Object o) { this.o = o; }
private final Object o;
public Constant(int i) { this(new Integer(i)); }
public Constant(Object o) { this.o = o; }
- public String _toString() { return o instanceof String ? "\"" + o + "\"" : o.toString(); }
+ public String _toString() { return o == null ? "null" : o instanceof String ? "\"" + o + "\"" : o.toString(); }
public Type getType() {
public Type getType() {
+ if (o == null) return Type.NULL;
if (o instanceof Byte) return Type.BYTE;
if (o instanceof Short) return Type.SHORT;
if (o instanceof Character) return Type.CHAR;
if (o instanceof Byte) return Type.BYTE;
if (o instanceof Short) return Type.SHORT;
if (o instanceof Character) return Type.CHAR;
@@
-465,8
+470,8
@@
public class JSSA extends MethodGen implements CGConst {
// Stack manipulations //////////////////////////////////////////////////////////////////////////////
// Stack manipulations //////////////////////////////////////////////////////////////////////////////
- case ACONST_NULL: return stack[sp++] = new Constant(null);
- case ICONST_M1: return stack[sp++] = new Constant(-1);
+ case ACONST_NULL: push(new Constant(null)); return null;
+ case ICONST_M1: push(new Constant(-1)); return null;
case ICONST_0: case LCONST_0: case FCONST_0: case DCONST_0: push(new Constant(0)); return null;
case ICONST_1: case LCONST_1: case FCONST_1: case DCONST_1: push(new Constant(1)); return null;
case ICONST_2: case FCONST_2: push(new Constant(2)); return null;
case ICONST_0: case LCONST_0: case FCONST_0: case DCONST_0: push(new Constant(0)); return null;
case ICONST_1: case LCONST_1: case FCONST_1: case DCONST_1: push(new Constant(1)); return null;
case ICONST_2: case FCONST_2: push(new Constant(2)); return null;
@@
-687,7
+692,7
@@
public class JSSA extends MethodGen implements CGConst {
else prefix = "o";
s = prefix + (nextVar++);
bindingMap.put(e,s);
else prefix = "o";
s = prefix + (nextVar++);
bindingMap.put(e,s);
- return "(" + s + ":= " + e._toString() + ")";
+ return "(" + s + " = " + e._toString() + ")";
}
public static void main(String[] args) throws Exception {
}
public static void main(String[] args) throws Exception {