public ASTree getInitializer() { ASTList t = tail(); if (t != null) return t.head(); else return null; }
public Declarator getDeclarator() { return (Declarator)tail().head(); }
public ASTree getInit() { return (ASTree)sublist(2).head(); }
public ASTree thenExpr() { return tail().head(); }
public Stmnt getBody() { return (Stmnt)sublist(4).head(); }
public Declarator getReturn() { return (Declarator)tail().head(); }
public ASTList getParams() { return (ASTList)sublist(2).head(); }
public ASTList getThrows() { return (ASTList)sublist(3).head(); }
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 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 atNewArrayExpr(NewExpr expr) throws CompileError { int type = expr.getArrayType(); ASTList size = expr.getArraySize(); ASTList classname = expr.getClassName(); ArrayInit init = expr.getInitializer(); if (size.length() > 1) { if (init != null) throw new CompileError( "sorry, multi-dimensional array initializer " + "for new is not supported"); atMultiNewArray(type, classname, size); return; } ASTree sizeExpr = size.head(); atNewArrayExpr2(type, sizeExpr, Declarator.astToClassName(classname, '/'), init); }