private CtBehavior compileMethod(Parser p, MethodDecl md) throws CompileError int mod = MemberResolver.getModifiers(md.getModifiers()); CtClass[] plist = gen.makeParamList(md); CtClass[] tlist = gen.makeThrowsList(md); md = p.parseMethod2(stable, md); try { if (md.isConstructor()) { CtConstructor cons = new CtConstructor(plist, gen.getThisClass()); cons.setModifiers(mod); md.accept(gen); cons.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute()); Declarator r = md.getReturn(); CtClass rtype = gen.resolver.lookupClass(r); recordReturnType(rtype, false); method.setModifiers(mod); gen.setThisMethod(method); md.accept(gen); if (md.getBody() != null) method.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute());
public ASTList getModifiers() { return (ASTList)getLeft(); }
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); }
public Stmnt getBody() { return (Stmnt)sublist(4).head(); }
public boolean isConstructor() { Symbol sym = getReturn().getVariable(); return sym != null && initName.equals(sym.get()); }
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 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; }
return new MethodDecl(mods, new ASTList(d, ASTList.make(parms, throwsList, null)));
public ASTList getParams() { return (ASTList)sublist(2).head(); }
public boolean isConstructor() { Symbol sym = getReturn().getVariable(); return sym != null && initName.equals(sym.get()); }
public CtClass[] makeThrowsList(MethodDecl md) throws CompileError { CtClass[] clist; ASTList list = md.getThrows(); if (list == null) return null; int i = 0; clist = new CtClass[list.length()]; while (list != null) { clist[i++] = resolver.lookupClassByName((ASTList)list.head()); list = list.tail(); } return clist; }
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; }
return new MethodDecl(mods, new ASTList(d, ASTList.make(parms, throwsList, null)));
@Override 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); }
private CtBehavior compileMethod(Parser p, MethodDecl md) throws CompileError int mod = MemberResolver.getModifiers(md.getModifiers()); CtClass[] plist = gen.makeParamList(md); CtClass[] tlist = gen.makeThrowsList(md); md = p.parseMethod2(stable, md); try { if (md.isConstructor()) { CtConstructor cons = new CtConstructor(plist, gen.getThisClass()); cons.setModifiers(mod); md.accept(gen); cons.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute()); return cons; Declarator r = md.getReturn(); CtClass rtype = gen.resolver.lookupClass(r); recordReturnType(rtype, false); method.setModifiers(mod); gen.setThisMethod(method); md.accept(gen); if (md.getBody() != null) method.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute());
public ASTList getThrows() { return (ASTList)sublist(3).head(); }
public boolean isConstructor() { Symbol sym = getReturn().getVariable(); return sym != null && initName.equals(sym.get()); }
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 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 ASTList getModifiers() { return (ASTList)getLeft(); }