Package javassist.compiler.ast

Examples of javassist.compiler.ast.Stmnt


/*      */
/*      */   protected void atTryStmnt(Stmnt st)
/*      */     throws CompileError
/*      */   {
/*  189 */     Bytecode bc = this.bytecode;
/*  190 */     Stmnt body = (Stmnt)st.getLeft();
/*  191 */     if (body == null) {
/*  192 */       return;
/*      */     }
/*  194 */     ASTList catchList = (ASTList)st.getRight().getLeft();
/*  195 */     Stmnt finallyBlock = (Stmnt)st.getRight().getRight().getLeft();
/*  196 */     ArrayList gotoList = new ArrayList();
/*      */
/*  198 */     JsrHook jsrHook = null;
/*  199 */     if (finallyBlock != null) {
/*  200 */       jsrHook = new JsrHook(this);
/*      */     }
/*  202 */     int start = bc.currentPc();
/*  203 */     body.accept(this);
/*  204 */     int end = bc.currentPc();
/*  205 */     if (start == end) {
/*  206 */       throw new CompileError("empty try block");
/*      */     }
/*  208 */     boolean tryNotReturn = !this.hasReturned;
/*  209 */     if (tryNotReturn) {
/*  210 */       bc.addOpcode(167);
/*  211 */       gotoList.add(new Integer(bc.currentPc()));
/*  212 */       bc.addIndex(0);
/*      */     }
/*      */
/*  215 */     int var = getMaxLocals();
/*  216 */     incMaxLocals(1);
/*  217 */     while (catchList != null)
/*      */     {
/*  219 */       Pair p = (Pair)catchList.head();
/*  220 */       catchList = catchList.tail();
/*  221 */       Declarator decl = (Declarator)p.getLeft();
/*  222 */       Stmnt block = (Stmnt)p.getRight();
/*      */
/*  224 */       decl.setLocalVar(var);
/*      */
/*  226 */       CtClass type = this.resolver.lookupClassByJvmName(decl.getClassName());
/*  227 */       decl.setClassName(MemberResolver.javaToJvmName(type.getName()));
/*  228 */       bc.addExceptionHandler(start, end, bc.currentPc(), type);
/*  229 */       bc.growStack(1);
/*  230 */       bc.addAstore(var);
/*  231 */       this.hasReturned = false;
/*  232 */       if (block != null) {
/*  233 */         block.accept(this);
/*      */       }
/*  235 */       if (!this.hasReturned) {
/*  236 */         bc.addOpcode(167);
/*  237 */         gotoList.add(new Integer(bc.currentPc()));
/*  238 */         bc.addIndex(0);
View Full Code Here


/* 208 */       if (src == null) {
/* 209 */         makeDefaultBody(this.bytecode, rtype);
/*     */       } else {
/* 211 */         Parser p = new Parser(new Lex(src));
/* 212 */         SymbolTable stb = new SymbolTable(this.stable);
/* 213 */         Stmnt s = p.parseStatement(stb);
/* 214 */         if (p.hasMore()) {
/* 215 */           throw new CompileError("the method/constructor body must be surrounded by {}");
/*     */         }
/*     */
/* 218 */         boolean callSuper = false;
View Full Code Here

/*     */     throws CompileError
/*     */   {
/* 563 */     Parser p = new Parser(new Lex(src));
/* 564 */     SymbolTable stb = new SymbolTable(this.stable);
/* 565 */     while (p.hasMore()) {
/* 566 */       Stmnt s = p.parseStatement(stb);
/* 567 */       if (s != null)
/* 568 */         s.accept(this.gen);
/*     */     }
/*     */   }
View Full Code Here

/*  267 */     while (params != null) {
/*  268 */       atDeclarator((Declarator)params.head());
/*  269 */       params = params.tail();
/*      */     }
/*      */
/*  272 */     Stmnt s = method.getBody();
/*  273 */     atMethodBody(s, method.isConstructor(), method.getReturn().getType() == 344);
/*      */   }
View Full Code Here

/*      */   }
/*      */
/*      */   private void atIfStmnt(Stmnt st) throws CompileError
/*      */   {
/*  380 */     ASTree expr = st.head();
/*  381 */     Stmnt thenp = (Stmnt)st.tail().head();
/*  382 */     Stmnt elsep = (Stmnt)st.tail().tail().head();
/*  383 */     compileBooleanExpr(false, expr);
/*  384 */     int pc = this.bytecode.currentPc();
/*  385 */     int pc2 = 0;
/*  386 */     this.bytecode.addIndex(0);
/*      */
/*  388 */     this.hasReturned = false;
/*  389 */     if (thenp != null) {
/*  390 */       thenp.accept(this);
/*      */     }
/*  392 */     boolean thenHasReturned = this.hasReturned;
/*  393 */     this.hasReturned = false;
/*      */
/*  395 */     if ((elsep != null) && (!thenHasReturned)) {
/*  396 */       this.bytecode.addOpcode(167);
/*  397 */       pc2 = this.bytecode.currentPc();
/*  398 */       this.bytecode.addIndex(0);
/*      */     }
/*      */
/*  401 */     this.bytecode.write16bit(pc, this.bytecode.currentPc() - pc + 1);
/*      */
/*  403 */     if (elsep != null) {
/*  404 */       elsep.accept(this);
/*  405 */       if (!thenHasReturned) {
/*  406 */         this.bytecode.write16bit(pc2, this.bytecode.currentPc() - pc2 + 1);
/*      */       }
/*  408 */       this.hasReturned = ((thenHasReturned) && (this.hasReturned));
/*      */     }
View Full Code Here

/*  414 */     ArrayList prevContList = this.continueList;
/*  415 */     this.breakList = new ArrayList();
/*  416 */     this.continueList = new ArrayList();
/*      */
/*  418 */     ASTree expr = st.head();
/*  419 */     Stmnt body = (Stmnt)st.tail();
/*      */
/*  421 */     int pc = 0;
/*  422 */     if (notDo) {
/*  423 */       this.bytecode.addOpcode(167);
/*  424 */       pc = this.bytecode.currentPc();
/*  425 */       this.bytecode.addIndex(0);
/*      */     }
/*      */
/*  428 */     int pc2 = this.bytecode.currentPc();
/*  429 */     if (body != null) {
/*  430 */       body.accept(this);
/*      */     }
/*  432 */     int pc3 = this.bytecode.currentPc();
/*  433 */     if (notDo) {
/*  434 */       this.bytecode.write16bit(pc, pc3 - pc + 1);
/*      */     }
View Full Code Here

/*  455 */     ArrayList prevBreakList = this.breakList;
/*  456 */     ArrayList prevContList = this.continueList;
/*  457 */     this.breakList = new ArrayList();
/*  458 */     this.continueList = new ArrayList();
/*      */
/*  460 */     Stmnt init = (Stmnt)st.head();
/*  461 */     ASTList p = st.tail();
/*  462 */     ASTree expr = p.head();
/*  463 */     p = p.tail();
/*  464 */     Stmnt update = (Stmnt)p.head();
/*  465 */     Stmnt body = (Stmnt)p.tail();
/*      */
/*  467 */     if (init != null) {
/*  468 */       init.accept(this);
/*      */     }
/*  470 */     int pc = this.bytecode.currentPc();
/*  471 */     int pc2 = 0;
/*  472 */     if (expr != null) {
/*  473 */       compileBooleanExpr(false, expr);
/*  474 */       pc2 = this.bytecode.currentPc();
/*  475 */       this.bytecode.addIndex(0);
/*      */     }
/*      */
/*  478 */     if (body != null) {
/*  479 */       body.accept(this);
/*      */     }
/*  481 */     int pc3 = this.bytecode.currentPc();
/*  482 */     if (update != null) {
/*  483 */       update.accept(this);
/*      */     }
View Full Code Here

/*  505 */     this.bytecode.addOpcode(171);
/*  506 */     int npads = 3 - (opcodePc & 0x3);
/*  507 */     while (npads-- > 0) {
/*  508 */       this.bytecode.add(0);
/*      */     }
/*  510 */     Stmnt body = (Stmnt)st.tail();
/*  511 */     int npairs = 0;
/*  512 */     for (ASTList list = body; list != null; list = list.tail()) {
/*  513 */       if (((Stmnt)list.head()).getOperator() == 304) {
/*  514 */         npairs++;
/*      */       }
/*      */     }
/*  517 */     int opcodePc2 = this.bytecode.currentPc();
/*  518 */     this.bytecode.addGap(4);
/*  519 */     this.bytecode.add32bit(npairs);
/*  520 */     this.bytecode.addGap(npairs * 8);
/*      */
/*  522 */     long[] pairs = new long[npairs];
/*  523 */     int ipairs = 0;
/*  524 */     int defaultPc = -1;
/*  525 */     for (ASTList list = body; list != null; list = list.tail()) {
/*  526 */       Stmnt label = (Stmnt)list.head();
/*  527 */       int op = label.getOperator();
/*  528 */       if (op == 310)
/*  529 */         defaultPc = this.bytecode.currentPc();
/*  530 */       else if (op != 304)
/*  531 */         fatal();
/*      */       else {
/*  533 */         pairs[(ipairs++)] = ((computeLabel(label.head()) << 32) + (this.bytecode.currentPc() - opcodePc & 0xFFFFFFFF));
/*      */       }
/*      */
/*  538 */       this.hasReturned = false;
/*  539 */       ((Stmnt)label.tail()).accept(this);
/*      */     }
/*      */
/*  542 */     Arrays.sort(pairs);
/*  543 */     int pc = opcodePc2 + 8;
/*  544 */     for (int i = 0; i < npairs; i++) {
View Full Code Here

/*  659 */         b.addOpcode(195);
/*  660 */         return false;
/*      */       }
/*      */     };
/*  664 */     int pc = bc.currentPc();
/*  665 */     Stmnt body = (Stmnt)st.tail();
/*  666 */     if (body != null) {
/*  667 */       body.accept(this);
/*      */     }
/*  669 */     int pc2 = bc.currentPc();
/*  670 */     int pc3 = 0;
/*  671 */     if (!this.hasReturned) {
/*  672 */       rh.doit(bc, 0);
View Full Code Here

/*      */   }
/*      */
/*      */   public MethodDecl parseMethod2(SymbolTable tbl, MethodDecl md)
/*      */     throws CompileError
/*      */   {
/*  147 */     Stmnt body = null;
/*  148 */     if (this.lex.lookAhead() == 59) {
/*  149 */       this.lex.get();
/*      */     } else {
/*  151 */       body = parseBlock(tbl);
/*  152 */       if (body == null) {
/*  153 */         body = new Stmnt(66);
/*      */       }
/*      */     }
/*  156 */     md.sublist(4).setHead(body);
/*  157 */     return md;
/*      */   }
View Full Code Here

TOP

Related Classes of javassist.compiler.ast.Stmnt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.