Search in sources :

Example 1 with BLangIntRangeExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangIntRangeExpression 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 2 with BLangIntRangeExpression

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

the class CodeGenerator method visit.

@Override
public void visit(BLangIntRangeExpression rangeExpr) {
    BLangExpression startExpr = rangeExpr.startExpr;
    BLangExpression endExpr = rangeExpr.endExpr;
    genNode(startExpr, env);
    genNode(endExpr, env);
    rangeExpr.regIndex = calcAndGetExprRegIndex(rangeExpr);
    if (!rangeExpr.includeStart || !rangeExpr.includeEnd) {
        RegIndex const1RegIndex = getRegIndex(TypeTags.INT);
        emit(InstructionCodes.ICONST_1, const1RegIndex);
        if (!rangeExpr.includeStart) {
            emit(InstructionCodes.IADD, startExpr.regIndex, const1RegIndex, startExpr.regIndex);
        }
        if (!rangeExpr.includeEnd) {
            emit(InstructionCodes.ISUB, endExpr.regIndex, const1RegIndex, endExpr.regIndex);
        }
    }
    emit(InstructionCodes.NEW_INT_RANGE, startExpr.regIndex, endExpr.regIndex, rangeExpr.regIndex);
}
Also used : BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 3 with BLangIntRangeExpression

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

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangIntRangeExpression intRangeExpression) {
    intRangeExpr = new StringBuilder();
    intRangeExpr.append("<");
    intRangeExpression.startExpr.accept(this);
    intRangeExpr.append(varRef).append(":");
    varRef = "";
    BLangExpression endExpr = intRangeExpression.endExpr;
    if (endExpr != null) {
        addVarRefToClauseBuilder(endExpr, intRangeExpr);
    }
    intRangeExpr.append(">");
}
Also used : BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)2 BLangIntRangeExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangIntRangeExpression)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1