diff options
Diffstat (limited to 'src/main/javassist/compiler/JvstCodeGen.java')
-rw-r--r-- | src/main/javassist/compiler/JvstCodeGen.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/main/javassist/compiler/JvstCodeGen.java b/src/main/javassist/compiler/JvstCodeGen.java index 4f251924..6a372018 100644 --- a/src/main/javassist/compiler/JvstCodeGen.java +++ b/src/main/javassist/compiler/JvstCodeGen.java @@ -147,7 +147,7 @@ public class JvstCodeGen extends MemberCodeGen { if (arrayDim != 1 || exprType != CLASS) throw new CompileError("invalid type for " + paramArrayName, expr.getLineNumber()); - atAssignParamList(paramTypeList, bytecode); + atAssignParamList(paramTypeList, bytecode, expr.getLineNumber()); if (!doDup) bytecode.addOpcode(POP); } @@ -155,7 +155,7 @@ public class JvstCodeGen extends MemberCodeGen { super.atFieldAssign(expr, op, left, right, doDup); } - protected void atAssignParamList(CtClass[] params, Bytecode code) + protected void atAssignParamList(CtClass[] params, Bytecode code, int lineNumber) throws CompileError { if (params == null) @@ -167,7 +167,7 @@ public class JvstCodeGen extends MemberCodeGen { code.addOpcode(DUP); code.addIconst(i); code.addOpcode(AALOAD); - compileUnwrapValue(params[i], code); + compileUnwrapValue(params[i], code, lineNumber); code.addStore(varNo, params[i]); varNo += is2word(exprType, arrayDim) ? 2 : 1; } @@ -201,10 +201,10 @@ public class JvstCodeGen extends MemberCodeGen { protected void atCastToRtype(CastExpr expr) throws CompileError { expr.getOprand().accept(this); if (exprType == VOID || isRefType(exprType) || arrayDim > 0) - compileUnwrapValue(returnType, bytecode); + compileUnwrapValue(returnType, bytecode, expr.getLineNumber()); else if (returnType instanceof CtPrimitiveType) { CtPrimitiveType pt = (CtPrimitiveType)returnType; - int destType = MemberResolver.descToType(pt.getDescriptor()); + int destType = MemberResolver.descToType(pt.getDescriptor(), expr.getLineNumber()); atNumCastExpr(exprType, destType); exprType = destType; arrayDim = 0; @@ -219,7 +219,7 @@ public class JvstCodeGen extends MemberCodeGen { if (isRefType(exprType) || arrayDim > 0) return; // Object type. do nothing. - CtClass clazz = resolver.lookupClass(exprType, arrayDim, className); + CtClass clazz = resolver.lookupClass(exprType, arrayDim, className, expr.getLineNumber()); if (clazz instanceof CtPrimitiveType) { CtPrimitiveType pt = (CtPrimitiveType)clazz; String wrapper = pt.getWrapperName(); @@ -249,7 +249,7 @@ public class JvstCodeGen extends MemberCodeGen { if (method instanceof Member) { String name = ((Member)method).get(); if (procHandler != null && name.equals(proceedName)) { - procHandler.doit(this, bytecode, (ASTList)expr.oprand2()); + procHandler.doit(this, bytecode, (ASTList)expr.oprand2(), expr.getLineNumber()); return; } else if (name.equals(cflowName)) { @@ -364,7 +364,7 @@ public class JvstCodeGen extends MemberCodeGen { for (int k = 0; k < n; ++k) { CtClass p = params[k]; regno += bytecode.addLoad(regno, p); - setType(p); + setType(p, a.getLineNumber()); types[i] = exprType; dims[i] = arrayDim; cnames[i] = className; @@ -420,7 +420,7 @@ public class JvstCodeGen extends MemberCodeGen { atMethodArgs(args, new int[nargs], new int[nargs], new String[nargs]); bytecode.addInvokespecial(methodIndex, descriptor); - setReturnType(descriptor, false, false); + setReturnType(descriptor, false, false, target.getLineNumber()); addNullIfVoid(); } @@ -569,7 +569,7 @@ public class JvstCodeGen extends MemberCodeGen { className = jvmJavaLangObject; } else - setType(cc); + setType(cc, cc.getLinesCount()); Declarator decl = new Declarator(exprType, className, arrayDim, @@ -593,7 +593,7 @@ public class JvstCodeGen extends MemberCodeGen { while ((c = typeDesc.charAt(dim)) == '[') ++dim; - int type = MemberResolver.descToType(c); + int type = MemberResolver.descToType(c, -1); String cname = null; if (type == CLASS) { if (dim == 0) @@ -653,7 +653,7 @@ public class JvstCodeGen extends MemberCodeGen { return 8; } - protected void compileUnwrapValue(CtClass type, Bytecode code) + protected void compileUnwrapValue(CtClass type, Bytecode code, int lineNumber) throws CompileError { if (type == CtClass.voidType) { @@ -662,7 +662,7 @@ public class JvstCodeGen extends MemberCodeGen { } if (exprType == VOID) - throw new CompileError("invalid type for " + returnCastName); + throw new CompileError("invalid type for " + returnCastName, lineNumber); if (type instanceof CtPrimitiveType) { CtPrimitiveType pt = (CtPrimitiveType)type; @@ -671,34 +671,34 @@ public class JvstCodeGen extends MemberCodeGen { code.addCheckcast(wrapper); code.addInvokevirtual(wrapper, pt.getGetMethodName(), pt.getGetMethodDescriptor()); - setType(type); + setType(type, lineNumber); } else { code.addCheckcast(type); - setType(type); + setType(type, lineNumber); } } /* Sets exprType, arrayDim, and className; * If type is void, then this method does nothing. */ - public void setType(CtClass type) throws CompileError { - setType(type, 0); + public void setType(CtClass type, int lineNumber) throws CompileError { + setType(type, 0, lineNumber); } - private void setType(CtClass type, int dim) throws CompileError { + private void setType(CtClass type, int dim, int lineNumber) throws CompileError { if (type.isPrimitive()) { CtPrimitiveType pt = (CtPrimitiveType)type; - exprType = MemberResolver.descToType(pt.getDescriptor()); + exprType = MemberResolver.descToType(pt.getDescriptor(), lineNumber); arrayDim = dim; className = null; } else if (type.isArray()) try { - setType(type.getComponentType(), dim + 1); + setType(type.getComponentType(), dim + 1, lineNumber); } catch (NotFoundException e) { - throw new CompileError("undefined type: " + type.getName()); + throw new CompileError("undefined type: " + type.getName(), lineNumber); } else { exprType = CLASS; @@ -714,9 +714,9 @@ public class JvstCodeGen extends MemberCodeGen { if (type instanceof CtPrimitiveType) { CtPrimitiveType pt = (CtPrimitiveType)type; atNumCastExpr(exprType, - MemberResolver.descToType(pt.getDescriptor())); + MemberResolver.descToType(pt.getDescriptor(), type.getLinesCount() - 1)); } else - throw new CompileError("type mismatch"); + throw new CompileError("type mismatch", type.getLinesCount() - 1); } } |