38 * you write code that depends on this, you do so at your own risk. |
38 * you write code that depends on this, you do so at your own risk. |
39 * This code and its internal interfaces are subject to change or |
39 * This code and its internal interfaces are subject to change or |
40 * deletion without notice.</b> |
40 * deletion without notice.</b> |
41 */ |
41 */ |
42 public class ConstantWriter extends BasicWriter { |
42 public class ConstantWriter extends BasicWriter { |
43 static ConstantWriter instance(Context context) { |
43 public static ConstantWriter instance(Context context) { |
44 ConstantWriter instance = context.get(ConstantWriter.class); |
44 ConstantWriter instance = context.get(ConstantWriter.class); |
45 if (instance == null) |
45 if (instance == null) |
46 instance = new ConstantWriter(context); |
46 instance = new ConstantWriter(context); |
47 return instance; |
47 return instance; |
48 } |
48 } |
52 context.put(ConstantWriter.class, this); |
52 context.put(ConstantWriter.class, this); |
53 classWriter = ClassWriter.instance(context); |
53 classWriter = ClassWriter.instance(context); |
54 options = Options.instance(context); |
54 options = Options.instance(context); |
55 } |
55 } |
56 |
56 |
57 void writeConstantPool() { |
57 protected void writeConstantPool() { |
|
58 ConstantPool constant_pool = classWriter.getClassFile().constant_pool; |
|
59 writeConstantPool(constant_pool); |
|
60 } |
|
61 |
|
62 protected void writeConstantPool(ConstantPool constant_pool) { |
58 ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() { |
63 ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() { |
59 public Integer visitClass(CONSTANT_Class_info info, Void p) { |
64 public Integer visitClass(CONSTANT_Class_info info, Void p) { |
60 println("#" + info.name_index + ";\t// " + stringValue(info)); |
65 println("#" + info.name_index + ";\t// " + stringValue(info)); |
61 return 1; |
66 return 1; |
62 } |
67 } |