Search in sources :

Example 6 with UTF8CPEntry

use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.

the class CodeGenerator method createErrorTableIfAbsent.

private ErrorTableAttributeInfo createErrorTableIfAbsent(PackageInfo packageInfo) {
    ErrorTableAttributeInfo errorTable = (ErrorTableAttributeInfo) packageInfo.getAttributeInfo(AttributeInfo.Kind.ERROR_TABLE);
    if (errorTable == null) {
        UTF8CPEntry attribNameCPEntry = new UTF8CPEntry(AttributeInfo.Kind.ERROR_TABLE.toString());
        int attribNameCPIndex = packageInfo.addCPEntry(attribNameCPEntry);
        errorTable = new ErrorTableAttributeInfo(attribNameCPIndex);
        packageInfo.addAttributeInfo(AttributeInfo.Kind.ERROR_TABLE, errorTable);
    }
    return errorTable;
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) ErrorTableAttributeInfo(org.wso2.ballerinalang.programfile.attributes.ErrorTableAttributeInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 7 with UTF8CPEntry

use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.

the class CodeGenerator method createLineNumberInfo.

private LineNumberInfo createLineNumberInfo(DiagnosticPos pos, PackageInfo packageInfo, int ip) {
    UTF8CPEntry fileNameUTF8CPEntry = new UTF8CPEntry(pos.src.cUnitName);
    int fileNameCPEntryIndex = packageInfo.addCPEntry(fileNameUTF8CPEntry);
    LineNumberInfo lineNumberInfo = new LineNumberInfo(pos.sLine, fileNameCPEntryIndex, pos.src.cUnitName, ip);
    lineNumberInfo.setPackageInfo(packageInfo);
    lineNumberInfo.setIp(ip);
    return lineNumberInfo;
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) LineNumberInfo(org.wso2.ballerinalang.programfile.LineNumberInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 8 with UTF8CPEntry

use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangWorkerSend workerSendStmt) {
    WorkerDataChannelInfo workerDataChannelInfo = this.getWorkerDataChannelInfo(this.currentCallableUnitInfo, this.currentWorkerInfo.getWorkerName(), workerSendStmt.workerIdentifier.value);
    WorkerDataChannelRefCPEntry wrkrInvRefCPEntry = new WorkerDataChannelRefCPEntry(workerDataChannelInfo.getUniqueNameCPIndex(), workerDataChannelInfo.getUniqueName());
    wrkrInvRefCPEntry.setWorkerDataChannelInfo(workerDataChannelInfo);
    Operand wrkrInvRefCPIndex = getOperand(currentPkgInfo.addCPEntry(wrkrInvRefCPEntry));
    if (workerSendStmt.isForkJoinSend) {
        this.currentWorkerInfo.setWrkrDtChnlRefCPIndex(wrkrInvRefCPIndex.value);
        this.currentWorkerInfo.setWorkerDataChannelInfoForForkJoin(workerDataChannelInfo);
    }
    workerDataChannelInfo.setDataChannelRefIndex(wrkrInvRefCPIndex.value);
    int nArgExprs = workerSendStmt.exprs.size();
    RegIndex[] argRegs = new RegIndex[nArgExprs];
    BType[] bTypes = new BType[nArgExprs];
    for (int i = 0; i < nArgExprs; i++) {
        BLangExpression argExpr = workerSendStmt.exprs.get(i);
        genNode(argExpr, this.env);
        argRegs[i] = argExpr.regIndex;
        bTypes[i] = argExpr.type;
    }
    UTF8CPEntry sigCPEntry = new UTF8CPEntry(this.generateSig(bTypes));
    Operand sigCPIndex = getOperand(this.currentPkgInfo.addCPEntry(sigCPEntry));
    // WRKSEND wrkrInvRefCPIndex typesCPIndex nRegIndexes, regIndexes[nRegIndexes]
    Operand[] wrkSendArgRegs = new Operand[nArgExprs + 3];
    wrkSendArgRegs[0] = wrkrInvRefCPIndex;
    wrkSendArgRegs[1] = sigCPIndex;
    wrkSendArgRegs[2] = getOperand(nArgExprs);
    System.arraycopy(argRegs, 0, wrkSendArgRegs, 3, argRegs.length);
    this.emit(InstructionCodes.WRKSEND, wrkSendArgRegs);
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) WorkerDataChannelRefCPEntry(org.wso2.ballerinalang.programfile.cpentries.WorkerDataChannelRefCPEntry) WorkerDataChannelInfo(org.wso2.ballerinalang.programfile.WorkerDataChannelInfo) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 9 with UTF8CPEntry

use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.

the class CodeGenerator method addVariableCountAttributeInfo.

private void addVariableCountAttributeInfo(ConstantPool constantPool, AttributeInfoPool attributeInfoPool, int[] fieldCount) {
    UTF8CPEntry attribNameCPEntry = new UTF8CPEntry(AttributeInfo.Kind.VARIABLE_TYPE_COUNT_ATTRIBUTE.toString());
    int attribNameCPIndex = constantPool.addCPEntry(attribNameCPEntry);
    VarTypeCountAttributeInfo varCountAttribInfo = new VarTypeCountAttributeInfo(attribNameCPIndex);
    varCountAttribInfo.setMaxLongVars(fieldCount[INT_OFFSET]);
    varCountAttribInfo.setMaxDoubleVars(fieldCount[FLOAT_OFFSET]);
    varCountAttribInfo.setMaxStringVars(fieldCount[STRING_OFFSET]);
    varCountAttribInfo.setMaxIntVars(fieldCount[BOOL_OFFSET]);
    varCountAttribInfo.setMaxByteVars(fieldCount[BLOB_OFFSET]);
    varCountAttribInfo.setMaxRefVars(fieldCount[REF_OFFSET]);
    attributeInfoPool.addAttributeInfo(AttributeInfo.Kind.VARIABLE_TYPE_COUNT_ATTRIBUTE, varCountAttribInfo);
}
Also used : VarTypeCountAttributeInfo(org.wso2.ballerinalang.programfile.attributes.VarTypeCountAttributeInfo) UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 10 with UTF8CPEntry

use of org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangWorkerReceive workerReceiveStmt) {
    WorkerDataChannelInfo workerDataChannelInfo = this.getWorkerDataChannelInfo(this.currentCallableUnitInfo, workerReceiveStmt.workerIdentifier.value, this.currentWorkerInfo.getWorkerName());
    WorkerDataChannelRefCPEntry wrkrChnlRefCPEntry = new WorkerDataChannelRefCPEntry(workerDataChannelInfo.getUniqueNameCPIndex(), workerDataChannelInfo.getUniqueName());
    wrkrChnlRefCPEntry.setWorkerDataChannelInfo(workerDataChannelInfo);
    Operand wrkrRplyRefCPIndex = getOperand(currentPkgInfo.addCPEntry(wrkrChnlRefCPEntry));
    workerDataChannelInfo.setDataChannelRefIndex(wrkrRplyRefCPIndex.value);
    List<BLangExpression> lhsExprs = workerReceiveStmt.exprs;
    int nLHSExprs = lhsExprs.size();
    RegIndex[] regIndexes = new RegIndex[nLHSExprs];
    BType[] bTypes = new BType[nLHSExprs];
    for (int i = 0; i < nLHSExprs; i++) {
        BLangExpression lExpr = lhsExprs.get(i);
        if (lExpr.getKind() == NodeKind.SIMPLE_VARIABLE_REF && lExpr instanceof BLangLocalVarRef) {
            lExpr.regIndex = ((BLangLocalVarRef) lExpr).symbol.varIndex;
            regIndexes[i] = lExpr.regIndex;
        } else {
            lExpr.regIndex = getRegIndex(lExpr.type.tag);
            lExpr.regIndex.isLHSIndex = true;
            regIndexes[i] = lExpr.regIndex;
        }
        bTypes[i] = lExpr.type;
    }
    UTF8CPEntry sigCPEntry = new UTF8CPEntry(this.generateSig(bTypes));
    Operand sigCPIndex = getOperand(currentPkgInfo.addCPEntry(sigCPEntry));
    // WRKRECEIVE wrkrRplyRefCPIndex typesCPIndex nRegIndexes, regIndexes[nRegIndexes]
    Operand[] wrkReceiveArgRegs = new Operand[nLHSExprs + 3];
    wrkReceiveArgRegs[0] = wrkrRplyRefCPIndex;
    wrkReceiveArgRegs[1] = sigCPIndex;
    wrkReceiveArgRegs[2] = getOperand(nLHSExprs);
    System.arraycopy(regIndexes, 0, wrkReceiveArgRegs, 3, regIndexes.length);
    emit(InstructionCodes.WRKRECEIVE, wrkReceiveArgRegs);
    for (BLangExpression lExpr : lhsExprs) {
        if (lExpr.getKind() == NodeKind.SIMPLE_VARIABLE_REF && lExpr instanceof BLangLocalVarRef) {
            continue;
        }
        this.varAssignment = true;
        this.genNode(lExpr, this.env);
        this.varAssignment = false;
    }
}
Also used : BLangLocalVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangLocalVarRef) Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) WorkerDataChannelRefCPEntry(org.wso2.ballerinalang.programfile.cpentries.WorkerDataChannelRefCPEntry) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex) UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) WorkerDataChannelInfo(org.wso2.ballerinalang.programfile.WorkerDataChannelInfo) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

UTF8CPEntry (org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry)14 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)13 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)4 BLangWorker (org.wso2.ballerinalang.compiler.tree.BLangWorker)3 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)3 Operand (org.wso2.ballerinalang.programfile.Instruction.Operand)3 WorkerDataChannelInfo (org.wso2.ballerinalang.programfile.WorkerDataChannelInfo)3 WorkerInfo (org.wso2.ballerinalang.programfile.WorkerInfo)3 WorkerDataChannelRefCPEntry (org.wso2.ballerinalang.programfile.cpentries.WorkerDataChannelRefCPEntry)3 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)2 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)2 DefaultValue (org.wso2.ballerinalang.programfile.DefaultValue)2 FloatCPEntry (org.wso2.ballerinalang.programfile.cpentries.FloatCPEntry)2 ForkJoinCPEntry (org.wso2.ballerinalang.programfile.cpentries.ForkJoinCPEntry)2 IntegerCPEntry (org.wso2.ballerinalang.programfile.cpentries.IntegerCPEntry)2 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)1 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)1 BLangLocalVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangLocalVarRef)1 ForkjoinInfo (org.wso2.ballerinalang.programfile.ForkjoinInfo)1 LineNumberInfo (org.wso2.ballerinalang.programfile.LineNumberInfo)1