diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-06-05 16:05:18 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-06-05 16:05:18 +0000 |
commit | 134ee70a9fd4959cbf6b9b6f3b9d1498247ec1e5 (patch) | |
tree | a285eba6f305608f805b36bcb89fecd6e6b00ca9 /src/main/javassist/expr | |
parent | fa03e04037cdfed164d5cab7025e1b2f9fe03a22 (diff) | |
download | javassist-134ee70a9fd4959cbf6b9b6f3b9d1498247ec1e5.tar.gz javassist-134ee70a9fd4959cbf6b9b6f3b9d1498247ec1e5.zip |
Changed subclasses of javassist.expr.Expr so that $_ is always initialized.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@109 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/expr')
-rw-r--r-- | src/main/javassist/expr/Cast.java | 4 | ||||
-rw-r--r-- | src/main/javassist/expr/FieldAccess.java | 13 | ||||
-rw-r--r-- | src/main/javassist/expr/Instanceof.java | 4 | ||||
-rw-r--r-- | src/main/javassist/expr/MethodCall.java | 6 | ||||
-rw-r--r-- | src/main/javassist/expr/NewExpr.java | 4 |
5 files changed, 31 insertions, 0 deletions
diff --git a/src/main/javassist/expr/Cast.java b/src/main/javassist/expr/Cast.java index 80ad4012..160698ff 100644 --- a/src/main/javassist/expr/Cast.java +++ b/src/main/javassist/expr/Cast.java @@ -113,6 +113,10 @@ public class Cast extends Expr { Bytecode bytecode = jc.getBytecode(); storeStack(params, true, paramVar, bytecode); jc.recordLocalVariables(ca, pos); + + bytecode.addConstZero(retType); + bytecode.addStore(retVar, retType); // initialize $_ + jc.compileStmnt(statement); bytecode.addLoad(retVar, retType); diff --git a/src/main/javassist/expr/FieldAccess.java b/src/main/javassist/expr/FieldAccess.java index 8598f456..954c3413 100644 --- a/src/main/javassist/expr/FieldAccess.java +++ b/src/main/javassist/expr/FieldAccess.java @@ -174,6 +174,8 @@ public class FieldAccess extends Expr { /* Is $_ included in the source code? */ boolean included = checkResultValue(retType, statement); + if (read) + included = true; int retVar = jc.recordReturnType(retType, included); if (read) @@ -189,6 +191,17 @@ public class FieldAccess extends Expr { Bytecode bytecode = jc.getBytecode(); storeStack(params, isStatic(), paramVar, bytecode); jc.recordLocalVariables(ca, pos); + + if (included) + if (retType == CtClass.voidType) { + bytecode.addOpcode(ACONST_NULL); + bytecode.addAstore(retVar); + } + else { + bytecode.addConstZero(retType); + bytecode.addStore(retVar, retType); // initialize $_ + } + jc.compileStmnt(statement); if (read) bytecode.addLoad(retVar, retType); diff --git a/src/main/javassist/expr/Instanceof.java b/src/main/javassist/expr/Instanceof.java index a0982583..2cb9790b 100644 --- a/src/main/javassist/expr/Instanceof.java +++ b/src/main/javassist/expr/Instanceof.java @@ -118,6 +118,10 @@ public class Instanceof extends Expr { Bytecode bytecode = jc.getBytecode(); storeStack(params, true, paramVar, bytecode); jc.recordLocalVariables(ca, pos); + + bytecode.addConstZero(retType); + bytecode.addStore(retVar, retType); // initialize $_ + jc.compileStmnt(statement); bytecode.addLoad(retVar, retType); diff --git a/src/main/javassist/expr/MethodCall.java b/src/main/javassist/expr/MethodCall.java index 28ed8d2d..1e0a842d 100644 --- a/src/main/javassist/expr/MethodCall.java +++ b/src/main/javassist/expr/MethodCall.java @@ -211,6 +211,12 @@ public class MethodCall extends Expr { Bytecode bytecode = jc.getBytecode(); storeStack(params, c == INVOKESTATIC, paramVar, bytecode); jc.recordLocalVariables(ca, pos); + + if (retType != CtClass.voidType) { + bytecode.addConstZero(retType); + bytecode.addStore(retVar, retType); // initialize $_ + } + jc.compileStmnt(statement); if (retType != CtClass.voidType) bytecode.addLoad(retVar, retType); diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java index 1fa7d4e9..e4c979fe 100644 --- a/src/main/javassist/expr/NewExpr.java +++ b/src/main/javassist/expr/NewExpr.java @@ -178,6 +178,10 @@ public class NewExpr extends Expr { Bytecode bytecode = jc.getBytecode(); storeStack(params, true, paramVar, bytecode); jc.recordLocalVariables(ca, pos); + + bytecode.addConstZero(newType); + bytecode.addStore(retVar, newType); // initialize $_ + jc.compileStmnt(statement); bytecode.addAload(retVar); |