Search in sources :

Example 71 with BLangExpression

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

the class BLangPackageBuilder method addWorkerSendStmt.

public void addWorkerSendStmt(DiagnosticPos pos, Set<Whitespace> ws, String workerName, boolean isForkJoinSend) {
    BLangWorkerSend workerSendNode = (BLangWorkerSend) TreeBuilder.createWorkerSendNode();
    workerSendNode.setWorkerName(this.createIdentifier(workerName));
    exprNodeListStack.pop().forEach(expr -> workerSendNode.exprs.add((BLangExpression) expr));
    workerSendNode.addWS(commaWsStack.pop());
    workerSendNode.isForkJoinSend = isForkJoinSend;
    workerSendNode.pos = pos;
    workerSendNode.addWS(ws);
    addStmtToCurrentBlock(workerSendNode);
}
Also used : BLangWorkerSend(org.wso2.ballerinalang.compiler.tree.statements.BLangWorkerSend) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 72 with BLangExpression

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

the class BLangPackageBuilder method addArrayInitExpr.

public void addArrayInitExpr(DiagnosticPos pos, Set<Whitespace> ws, boolean argsAvailable) {
    List<ExpressionNode> argExprList;
    BLangArrayLiteral arrayLiteral = (BLangArrayLiteral) TreeBuilder.createArrayLiteralNode();
    if (argsAvailable) {
        arrayLiteral.addWS(commaWsStack.pop());
        argExprList = exprNodeListStack.pop();
    } else {
        argExprList = new ArrayList<>(0);
    }
    arrayLiteral.exprs = argExprList.stream().map(expr -> (BLangExpression) expr).collect(Collectors.toList());
    arrayLiteral.pos = pos;
    arrayLiteral.addWS(ws);
    addExpressionNode(arrayLiteral);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangArrayLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)

Example 73 with BLangExpression

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

the class BLangPackageBuilder method createUnaryExpr.

public void createUnaryExpr(DiagnosticPos pos, Set<Whitespace> ws, String operator) {
    BLangUnaryExpr unaryExpressionNode = (BLangUnaryExpr) TreeBuilder.createUnaryExpressionNode();
    unaryExpressionNode.pos = pos;
    unaryExpressionNode.addWS(ws);
    unaryExpressionNode.expr = (BLangExpression) exprNodeStack.pop();
    unaryExpressionNode.operator = OperatorKind.valueFrom(operator);
    addExpressionNode(unaryExpressionNode);
}
Also used : BLangUnaryExpr(org.wso2.ballerinalang.compiler.tree.expressions.BLangUnaryExpr)

Example 74 with BLangExpression

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

the class BLangPackageBuilder method addIntRangeExpression.

public void addIntRangeExpression(DiagnosticPos pos, Set<Whitespace> ws, boolean includeStart, boolean includeEnd) {
    BLangIntRangeExpression intRangeExpr = (BLangIntRangeExpression) TreeBuilder.createIntRangeExpression();
    intRangeExpr.pos = pos;
    intRangeExpr.addWS(ws);
    intRangeExpr.endExpr = (BLangExpression) this.exprNodeStack.pop();
    intRangeExpr.startExpr = (BLangExpression) this.exprNodeStack.pop();
    intRangeExpr.includeStart = includeStart;
    intRangeExpr.includeEnd = includeEnd;
    exprNodeStack.push(intRangeExpr);
}
Also used : BLangIntRangeExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangIntRangeExpression)

Example 75 with BLangExpression

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

the class BLangPackageBuilder method addPostIncrementStatement.

public void addPostIncrementStatement(DiagnosticPos pos, Set<Whitespace> ws, String operator) {
    BLangPostIncrement postIncrement = (BLangPostIncrement) TreeBuilder.createPostIncrementNode();
    postIncrement.setVariable((BLangVariableReference) exprNodeStack.pop());
    postIncrement.pos = pos;
    postIncrement.addWS(ws);
    addLiteralValue(pos, ws, TypeTags.INT, Long.parseLong("1"));
    postIncrement.increment = (BLangExpression) exprNodeStack.pop();
    postIncrement.opKind = OperatorKind.valueFrom(operator);
    addStmtToCurrentBlock(postIncrement);
}
Also used : BLangPostIncrement(org.wso2.ballerinalang.compiler.tree.statements.BLangPostIncrement)

Aggregations

BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)101 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)27 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)26 ArrayList (java.util.ArrayList)22 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)19 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)15 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)15 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)14 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)14 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)14 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)13 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)11 BLangArrayLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral)11 BLangRecordLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral)11 BLangTypeConversionExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeConversionExpr)11 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)10 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)10 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)10 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)10 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)10