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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations