use of org.wso2.ballerinalang.compiler.tree.statements.BLangCatch in project ballerina by ballerina-lang.
the class CodeAnalyzer method visit.
public void visit(BLangTryCatchFinally tryNode) {
this.checkStatementExecutionValidity(tryNode);
tryNode.tryBody.accept(this);
this.resetStatementReturns();
List<BType> caughtTypes = new ArrayList<>();
for (BLangCatch bLangCatch : tryNode.getCatchBlocks()) {
if (caughtTypes.contains(bLangCatch.getParameter().type)) {
dlog.error(bLangCatch.getParameter().pos, DiagnosticCode.DUPLICATED_ERROR_CATCH, bLangCatch.getParameter().type);
}
caughtTypes.add(bLangCatch.getParameter().type);
bLangCatch.body.accept(this);
this.resetStatementReturns();
}
if (tryNode.finallyBody != null) {
tryNode.finallyBody.accept(this);
this.resetStatementReturns();
}
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangCatch in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangCatch bLangCatch) {
// Define local variable index for Error.
BLangVariable variable = bLangCatch.param;
RegIndex lvIndex = getLVIndex(variable.symbol.type.tag);
variable.symbol.varIndex = lvIndex;
emit(InstructionFactory.get(InstructionCodes.ERRSTORE, lvIndex));
// Visit Catch Block.
genNode(bLangCatch.body, env);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangCatch in project ballerina by ballerina-lang.
the class SignatureTreeVisitor method visit.
@Override
public void visit(BLangCatch catchNode) {
SymbolEnv catchBlockEnv = SymbolEnv.createBlockEnv(catchNode.body, symbolEnv);
this.acceptNode(catchNode.param, catchBlockEnv);
this.blockOwnerStack.push(catchNode);
this.acceptNode(catchNode.body, catchBlockEnv);
this.blockOwnerStack.pop();
}
Aggregations