use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class TypeChecker method checkFunctionInvocationExpr.
private void checkFunctionInvocationExpr(BLangInvocation iExpr, BType bType) {
Name funcName = names.fromString(Symbols.getAttachedFuncSymbolName(bType.toString(), iExpr.name.value));
BPackageSymbol packageSymbol = (BPackageSymbol) bType.tsymbol.owner;
BSymbol funcSymbol = symResolver.lookupMemberSymbol(iExpr.pos, packageSymbol.scope, this.env, funcName, SymTag.FUNCTION);
if (funcSymbol == symTable.notFoundSymbol) {
dlog.error(iExpr.pos, DiagnosticCode.UNDEFINED_FUNCTION, funcName);
resultTypes = getListWithErrorTypes(expTypes.size());
return;
}
iExpr.symbol = funcSymbol;
checkInvocationParamAndReturnType(iExpr);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method visit.
@Override
public void visit(BLangTypeConversionExpr conversionExpr) {
conversionExpr.expr = rewriteExpr(conversionExpr.expr);
// Built-in conversion
if (conversionExpr.conversionSymbol.tag != SymTag.TRANSFORMER) {
result = conversionExpr;
return;
}
// Named transformer invocation
BLangInvocation transformerInvoc = conversionExpr.transformerInvocation;
if (transformerInvoc != null) {
transformerInvoc = rewriteExpr(transformerInvoc);
// Add the rExpr as the first argument
conversionExpr.transformerInvocation.requiredArgs.add(0, conversionExpr.expr);
result = new BLangTransformerInvocation(conversionExpr.pos, transformerInvoc.requiredArgs, transformerInvoc.namedArgs, transformerInvoc.restArgs, transformerInvoc.symbol, conversionExpr.types);
conversionExpr.transformerInvocation = transformerInvoc;
return;
}
// Unnamed transformer invocation
BConversionOperatorSymbol transformerSym = conversionExpr.conversionSymbol;
transformerInvoc = new BLangTransformerInvocation(conversionExpr.pos, Lists.of(conversionExpr.expr), transformerSym, conversionExpr.types);
transformerInvoc.types = transformerSym.type.getReturnTypes();
result = transformerInvoc;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method reorderNamedArgs.
private void reorderNamedArgs(BLangInvocation iExpr, BInvokableSymbol invocableSymbol) {
Map<String, BLangExpression> namedArgs = new HashMap<>();
iExpr.namedArgs.forEach(expr -> namedArgs.put(((NamedArgNode) expr).getName().value, expr));
// Re-order the named arguments
List<BLangExpression> args = new ArrayList<>();
for (BVarSymbol param : invocableSymbol.defaultableParams) {
args.add(namedArgs.get(param.name.value));
}
iExpr.namedArgs = args;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class Desugar method createInvocationForForeverBlock.
private BLangInvocation createInvocationForForeverBlock(BLangForever forever) {
List<BLangExpression> args = new ArrayList<>();
List<BType> retTypes = new ArrayList<>();
retTypes.add(symTable.noType);
BLangLiteral streamingQueryLiteral = ASTBuilderUtil.createLiteral(forever.pos, symTable.stringType, forever.getSiddhiQuery());
args.add(streamingQueryLiteral);
addReferenceVariablesToArgs(args, siddhiQueryBuilder.getInStreamRefs());
addReferenceVariablesToArgs(args, siddhiQueryBuilder.getInTableRefs());
addReferenceVariablesToArgs(args, siddhiQueryBuilder.getOutStreamRefs());
addReferenceVariablesToArgs(args, siddhiQueryBuilder.getOutTableRefs());
addFunctionPointersToArgs(args, forever.gettreamingQueryStatements());
return createInvocationNode(CREATE_FOREVER, args, retTypes);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation in project ballerina by ballerina-lang.
the class EndpointDesugar method generateEndpointStartOrStop.
private BLangBlockStmt generateEndpointStartOrStop(BLangEndpoint endpoint, BInvokableSymbol funSymbol, SymbolEnv env, BSymbol encSymbol) {
BLangBlockStmt temp = new BLangBlockStmt();
if (funSymbol == null || endpoint.configurationExpr == null || endpoint.configurationExpr.getKind() != NodeKind.RECORD_LITERAL_EXPR) {
// 2: If endpoint in initialized
return temp;
}
final DiagnosticPos pos = endpoint.pos;
final String epName = endpoint.name.value;
final BLangVariable epVariable = ASTBuilderUtil.createVariable(pos, epName, endpoint.symbol.type);
final Name name = names.fromIdNode(endpoint.name);
epVariable.symbol = (BVarSymbol) symResolver.lookupMemberSymbol(pos, encSymbol.scope, env, name, SymTag.VARIABLE);
List<BLangVariable> args = new ArrayList<>();
if (funSymbol.params.size() == 1) {
// Endpoint is already desugared. Fix this correctly.
args.add(0, epVariable);
}
final BLangExpressionStmt expressionStmt = ASTBuilderUtil.createExpressionStmt(pos, temp);
final BLangInvocation iExpr = ASTBuilderUtil.createInvocationExpr(pos, funSymbol, args, symResolver);
if (funSymbol.params.size() != 1) {
iExpr.expr = ASTBuilderUtil.createVariableRef(epVariable.pos, epVariable.symbol);
}
expressionStmt.expr = iExpr;
return temp;
}
Aggregations