use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createInvocationExpr.
static BLangInvocation createInvocationExpr(DiagnosticPos pos, BInvokableSymbol invokableSymbol, List<BLangVariable> requiredArgs, List<BLangVariable> namedArgs, List<BLangVariable> restArgs, SymbolResolver symResolver) {
final BLangInvocation invokeLambda = (BLangInvocation) TreeBuilder.createInvocationNode();
invokeLambda.pos = pos;
invokeLambda.requiredArgs.addAll(generateArgExprs(pos, requiredArgs, invokableSymbol.params, symResolver));
invokeLambda.namedArgs.addAll(generateArgExprs(pos, namedArgs, invokableSymbol.defaultableParams, symResolver));
invokeLambda.restArgs.addAll(generateArgExprs(pos, restArgs, Lists.of(invokableSymbol.restParam), symResolver));
invokeLambda.symbol = invokableSymbol;
invokeLambda.types.addAll(((BInvokableType) invokableSymbol.type).retTypes);
if (!invokeLambda.types.isEmpty()) {
invokeLambda.type = invokeLambda.types.get(0);
}
return invokeLambda;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation 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);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method visitActionInvocationEndpoint.
private void visitActionInvocationEndpoint(BLangInvocation iExpr) {
final BEndpointVarSymbol epSymbol = (BEndpointVarSymbol) iExpr.expr.symbol;
// Convert to endpoint.getClient(). iExpr has to be a VarRef.
final BLangInvocation getClientExpr = ASTBuilderUtil.createInvocationExpr(iExpr.expr.pos, epSymbol.getClientFunction, Collections.emptyList(), symResolver);
getClientExpr.expr = iExpr.expr;
iExpr.expr = getClientExpr;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method createInvocationFromTableExpr.
private BLangInvocation createInvocationFromTableExpr(BLangTableQueryExpression tableQueryExpression) {
List<BLangExpression> args = new ArrayList<>();
List<BType> retTypes = new ArrayList<>();
String functionName = QUERY_TABLE_WITHOUT_JOIN_CLAUSE;
// Order matters, because these are the args for a function invocation.
args.add(getSQLPreparedStatement(tableQueryExpression));
args.add(getFromTableVarRef(tableQueryExpression));
// BLangTypeofExpr
retTypes.add(tableQueryExpression.type);
BLangSimpleVarRef joinTable = getJoinTableVarRef(tableQueryExpression);
if (joinTable != null) {
args.add(joinTable);
functionName = QUERY_TABLE_WITH_JOIN_CLAUSE;
}
args.add(getSQLStatementParameters(tableQueryExpression));
args.add(getReturnType(tableQueryExpression));
return createInvocationNode(functionName, args, retTypes);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method visit.
@Override
public void visit(BLangInvocation iExpr) {
BLangInvocation genIExpr = iExpr;
// Reorder the arguments to match the original function signature.
reorderArguments(iExpr);
iExpr.requiredArgs = rewriteExprs(iExpr.requiredArgs);
iExpr.namedArgs = rewriteExprs(iExpr.namedArgs);
iExpr.restArgs = rewriteExprs(iExpr.restArgs);
if (iExpr.functionPointerInvocation) {
visitFunctionPointerInvocation(iExpr);
return;
} else if (iExpr.iterableOperationInvocation) {
visitIterableOperationInvocation(iExpr);
return;
}
if (iExpr.actionInvocation) {
visitActionInvocationEndpoint(iExpr);
}
iExpr.expr = rewriteExpr(iExpr.expr);
result = genIExpr;
if (iExpr.expr == null) {
return;
}
switch(iExpr.expr.type.tag) {
case TypeTags.BOOLEAN:
case TypeTags.STRING:
case TypeTags.INT:
case TypeTags.FLOAT:
case TypeTags.BLOB:
case TypeTags.JSON:
case TypeTags.XML:
case TypeTags.MAP:
case TypeTags.TABLE:
case TypeTags.STREAM:
case TypeTags.FUTURE:
case TypeTags.STRUCT:
List<BLangExpression> argExprs = new ArrayList<>(iExpr.requiredArgs);
argExprs.add(0, iExpr.expr);
final BLangAttachedFunctionInvocation attachedFunctionInvocation = new BLangAttachedFunctionInvocation(iExpr.pos, argExprs, iExpr.namedArgs, iExpr.restArgs, iExpr.symbol, iExpr.types, iExpr.expr, iExpr.async);
attachedFunctionInvocation.actionInvocation = iExpr.actionInvocation;
result = attachedFunctionInvocation;
break;
case TypeTags.CONNECTOR:
List<BLangExpression> actionArgExprs = new ArrayList<>(iExpr.requiredArgs);
actionArgExprs.add(0, iExpr.expr);
result = new BLangActionInvocation(iExpr.pos, actionArgExprs, iExpr.namedArgs, iExpr.restArgs, iExpr.symbol, iExpr.types, iExpr.async);
break;
}
}
Aggregations