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);
}
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);
}
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(">");
}
Aggregations