35 import javax.tools.FileObject; |
35 import javax.tools.FileObject; |
36 import javax.tools.JavaFileObject; |
36 import javax.tools.JavaFileObject; |
37 |
37 |
38 import com.sun.tools.javac.code.*; |
38 import com.sun.tools.javac.code.*; |
39 import com.sun.tools.javac.code.Attribute.RetentionPolicy; |
39 import com.sun.tools.javac.code.Attribute.RetentionPolicy; |
40 import com.sun.tools.javac.code.Attribute.TypeCompound; |
|
41 import com.sun.tools.javac.code.Symbol.*; |
40 import com.sun.tools.javac.code.Symbol.*; |
42 import com.sun.tools.javac.code.Type.*; |
41 import com.sun.tools.javac.code.Type.*; |
43 import com.sun.tools.javac.code.Types.UniqueType; |
42 import com.sun.tools.javac.code.Types.UniqueType; |
44 import com.sun.tools.javac.file.BaseFileObject; |
43 import com.sun.tools.javac.file.BaseFileObject; |
45 import com.sun.tools.javac.jvm.Pool.DynamicMethod; |
44 import com.sun.tools.javac.jvm.Pool.DynamicMethod; |
52 import static com.sun.tools.javac.code.Kinds.*; |
51 import static com.sun.tools.javac.code.Kinds.*; |
53 import static com.sun.tools.javac.code.TypeTag.*; |
52 import static com.sun.tools.javac.code.TypeTag.*; |
54 import static com.sun.tools.javac.jvm.UninitializedType.*; |
53 import static com.sun.tools.javac.jvm.UninitializedType.*; |
55 import static com.sun.tools.javac.main.Option.*; |
54 import static com.sun.tools.javac.main.Option.*; |
56 import static javax.tools.StandardLocation.CLASS_OUTPUT; |
55 import static javax.tools.StandardLocation.CLASS_OUTPUT; |
57 |
|
58 |
56 |
59 /** This class provides operations to map an internal symbol table graph |
57 /** This class provides operations to map an internal symbol table graph |
60 * rooted in a ClassSymbol into a classfile. |
58 * rooted in a ClassSymbol into a classfile. |
61 * |
59 * |
62 * <p><b>This is NOT part of any supported API. |
60 * <p><b>This is NOT part of any supported API. |
1178 // counter for number of generic local variables |
1176 // counter for number of generic local variables |
1179 int nGenericVars = 0; |
1177 int nGenericVars = 0; |
1180 |
1178 |
1181 if (code.varBufferSize > 0) { |
1179 if (code.varBufferSize > 0) { |
1182 int alenIdx = writeAttr(names.LocalVariableTable); |
1180 int alenIdx = writeAttr(names.LocalVariableTable); |
1183 databuf.appendChar(code.varBufferSize); |
1181 databuf.appendChar(code.getLVTSize()); |
1184 |
|
1185 for (int i=0; i<code.varBufferSize; i++) { |
1182 for (int i=0; i<code.varBufferSize; i++) { |
1186 Code.LocalVar var = code.varBuffer[i]; |
1183 Code.LocalVar var = code.varBuffer[i]; |
1187 |
1184 |
1188 // write variable info |
1185 for (Code.LocalVar.Range r: var.aliveRanges) { |
1189 Assert.check(var.start_pc >= 0 |
1186 // write variable info |
1190 && var.start_pc <= code.cp); |
1187 Assert.check(r.start_pc >= 0 |
1191 databuf.appendChar(var.start_pc); |
1188 && r.start_pc <= code.cp); |
1192 Assert.check(var.length >= 0 |
1189 databuf.appendChar(r.start_pc); |
1193 && (var.start_pc + var.length) <= code.cp); |
1190 Assert.check(r.length >= 0 |
1194 databuf.appendChar(var.length); |
1191 && (r.start_pc + r.length) <= code.cp); |
1195 VarSymbol sym = var.sym; |
1192 databuf.appendChar(r.length); |
1196 databuf.appendChar(pool.put(sym.name)); |
1193 VarSymbol sym = var.sym; |
1197 Type vartype = sym.erasure(types); |
1194 databuf.appendChar(pool.put(sym.name)); |
1198 if (needsLocalVariableTypeEntry(sym.type)) |
1195 Type vartype = sym.erasure(types); |
1199 nGenericVars++; |
1196 databuf.appendChar(pool.put(typeSig(vartype))); |
1200 databuf.appendChar(pool.put(typeSig(vartype))); |
1197 databuf.appendChar(var.reg); |
1201 databuf.appendChar(var.reg); |
1198 if (needsLocalVariableTypeEntry(var.sym.type)) |
|
1199 nGenericVars++; |
|
1200 } |
1202 } |
1201 } |
1203 endAttr(alenIdx); |
1202 endAttr(alenIdx); |
1204 acount++; |
1203 acount++; |
1205 } |
1204 } |
1206 |
1205 |
1212 for (int i=0; i<code.varBufferSize; i++) { |
1211 for (int i=0; i<code.varBufferSize; i++) { |
1213 Code.LocalVar var = code.varBuffer[i]; |
1212 Code.LocalVar var = code.varBuffer[i]; |
1214 VarSymbol sym = var.sym; |
1213 VarSymbol sym = var.sym; |
1215 if (!needsLocalVariableTypeEntry(sym.type)) |
1214 if (!needsLocalVariableTypeEntry(sym.type)) |
1216 continue; |
1215 continue; |
1217 count++; |
1216 for (Code.LocalVar.Range r : var.aliveRanges) { |
1218 // write variable info |
1217 // write variable info |
1219 databuf.appendChar(var.start_pc); |
1218 databuf.appendChar(r.start_pc); |
1220 databuf.appendChar(var.length); |
1219 databuf.appendChar(r.length); |
1221 databuf.appendChar(pool.put(sym.name)); |
1220 databuf.appendChar(pool.put(sym.name)); |
1222 databuf.appendChar(pool.put(typeSig(sym.type))); |
1221 databuf.appendChar(pool.put(typeSig(sym.type))); |
1223 databuf.appendChar(var.reg); |
1222 databuf.appendChar(var.reg); |
|
1223 count++; |
|
1224 } |
1224 } |
1225 } |
1225 Assert.check(count == nGenericVars); |
1226 Assert.check(count == nGenericVars); |
1226 endAttr(alenIdx); |
1227 endAttr(alenIdx); |
1227 acount++; |
1228 acount++; |
1228 } |
1229 } |