private ASTList parseArraySize(SymbolTable tbl) throws CompileError { ASTList list = null; while (lex.lookAhead() == '[') list = ASTList.append(list, parseArrayIndex(tbl)); return list; }
public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append("(<"); sbuf.append(getTag()); sbuf.append('>'); ASTList list = this; while (list != null) { sbuf.append(' '); ASTree a = list.left; sbuf.append(a == null ? "<null>" : a.toString()); list = list.right; } sbuf.append(')'); return sbuf.toString(); }
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; }
if (lex.lookAhead() != ')') while (true) { parms = ASTList.append(parms, parseFormalParam(tbl)); int t = lex.lookAhead(); if (t == ',') lex.get(); while (true) { throwsList = ASTList.append(throwsList, parseClassType(tbl)); if (lex.lookAhead() == ',') lex.get(); return new MethodDecl(mods, new ASTList(d, ASTList.make(parms, throwsList, null)));
public CastExpr(ASTList className, int dim, ASTree expr) { super(className, new ASTList(expr)); castType = CLASS; arrayDim = dim; }
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); }
private Stmnt parseDeclarators(SymbolTable tbl, Declarator d) throws CompileError { Stmnt decl = null; for (;;) { decl = (Stmnt)ASTList.concat(decl, new Stmnt(DECL, parseDeclarator(tbl, d))); int t = lex.get(); if (t == ';') return decl; else if (t != ',') throw new CompileError("; is missing", lex); } }
public void setThen(ASTree t) { tail().setHead(t); }
/** * Returns the number of the elements in this list. */ public int length() { return length(this); }
public ASTree getInitializer() { ASTList t = tail(); if (t != null) return t.head(); else return null; }
|| (exprType == CLASS && arrayDim == 0 && jvmJavaLangString.equals(className))) { ASTList sbufClass = ASTList.make(new Symbol("java"), new Symbol("lang"), new Symbol("StringBuffer")); ASTree e = new NewExpr(sbufClass, null);
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; } }
if (lex.lookAhead() != ')') while (true) { parms = ASTList.append(parms, parseFormalParam(tbl)); int t = lex.lookAhead(); if (t == ',') lex.get(); while (true) { throwsList = ASTList.append(throwsList, parseClassType(tbl)); if (lex.lookAhead() == ',') lex.get(); return new MethodDecl(mods, new ASTList(d, ASTList.make(parms, throwsList, null)));
public CastExpr(int type, int dim, ASTree expr) { super(null, new ASTList(expr)); castType = type; arrayDim = dim; }
public void atNewArrayExpr(NewExpr expr) throws CompileError { int type = expr.getArrayType(); ASTList size = expr.getArraySize(); ASTList classname = expr.getClassName(); ASTree init = expr.getInitializer(); if (init != null) init.accept(this); if (size.length() > 1) atMultiNewArray(type, classname, size); else { ASTree sizeExpr = size.head(); if (sizeExpr != null) sizeExpr.accept(this); exprType = type; arrayDim = 1; if (type == CLASS) className = resolveClassName(classname); else className = null; } }