本文整理汇总了Java中polyglot.ast.Try类的典型用法代码示例。如果您正苦于以下问题:Java Try类的具体用法?Java Try怎么用?Java Try使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Try类属于polyglot.ast包,在下文中一共展示了Try类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTry
import polyglot.ast.Try; //导入依赖的package包/类
/**
* Try Stmt Creation
*/
private void createTry(polyglot.ast.Try tryStmt) {
polyglot.ast.Block finallyBlock = tryStmt.finallyBlock();
if (finallyBlock == null) {
createTryCatch(tryStmt);
}
else {
createTryCatchFinally(tryStmt);
}
}
示例2: createStmt
import polyglot.ast.Try; //导入依赖的package包/类
/**
* Stmt creation
*/
protected void createStmt(polyglot.ast.Stmt stmt) {
//System.out.println("stmt: "+stmt.getClass());
if (stmt instanceof polyglot.ast.Eval) {
base().createAggressiveExpr(((polyglot.ast.Eval)stmt).expr(), false, false);
}
else if (stmt instanceof polyglot.ast.If) {
createIf2((polyglot.ast.If)stmt);
}
else if (stmt instanceof polyglot.ast.LocalDecl) {
createLocalDecl((polyglot.ast.LocalDecl)stmt);
}
else if (stmt instanceof polyglot.ast.Block) {
createBlock((polyglot.ast.Block)stmt);
}
else if (stmt instanceof polyglot.ast.While) {
createWhile2((polyglot.ast.While)stmt);
}
else if (stmt instanceof polyglot.ast.Do) {
createDo2((polyglot.ast.Do)stmt);
}
else if (stmt instanceof polyglot.ast.For) {
createForLoop2((polyglot.ast.For)stmt);
}
else if (stmt instanceof polyglot.ast.Switch) {
createSwitch((polyglot.ast.Switch)stmt);
}
else if (stmt instanceof polyglot.ast.Return) {
createReturn((polyglot.ast.Return)stmt);
}
else if (stmt instanceof polyglot.ast.Branch) {
createBranch((polyglot.ast.Branch)stmt);
}
else if (stmt instanceof polyglot.ast.ConstructorCall) {
createConstructorCall((polyglot.ast.ConstructorCall)stmt);
}
else if (stmt instanceof polyglot.ast.Empty) {
// do nothing empty stmt
}
else if (stmt instanceof polyglot.ast.Throw) {
createThrow((polyglot.ast.Throw)stmt);
}
else if (stmt instanceof polyglot.ast.Try) {
createTry((polyglot.ast.Try)stmt);
}
else if (stmt instanceof polyglot.ast.Labeled) {
createLabeled((polyglot.ast.Labeled)stmt);
}
else if (stmt instanceof polyglot.ast.Synchronized) {
createSynchronized((polyglot.ast.Synchronized)stmt);
}
else if (stmt instanceof polyglot.ast.Assert) {
createAssert((polyglot.ast.Assert)stmt);
}
else if (stmt instanceof polyglot.ast.LocalClassDecl) {
createLocalClassDecl((polyglot.ast.LocalClassDecl)stmt);
}
else {
throw new RuntimeException("Unhandled Stmt: "+stmt.getClass());
}
}
示例3: createTryCatch
import polyglot.ast.Try; //导入依赖的package包/类
/**
* handles try/catch (try/catch/finally is separate for simplicity)
*/
private void createTryCatch(polyglot.ast.Try tryStmt){
// try
polyglot.ast.Block tryBlock = tryStmt.tryBlock();
// this nop is for the fromStmt of try
soot.jimple.Stmt noop1 = soot.jimple.Jimple.v().newNopStmt();
body.getUnits().add(noop1);
if (tryStack == null){
tryStack = new Stack<Try>();
}
tryStack.push(tryStmt);
createBlock(tryBlock);
tryStack.pop();
// this nop is for the toStmt of try
soot.jimple.Stmt noop2 = soot.jimple.Jimple.v().newNopStmt();
body.getUnits().add(noop2);
// create end nop for after entire try/catch
soot.jimple.Stmt endNoop = soot.jimple.Jimple.v().newNopStmt();
soot.jimple.Stmt tryEndGoto = soot.jimple.Jimple.v().newGotoStmt(endNoop);
body.getUnits().add(tryEndGoto);
Iterator it = tryStmt.catchBlocks().iterator();
while (it.hasNext()) {
soot.jimple.Stmt noop3 = soot.jimple.Jimple.v().newNopStmt();
body.getUnits().add(noop3);
// create catch stmts
polyglot.ast.Catch catchBlock = (polyglot.ast.Catch)it.next();
// create catch ref
createCatchFormal(catchBlock.formal());
if (catchStack == null){
catchStack = new Stack<Try>();
}
catchStack.push(tryStmt);
createBlock(catchBlock.body());
catchStack.pop();
soot.jimple.Stmt catchEndGoto = soot.jimple.Jimple.v().newGotoStmt(endNoop);
body.getUnits().add(catchEndGoto);
soot.Type sootType = Util.getSootType(catchBlock.catchType());
addToExceptionList(noop1, noop2, noop3, soot.Scene.v().getSootClass(sootType.toString()));
}
body.getUnits().add(endNoop);
}