Search in sources :

Example 1 with InvokableNode

use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endCallableUnitBody.

public void endCallableUnitBody(Set<Whitespace> ws) {
    BlockNode block = this.blockNodeStack.pop();
    InvokableNode invokableNode = this.invokableNodeStack.peek();
    invokableNode.addWS(ws);
    invokableNode.setBody(block);
}
Also used : BlockNode(org.ballerinalang.model.tree.statements.BlockNode) InvokableNode(org.ballerinalang.model.tree.InvokableNode)

Example 2 with InvokableNode

use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addWorker.

public void addWorker(DiagnosticPos pos, Set<Whitespace> ws, String workerName) {
    BLangWorker worker = (BLangWorker) this.invokableNodeStack.pop();
    worker.setName(createIdentifier(workerName));
    worker.pos = pos;
    worker.addWS(ws);
    worker.setBody(this.blockNodeStack.pop());
    if (this.forkJoinNodesStack.empty()) {
        InvokableNode invokableNode = this.invokableNodeStack.peek();
        invokableNode.getParameters().forEach(worker::addParameter);
        invokableNode.getReturnParameters().forEach(worker::addReturnParameter);
        invokableNode.addWorker(worker);
        invokableNode.addFlag(Flag.PARALLEL);
    } else {
        ((BLangForkJoin) this.forkJoinNodesStack.peek()).workers.add(worker);
    }
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) InvokableNode(org.ballerinalang.model.tree.InvokableNode)

Example 3 with InvokableNode

use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endObjectInitParamList.

void endObjectInitParamList(Set<Whitespace> ws, boolean paramsAvail, boolean restParamAvail) {
    InvokableNode invNode = this.invokableNodeStack.peek();
    invNode.addWS(ws);
    if (paramsAvail) {
        this.varListStack.pop().forEach(variableNode -> {
            ((BLangVariable) variableNode).docTag = DocTag.PARAM;
            invNode.addParameter(variableNode);
        });
        this.defaultableParamsList.forEach(variableDef -> {
            BLangVariableDef varDef = (BLangVariableDef) variableDef;
            varDef.var.docTag = DocTag.PARAM;
            invNode.addDefaultableParameter(varDef);
        });
        this.defaultableParamsList = new ArrayList<>();
        if (restParamAvail) {
            invNode.setRestParameter(this.restParamStack.pop());
        }
    }
}
Also used : InvokableNode(org.ballerinalang.model.tree.InvokableNode) BLangVariableDef(org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)

Example 4 with InvokableNode

use of org.ballerinalang.model.tree.InvokableNode in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endCallableUnitSignature.

public void endCallableUnitSignature(Set<Whitespace> ws, String identifier, boolean paramsAvail, boolean retParamsAvail, boolean restParamAvail) {
    InvokableNode invNode = this.invokableNodeStack.peek();
    invNode.setName(this.createIdentifier(identifier));
    invNode.addWS(ws);
    if (retParamsAvail) {
        BLangVariable variableNode = (BLangVariable) this.varStack.pop();
        variableNode.docTag = DocTag.RETURN;
        invNode.addReturnParameter(variableNode);
    }
    if (paramsAvail) {
        this.varListStack.pop().forEach(variableNode -> {
            ((BLangVariable) variableNode).docTag = DocTag.PARAM;
            invNode.addParameter(variableNode);
        });
        this.defaultableParamsList.forEach(variableDef -> {
            BLangVariableDef varDef = (BLangVariableDef) variableDef;
            varDef.var.docTag = DocTag.PARAM;
            invNode.addDefaultableParameter(varDef);
        });
        this.defaultableParamsList = new ArrayList<>();
        if (restParamAvail) {
            invNode.setRestParameter(this.restParamStack.pop());
        }
    }
}
Also used : InvokableNode(org.ballerinalang.model.tree.InvokableNode) BLangVariableDef(org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Aggregations

InvokableNode (org.ballerinalang.model.tree.InvokableNode)4 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)2 BlockNode (org.ballerinalang.model.tree.statements.BlockNode)1 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)1 BLangWorker (org.wso2.ballerinalang.compiler.tree.BLangWorker)1