use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class CodeGenerator method visitXMLTagName.
/**
* Visit XML tag name and return the index of the tag name in the reference registry.
*
* @param tagName Tag name expression
* @param xmlElementEnv Environment of the XML element of the tag
* @param xmlElementLiteral XML element literal to which the tag name belongs to
* @return Index of the tag name, in the reference registry
*/
private RegIndex visitXMLTagName(BLangExpression tagName, SymbolEnv xmlElementEnv, BLangXMLElementLiteral xmlElementLiteral) {
genNode(tagName, xmlElementEnv);
RegIndex startTagNameRegIndex = tagName.regIndex;
// If this is a string representation of element name, generate the namespace lookup instructions
if (tagName.getKind() != NodeKind.XML_QNAME) {
RegIndex localNameRegIndex = getRegIndex(TypeTags.STRING);
RegIndex uriRegIndex = getRegIndex(TypeTags.STRING);
emit(InstructionCodes.S2QNAME, startTagNameRegIndex, localNameRegIndex, uriRegIndex);
startTagNameRegIndex = getRegIndex(TypeTags.XML);
generateURILookupInstructions(xmlElementLiteral.namespacesInScope, localNameRegIndex, uriRegIndex, startTagNameRegIndex, xmlElementLiteral.pos, xmlElementEnv);
tagName.regIndex = startTagNameRegIndex;
}
return startTagNameRegIndex;
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangTransformer transformerNode) {
SymbolEnv transformerEnv = SymbolEnv.createTransformerEnv(transformerNode, transformerNode.symbol.scope, this.env);
currentCallableUnitInfo = currentPkgInfo.transformerInfoMap.get(transformerNode.symbol.name.value);
visitInvokableNode(transformerNode, currentCallableUnitInfo, transformerEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class CodeGenerator method processTimeoutBlock.
/* generate code for timeout block */
private void processTimeoutBlock(BLangForkJoin forkJoin, SymbolEnv forkJoinEnv, RegIndex timeoutVarRegIndex, Operand timeoutBlockAddr) {
/* emit a GOTO instruction to jump out of the timeout block */
Operand gotoAddr = getOperand(-1);
this.emit(InstructionCodes.GOTO, gotoAddr);
timeoutBlockAddr.value = nextIP();
if (forkJoin.timeoutVariable != null) {
visitForkJoinParameterDefs(forkJoin.timeoutVariable, forkJoinEnv);
timeoutVarRegIndex.value = forkJoin.timeoutVariable.symbol.varIndex.value;
}
if (forkJoin.timeoutBody != null) {
this.genNode(forkJoin.timeoutBody, forkJoinEnv);
}
gotoAddr.value = nextIP();
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangFunction funcNode) {
SymbolEnv funcEnv = SymbolEnv.createFunctionEnv(funcNode, funcNode.symbol.scope, this.env);
currentCallableUnitInfo = currentPkgInfo.functionInfoMap.get(funcNode.symbol.name.value);
visitInvokableNode(funcNode, currentCallableUnitInfo, funcEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv 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);
}
Aggregations