Search in sources :

Example 6 with BLangFieldBasedAccess

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

the class BLangPackageBuilder method createFieldBasedAccessNode.

public void createFieldBasedAccessNode(DiagnosticPos pos, Set<Whitespace> ws, String fieldName, FieldType fieldType) {
    BLangFieldBasedAccess fieldBasedAccess = (BLangFieldBasedAccess) TreeBuilder.createFieldBasedAccessNode();
    fieldBasedAccess.pos = pos;
    fieldBasedAccess.addWS(ws);
    fieldBasedAccess.field = (BLangIdentifier) createIdentifier(fieldName);
    fieldBasedAccess.expr = (BLangVariableReference) exprNodeStack.pop();
    fieldBasedAccess.fieldType = fieldType;
    addExpressionNode(fieldBasedAccess);
}
Also used : BLangFieldBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess)

Example 7 with BLangFieldBasedAccess

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

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangFieldBasedAccess fieldAccessExpr) {
    BLangSimpleVarRef expr = (BLangSimpleVarRef) fieldAccessExpr.expr;
    String sqlExpr = expr.variableName.value + "." + fieldAccessExpr.field.value;
    exprStack.push(sqlExpr);
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)

Example 8 with BLangFieldBasedAccess

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

the class TaintAnalyzer method updatedVarRefTaintedState.

private void updatedVarRefTaintedState(BLangVariableReference varRef, boolean taintedState) {
    if (varRef instanceof BLangSimpleVarRef) {
        setTaintedStatus(varRef, taintedState);
    } else if (varRef instanceof BLangIndexBasedAccess) {
        BLangIndexBasedAccess indexBasedAccessExpr = (BLangIndexBasedAccess) varRef;
        updatedVarRefTaintedState(indexBasedAccessExpr.expr, taintedState);
    } else if (varRef instanceof BLangFieldBasedAccess) {
        BLangFieldBasedAccess fieldBasedAccessExpr = (BLangFieldBasedAccess) varRef;
        updatedVarRefTaintedState(fieldBasedAccessExpr.expr, taintedState);
    }
}
Also used : BLangIndexBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess) BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BLangFieldBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess)

Example 9 with BLangFieldBasedAccess

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

the class Desugar method visitFunctionPointerInvocation.

// private functions
private void visitFunctionPointerInvocation(BLangInvocation iExpr) {
    BLangVariableReference expr;
    if (iExpr.expr == null) {
        expr = new BLangSimpleVarRef();
    } else {
        BLangFieldBasedAccess fieldBasedAccess = new BLangFieldBasedAccess();
        fieldBasedAccess.expr = iExpr.expr;
        fieldBasedAccess.field = iExpr.name;
        expr = fieldBasedAccess;
    }
    expr.symbol = (BVarSymbol) iExpr.symbol;
    expr.type = iExpr.symbol.type;
    expr = rewriteExpr(expr);
    result = new BFunctionPointerInvocation(iExpr, expr);
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BLangFieldBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess) BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference) BFunctionPointerInvocation(org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation.BFunctionPointerInvocation)

Example 10 with BLangFieldBasedAccess

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

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangFieldBasedAccess fieldAccessExpr) {
    varRef = fieldAccessExpr.toString();
    if (fieldAccessExpr.expr instanceof BLangIndexBasedAccess) {
        BLangIndexBasedAccess indexBasedAccess = (BLangIndexBasedAccess) fieldAccessExpr.expr;
        String exprName = indexBasedAccess.expr.toString() + ".length";
        if (varRef.contains(exprName)) {
            varRef = varRef.replaceFirst(exprName, "last");
        }
    }
}
Also used : BLangIndexBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)

Aggregations

BLangFieldBasedAccess (org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess)5 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)5 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)4 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)3 BLangIndexBasedAccess (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)3 ArrayList (java.util.ArrayList)1 VariableReferenceNode (org.ballerinalang.model.tree.expressions.VariableReferenceNode)1 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)1 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)1 BEnumType (org.wso2.ballerinalang.compiler.semantics.model.types.BEnumType)1 BJSONType (org.wso2.ballerinalang.compiler.semantics.model.types.BJSONType)1 BTupleType (org.wso2.ballerinalang.compiler.semantics.model.types.BTupleType)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangEnumeratorAccessExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess.BLangEnumeratorAccessExpr)1 BLangStructFieldAccessExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess.BLangStructFieldAccessExpr)1 BLangJSONAccessExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess.BLangJSONAccessExpr)1 BLangMapAccessExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess.BLangMapAccessExpr)1 BLangXMLAccessExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess.BLangXMLAccessExpr)1 BFunctionPointerInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation.BFunctionPointerInvocation)1 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)1