use of org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation.BLangTransformerInvocation 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.BLangTransformerInvocation in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangTransformerInvocation iExpr) {
BInvokableSymbol transformerSymbol = (BInvokableSymbol) iExpr.symbol;
int pkgRefCPIndex = addPackageRefCPEntry(currentPkgInfo, transformerSymbol.pkgID);
int transformerNameCPIndex = addUTF8CPEntry(currentPkgInfo, transformerSymbol.name.value);
TransformerRefCPEntry transformerRefCPEntry = new TransformerRefCPEntry(pkgRefCPIndex, transformerNameCPIndex);
int transformerRefCPIndex = currentPkgInfo.addCPEntry(transformerRefCPEntry);
Operand[] operands = getFuncOperands(iExpr, transformerRefCPIndex);
emit(InstructionCodes.TCALL, operands);
}
Aggregations