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/bytecode | |
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/bytecode')
-rw-r--r-- | src/main/javassist/bytecode/Bytecode.java | 27 | ||||
-rw-r--r-- | src/main/javassist/bytecode/Descriptor.java | 32 |
2 files changed, 39 insertions, 20 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index ae6f1691..e319eeea 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -442,6 +442,29 @@ public class Bytecode implements Opcode { } /** + * Appends an instruction for pushing zero or null on the stack. + * If the type is void, this method does not append any instruction. + * + * @param type the type of the zero value (or null). + */ + public void addConstZero(CtClass type) { + if (type.isPrimitive()) { + if (type == CtClass.longType) + addOpcode(LCONST_0); + else if (type == CtClass.floatType) + addOpcode(FCONST_0); + else if (type == CtClass.doubleType) + addOpcode(DCONST_0); + else if (type == CtClass.voidType) + throw new RuntimeException("void type?"); + else + addOpcode(ICONST_0); + } + else + addOpcode(ACONST_NULL); + } + + /** * Appends ILOAD or (WIDE) ILOAD_<n> * * @param n an index into the local variable array. @@ -680,9 +703,9 @@ public class Bytecode implements Opcode { addLstore(n); return 2; } - else if(type == CtClass.floatType) + else if (type == CtClass.floatType) addFstore(n); - else if(type == CtClass.doubleType) { + else if (type == CtClass.doubleType) { addDstore(n); return 2; } diff --git a/src/main/javassist/bytecode/Descriptor.java b/src/main/javassist/bytecode/Descriptor.java index b3cc5a8c..9590d632 100644 --- a/src/main/javassist/bytecode/Descriptor.java +++ b/src/main/javassist/bytecode/Descriptor.java @@ -46,22 +46,20 @@ public class Descriptor { return classname.replace('/', '.'); } - /** - * Converts to a classname from a descriptor - */ - public static String fromDescriptor(String descriptor) - { - String newname = toJavaName(descriptor).substring(1); - return newname.substring(0, newname.length() - 1); - } - - /** - * Converts to a descriptor from a classname - */ - public static String toDescriptor(String classname) - { - return "L" + toJvmName(classname) + ";"; - } + /** + * Converts to a classname from a descriptor + */ + public static String fromDescriptor(String descriptor) { + String newname = toJavaName(descriptor).substring(1); + return newname.substring(0, newname.length() - 1); + } + + /** + * Converts to a descriptor from a classname + */ + public static String toDescriptor(String classname) { + return "L" + toJvmName(classname) + ";"; + } /** * Returns the internal representation of the class name in the @@ -179,8 +177,6 @@ public class Descriptor { return sbuf.toString(); } - - private static void toDescriptor(StringBuffer desc, CtClass type) { if (type.isArray()) { desc.append('['); |