use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class CodeGenerator method addWorkerInfoEntries.
private void addWorkerInfoEntries(CallableUnitInfo callableUnitInfo, List<BLangWorker> workers) {
UTF8CPEntry workerNameCPEntry = new UTF8CPEntry("default");
int workerNameCPIndex = this.currentPkgInfo.addCPEntry(workerNameCPEntry);
WorkerInfo defaultWorkerInfo = new WorkerInfo(workerNameCPIndex, "default");
callableUnitInfo.defaultWorkerInfo = defaultWorkerInfo;
for (BLangWorker worker : workers) {
workerNameCPEntry = new UTF8CPEntry(worker.name.value);
workerNameCPIndex = currentPkgInfo.addCPEntry(workerNameCPEntry);
WorkerInfo workerInfo = new WorkerInfo(workerNameCPIndex, worker.getName().value);
callableUnitInfo.addWorkerInfo(worker.getName().value, workerInfo);
}
}
use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class CodeGenerator method populateForkJoinWorkerInfo.
private void populateForkJoinWorkerInfo(BLangForkJoin forkJoin, ForkjoinInfo forkjoinInfo) {
for (BLangWorker worker : forkJoin.workers) {
UTF8CPEntry workerNameCPEntry = new UTF8CPEntry(worker.name.value);
int workerNameCPIndex = this.currentPkgInfo.addCPEntry(workerNameCPEntry);
WorkerInfo workerInfo = new WorkerInfo(workerNameCPIndex, worker.name.value);
forkjoinInfo.addWorkerInfo(worker.name.value, workerInfo);
}
}
use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class CodeGenerator method getDefaultValue.
private DefaultValue getDefaultValue(BLangLiteral literalExpr) {
String desc = literalExpr.type.getDesc();
int typeDescCPIndex = addUTF8CPEntry(currentPkgInfo, desc);
DefaultValue defaultValue = new DefaultValue(typeDescCPIndex, desc);
int typeTag = literalExpr.type.tag;
switch(typeTag) {
case TypeTags.INT:
defaultValue.intValue = (Long) literalExpr.value;
defaultValue.valueCPIndex = currentPkgInfo.addCPEntry(new IntegerCPEntry(defaultValue.intValue));
break;
case TypeTags.FLOAT:
defaultValue.floatValue = (Double) literalExpr.value;
defaultValue.valueCPIndex = currentPkgInfo.addCPEntry(new FloatCPEntry(defaultValue.floatValue));
break;
case TypeTags.STRING:
defaultValue.stringValue = (String) literalExpr.value;
defaultValue.valueCPIndex = currentPkgInfo.addCPEntry(new UTF8CPEntry(defaultValue.stringValue));
break;
case TypeTags.BOOLEAN:
defaultValue.booleanValue = (Boolean) literalExpr.value;
break;
default:
defaultValue = null;
}
return defaultValue;
}
use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class CodeGenerator method processJoinWorkers.
/* visit the workers within fork-join block */
private void processJoinWorkers(BLangForkJoin forkJoin, ForkjoinInfo forkjoinInfo, SymbolEnv forkJoinEnv) {
UTF8CPEntry codeUTF8CPEntry = new UTF8CPEntry(AttributeInfo.Kind.CODE_ATTRIBUTE.toString());
int codeAttribNameIndex = this.currentPkgInfo.addCPEntry(codeUTF8CPEntry);
for (BLangWorker worker : forkJoin.workers) {
VariableIndex lvIndexesCopy = copyVarIndex(this.lvIndexes);
this.regIndexes = new VariableIndex(REG);
VariableIndex regIndexesCopy = this.regIndexes;
this.regIndexes = new VariableIndex(REG);
VariableIndex maxRegIndexesCopy = this.maxRegIndexes;
this.maxRegIndexes = new VariableIndex(REG);
List<RegIndex> regIndexListCopy = this.regIndexList;
this.regIndexList = new ArrayList<>();
WorkerInfo workerInfo = forkjoinInfo.getWorkerInfo(worker.name.value);
workerInfo.codeAttributeInfo.attributeNameIndex = codeAttribNameIndex;
workerInfo.codeAttributeInfo.codeAddrs = this.nextIP();
this.currentWorkerInfo = workerInfo;
this.genNode(worker.body, forkJoinEnv);
this.endWorkerInfoUnit(workerInfo.codeAttributeInfo);
this.emit(InstructionCodes.HALT);
this.lvIndexes = lvIndexesCopy;
this.regIndexes = regIndexesCopy;
this.maxRegIndexes = maxRegIndexesCopy;
this.regIndexList = regIndexListCopy;
}
}
Aggregations