Search in sources :

Example 1 with BLangAwaitExpr

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangAwaitExpr in project ballerina by ballerina-lang.

the class TypeChecker method visit.

public void visit(BLangAwaitExpr awaitExpr) {
    BType expType = checkExpr(awaitExpr.expr, env, Lists.of(this.symTable.futureType)).get(0);
    if (expType == symTable.errType) {
        resultTypes = Lists.of(symTable.errType);
    } else {
        BType constraint = ((BFutureType) expType).constraint;
        resultTypes = Lists.of(constraint);
        if (constraint == symTable.noType) {
            resultTypes.clear();
        }
    }
    this.checkAsyncReturnTypes(awaitExpr, resultTypes);
}
Also used : BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BFutureType(org.wso2.ballerinalang.compiler.semantics.model.types.BFutureType)

Example 2 with BLangAwaitExpr

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangAwaitExpr in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangAwaitExpr awaitExpr) {
    Operand valueRegIndex;
    if (awaitExpr.type != null) {
        valueRegIndex = calcAndGetExprRegIndex(awaitExpr);
    } else {
        valueRegIndex = this.getOperand(-1);
    }
    genNode(awaitExpr.expr, this.env);
    Operand futureRegIndex = awaitExpr.expr.regIndex;
    this.emit(InstructionCodes.AWAIT, futureRegIndex, valueRegIndex);
}
Also used : Operand(org.wso2.ballerinalang.programfile.Instruction.Operand)

Example 3 with BLangAwaitExpr

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangAwaitExpr in project ballerina by ballerina-lang.

the class BLangPackageBuilder method createAwaitExpr.

public void createAwaitExpr(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangAwaitExpr awaitExpr = (BLangAwaitExpr) TreeBuilder.createAwaitExpressionNode();
    awaitExpr.pos = pos;
    awaitExpr.addWS(ws);
    awaitExpr.expr = (BLangExpression) exprNodeStack.pop();
    addExpressionNode(awaitExpr);
}
Also used : BLangAwaitExpr(org.wso2.ballerinalang.compiler.tree.expressions.BLangAwaitExpr)

Aggregations

BFutureType (org.wso2.ballerinalang.compiler.semantics.model.types.BFutureType)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 BLangAwaitExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangAwaitExpr)1 Operand (org.wso2.ballerinalang.programfile.Instruction.Operand)1