Search in sources :

Example 1 with BLangFunctionTypeNode

use of org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode in project ballerina by ballerina-lang.

the class SymbolResolver method visit.

@Override
public void visit(BLangFunctionTypeNode functionTypeNode) {
    List<BType> paramTypes = new ArrayList<>();
    List<BType> retParamTypes = new ArrayList<>();
    functionTypeNode.getParamTypeNode().forEach(t -> paramTypes.add(resolveTypeNode((BLangType) t, env)));
    functionTypeNode.getReturnParamTypeNode().forEach(t -> retParamTypes.add(resolveTypeNode((BLangType) t, env)));
    resultType = new BInvokableType(paramTypes, retParamTypes, null);
}
Also used : BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) ArrayList(java.util.ArrayList) BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)

Example 2 with BLangFunctionTypeNode

use of org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addFunctionType.

public void addFunctionType(DiagnosticPos pos, Set<Whitespace> ws, boolean paramsAvail, boolean paramsTypeOnly, boolean retParamsAvail) {
    // TODO : Fix function main ()(boolean , function(string x)(float, int)){} issue
    BLangFunctionTypeNode functionTypeNode = (BLangFunctionTypeNode) TreeBuilder.createFunctionTypeNode();
    functionTypeNode.pos = pos;
    functionTypeNode.returnsKeywordExists = true;
    if (retParamsAvail) {
        // functionTypeNode.addWS(commaWsStack.pop());
        functionTypeNode.returnParamTypeNodes.add(this.varStack.pop().getTypeNode());
    }
    if (paramsAvail) {
        functionTypeNode.addWS(commaWsStack.pop());
        this.varListStack.pop().forEach(v -> functionTypeNode.paramTypeNodes.add(v.getTypeNode()));
    }
    functionTypeNode.addWS(ws);
    addType(functionTypeNode);
}
Also used : BLangFunctionTypeNode(org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode)

Aggregations

ArrayList (java.util.ArrayList)1 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 BLangFunctionTypeNode (org.wso2.ballerinalang.compiler.tree.types.BLangFunctionTypeNode)1