public boolean isParamListName(ASTList args) { if (codeGen.paramTypeList != null && args != null && args.tail() == null) { ASTree left = args.head(); return (left instanceof Member && ((Member)left).get().equals(codeGen.paramListName)); } else return false; }
public boolean isParamListName(ASTList args) { if (paramTypeList != null && args != null && args.tail() == null) { ASTree left = args.head(); return (left instanceof Member && ((Member)left).get().equals(paramListName)); } else return false; }
public int getMethodArgsLength(ASTList args) { String pname = codeGen.paramListName; int n = 0; while (args != null) { ASTree a = args.head(); if (a instanceof Member && ((Member)a).get().equals(pname)) { if (codeGen.paramTypeList != null) n += codeGen.paramTypeList.length; } else ++n; args = args.tail(); } return n; }
public int getMethodArgsLength(ASTList args) { String pname = paramListName; int n = 0; while (args != null) { ASTree a = args.head(); if (a instanceof Member && ((Member)a).get().equals(pname)) { if (paramTypeList != null) n += paramTypeList.length; } else ++n; args = args.tail(); } return n; }
public void atArrayInit(ArrayInit init) throws CompileError { ASTList list = init; while (list != null) { ASTree h = list.head(); list = list.tail(); if (h != null) h.accept(this); } }
public void atMethodArgs(ASTList args, int[] types, int[] dims, String[] cnames) throws CompileError { int i = 0; while (args != null) { ASTree a = args.head(); a.accept(this); types[i] = exprType; dims[i] = arrayDim; cnames[i] = className; ++i; args = args.tail(); } }
public void atMethodArgs(ASTList args, int[] types, int[] dims, String[] cnames) throws CompileError { int i = 0; while (args != null) { ASTree a = args.head(); a.accept(this); types[i] = exprType; dims[i] = arrayDim; cnames[i] = className; ++i; args = args.tail(); } }
private static void astToClassName(StringBuffer sbuf, ASTList name, char sep) { for (;;) { ASTree h = name.head(); if (h instanceof Symbol) sbuf.append(((Symbol)h).get()); else if (h instanceof ASTList) astToClassName(sbuf, (ASTList)h, sep); name = name.tail(); if (name == null) break; sbuf.append(sep); } } }
public ASTree elseExpr() { return tail().tail().head(); }
public void setElse(ASTree t) { tail().tail().setHead(t); }
public boolean isParamListName(ASTList args) { if (paramTypeList != null && args != null && args.tail() == null) { ASTree left = args.head(); return (left instanceof Member && ((Member)left).get().equals(paramListName)); } return false; }
public boolean isParamListName(ASTList args) { if (codeGen.paramTypeList != null && args != null && args.tail() == null) { ASTree left = args.head(); return (left instanceof Member && ((Member)left).get().equals(codeGen.paramListName)); } return false; }
@Override public void atArrayInit(ArrayInit init) throws CompileError { ASTList list = init; while (list != null) { ASTree h = list.head(); list = list.tail(); if (h != null) h.accept(this); } }
public CtClass[] makeParamList(MethodDecl md) throws CompileError { CtClass[] params; ASTList plist = md.getParams(); if (plist == null) params = new CtClass[0]; else { int i = 0; params = new CtClass[plist.length()]; while (plist != null) { params[i++] = resolver.lookupClass((Declarator)plist.head()); plist = plist.tail(); } } return params; }
public CtClass[] makeThrowsList(MethodDecl md) throws CompileError { CtClass[] clist; ASTList list = md.getThrows(); if (list == null) return null; else { int i = 0; clist = new CtClass[list.length()]; while (list != null) { clist[i++] = resolver.lookupClassByName((ASTList)list.head()); list = list.tail(); } return clist; } }
public void atCastExpr(CastExpr expr) throws CompileError { ASTList classname = expr.getClassName(); if (classname != null && expr.getArrayDim() == 0) { ASTree p = classname.head(); if (p instanceof Symbol && classname.tail() == null) { String typename = ((Symbol)p).get(); if (typename.equals(codeGen.returnCastName)) { atCastToRtype(expr); return; } else if (typename.equals(JvstCodeGen.wrapperCastName)) { atCastToWrapper(expr); return; } } } super.atCastExpr(expr); }
public void atCastExpr(CastExpr expr) throws CompileError { ASTList classname = expr.getClassName(); if (classname != null && expr.getArrayDim() == 0) { ASTree p = classname.head(); if (p instanceof Symbol && classname.tail() == null) { String typename = ((Symbol)p).get(); if (typename.equals(returnCastName)) { atCastToRtype(expr); return; } else if (typename.equals(wrapperCastName)) { atCastToWrapper(expr); return; } } } super.atCastExpr(expr); }
protected void atMultiNewArray(int type, ASTList classname, ASTList size) throws CompileError { int count, dim; dim = size.length(); for (count = 0; size != null; size = size.tail()) { ASTree s = size.head(); if (s == null) break; // int[][][] a = new int[3][4][]; ++count; s.accept(this); } exprType = type; arrayDim = dim; if (type == CLASS) className = resolveClassName(classname); else className = null; }
protected void atCflow(ASTList cname) throws CompileError { StringBuffer sbuf = new StringBuffer(); if (cname == null || cname.tail() != null) throw new CompileError("bad " + cflowName); makeCflowName(sbuf, cname.head()); String name = sbuf.toString(); Object[] names = resolver.getClassPool().lookupCflow(name); if (names == null) throw new CompileError("no such " + cflowName + ": " + name); bytecode.addGetstatic((String)names[0], (String)names[1], "Ljavassist/runtime/Cflow;"); bytecode.addInvokevirtual("javassist.runtime.Cflow", "value", "()I"); exprType = INT; arrayDim = 0; className = null; }
public void atMethodDecl(MethodDecl method) throws CompileError { ASTList mods = method.getModifiers(); setMaxLocals(1); while (mods != null) { Keyword k = (Keyword)mods.head(); mods = mods.tail(); if (k.get() == STATIC) { setMaxLocals(0); inStaticMethod = true; } } ASTList params = method.getParams(); while (params != null) { atDeclarator((Declarator)params.head()); params = params.tail(); } Stmnt s = method.getBody(); atMethodBody(s, method.isConstructor(), method.getReturn().getType() == VOID); }