Search in sources :

Example 6 with BLangIdentifier

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

the class CodeGenerator method visit.

public void visit(BLangForkJoin forkJoin) {
    SymbolEnv forkJoinEnv = SymbolEnv.createForkJoinSymbolEnv(forkJoin, this.env);
    ForkjoinInfo forkjoinInfo = new ForkjoinInfo(this.lvIndexes.toArray());
    this.populateForkJoinWorkerInfo(forkJoin, forkjoinInfo);
    int forkJoinInfoIndex = this.forkJoinCount++;
    /* was I already inside a fork/join */
    if (this.env.forkJoin != null) {
        this.currentWorkerInfo.addForkJoinInfo(forkjoinInfo);
    } else {
        this.currentCallableUnitInfo.defaultWorkerInfo.addForkJoinInfo(forkjoinInfo);
    }
    ForkJoinCPEntry forkJoinCPEntry = new ForkJoinCPEntry(forkJoinInfoIndex);
    Operand forkJoinCPIndex = getOperand(this.currentPkgInfo.addCPEntry(forkJoinCPEntry));
    forkjoinInfo.setIndexCPIndex(forkJoinCPIndex.value);
    RegIndex timeoutRegIndex = new RegIndex(-1, TypeTags.INT);
    addToRegIndexList(timeoutRegIndex);
    if (forkJoin.timeoutExpression != null) {
        forkjoinInfo.setTimeoutAvailable(true);
        this.genNode(forkJoin.timeoutExpression, forkJoinEnv);
        timeoutRegIndex.value = forkJoin.timeoutExpression.regIndex.value;
    }
    // FORKJOIN forkJoinCPIndex timeoutRegIndex joinVarRegIndex joinBlockAddr timeoutVarRegIndex timeoutBlockAddr
    RegIndex joinVarRegIndex = new RegIndex(-1, TypeTags.MAP);
    Operand joinBlockAddr = getOperand(-1);
    RegIndex timeoutVarRegIndex = new RegIndex(-1, TypeTags.MAP);
    Operand timeoutBlockAddr = getOperand(-1);
    this.emit(InstructionCodes.FORKJOIN, forkJoinCPIndex, timeoutRegIndex, joinVarRegIndex, joinBlockAddr, timeoutVarRegIndex, timeoutBlockAddr);
    this.processJoinWorkers(forkJoin, forkjoinInfo, forkJoinEnv);
    int i = 0;
    int[] joinWrkrNameCPIndexes = new int[forkJoin.joinedWorkers.size()];
    String[] joinWrkrNames = new String[joinWrkrNameCPIndexes.length];
    for (BLangIdentifier workerName : forkJoin.joinedWorkers) {
        UTF8CPEntry workerNameCPEntry = new UTF8CPEntry(workerName.value);
        int workerNameCPIndex = this.currentPkgInfo.addCPEntry(workerNameCPEntry);
        joinWrkrNameCPIndexes[i] = workerNameCPIndex;
        joinWrkrNames[i] = workerName.value;
        i++;
    }
    forkjoinInfo.setJoinWrkrNameIndexes(joinWrkrNameCPIndexes);
    forkjoinInfo.setJoinWorkerNames(joinWrkrNames);
    forkjoinInfo.setWorkerCount(forkJoin.joinedWorkerCount);
    this.processJoinBlock(forkJoin, forkjoinInfo, forkJoinEnv, joinVarRegIndex, joinBlockAddr);
    this.processTimeoutBlock(forkJoin, forkJoinEnv, timeoutVarRegIndex, timeoutBlockAddr);
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) ForkjoinInfo(org.wso2.ballerinalang.programfile.ForkjoinInfo) Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) ForkJoinCPEntry(org.wso2.ballerinalang.programfile.cpentries.ForkJoinCPEntry) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 7 with BLangIdentifier

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

the class BLangPackageBuilder method addCatchClause.

public void addCatchClause(DiagnosticPos poc, Set<Whitespace> ws, String paramName) {
    BLangVariable variableNode = (BLangVariable) TreeBuilder.createVariableNode();
    variableNode.typeNode = (BLangType) this.typeNodeStack.pop();
    variableNode.name = (BLangIdentifier) createIdentifier(paramName);
    variableNode.pos = variableNode.typeNode.pos;
    variableNode.addWS(removeNthFromLast(ws, 3));
    BLangCatch catchNode = (BLangCatch) TreeBuilder.createCatchNode();
    catchNode.pos = poc;
    catchNode.addWS(ws);
    catchNode.body = (BLangBlockStmt) this.blockNodeStack.pop();
    catchNode.param = variableNode;
    tryCatchFinallyNodesStack.peek().catchBlocks.add(catchNode);
}
Also used : BLangCatch(org.wso2.ballerinalang.compiler.tree.statements.BLangCatch) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 8 with BLangIdentifier

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

the class BLangPackageBuilder method createDocumentationAttribute.

public void createDocumentationAttribute(DiagnosticPos pos, Set<Whitespace> ws, String attributeName, String endText, String docPrefix) {
    BLangDocumentationAttribute attrib = (BLangDocumentationAttribute) TreeBuilder.createDocumentationAttributeNode();
    attrib.documentationField = (BLangIdentifier) createIdentifier(attributeName);
    attrib.documentationText = endText;
    attrib.docTag = DocTag.fromString(docPrefix);
    attrib.pos = pos;
    attrib.addWS(ws);
    docAttachmentStack.peek().addAttribute(attrib);
}
Also used : BLangDocumentationAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangDocumentationAttribute)

Example 9 with BLangIdentifier

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

the class BLangPackageBuilder method createFieldBasedAccessNode.

public void createFieldBasedAccessNode(DiagnosticPos pos, Set<Whitespace> ws, String fieldName, FieldType fieldType) {
    BLangFieldBasedAccess fieldBasedAccess = (BLangFieldBasedAccess) TreeBuilder.createFieldBasedAccessNode();
    fieldBasedAccess.pos = pos;
    fieldBasedAccess.addWS(ws);
    fieldBasedAccess.field = (BLangIdentifier) createIdentifier(fieldName);
    fieldBasedAccess.expr = (BLangVariableReference) exprNodeStack.pop();
    fieldBasedAccess.fieldType = fieldType;
    addExpressionNode(fieldBasedAccess);
}
Also used : BLangFieldBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess)

Example 10 with BLangIdentifier

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

the class BLangPackageBuilder method addEnumerator.

public void addEnumerator(DiagnosticPos pos, Set<Whitespace> ws, String name) {
    BLangEnumerator enumerator = (BLangEnumerator) TreeBuilder.createEnumeratorNode();
    enumerator.pos = pos;
    enumerator.addWS(ws);
    enumerator.name = (BLangIdentifier) createIdentifier(name);
    enumeratorList.add(enumerator);
}
Also used : BLangEnumerator(org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator)

Aggregations

BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)20 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)9 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)8 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)7 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)7 BLangUserDefinedType (org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)6 ArrayList (java.util.ArrayList)5 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)5 BLangImportPackage (org.wso2.ballerinalang.compiler.tree.BLangImportPackage)5 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)4 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)4 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)4 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)4 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)4 Name (org.wso2.ballerinalang.compiler.util.Name)4 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)3 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)3 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)3 List (java.util.List)2 Set (java.util.Set)2