Search in sources :

Example 6 with PackageInfo

use of org.wso2.ballerinalang.programfile.PackageInfo 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 PackageInfo

use of org.wso2.ballerinalang.programfile.PackageInfo 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 PackageInfo

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

the class CodeGenerator method generateNamedArgs.

private int generateNamedArgs(BLangInvocation iExpr, Operand[] operands, int currentIndex) {
    if (iExpr.namedArgs.isEmpty()) {
        return currentIndex;
    }
    PackageInfo pkgInfo = programFile.packageInfoMap.get(iExpr.symbol.pkgID.bvmAlias());
    CallableUnitInfo callableUnitInfo;
    if (iExpr.symbol.kind == SymbolKind.FUNCTION) {
        callableUnitInfo = pkgInfo.functionInfoMap.get(iExpr.symbol.name.value);
    } else if (iExpr.symbol.kind == SymbolKind.ACTION) {
        ConnectorInfo connectorInfo = pkgInfo.connectorInfoMap.get(iExpr.symbol.owner.name.value);
        callableUnitInfo = connectorInfo.actionInfoMap.get(iExpr.symbol.name.value);
    } else {
        throw new IllegalStateException("Unsupported callable unit");
    }
    ParamDefaultValueAttributeInfo defaultValAttrInfo = (ParamDefaultValueAttributeInfo) callableUnitInfo.getAttributeInfo(AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE);
    for (int i = 0; i < iExpr.namedArgs.size(); i++) {
        BLangExpression argExpr = iExpr.namedArgs.get(i);
        // at this point. If so, get the default value for that parameter from the function info.
        if (argExpr == null) {
            DefaultValue defaultVal = defaultValAttrInfo.getDefaultValueInfo()[i];
            argExpr = getDefaultValExpr(defaultVal);
        }
        operands[currentIndex++] = genNode(argExpr, this.env).regIndex;
    }
    return currentIndex;
}
Also used : DefaultValue(org.wso2.ballerinalang.programfile.DefaultValue) ParamDefaultValueAttributeInfo(org.wso2.ballerinalang.programfile.attributes.ParamDefaultValueAttributeInfo) ConnectorInfo(org.wso2.ballerinalang.programfile.ConnectorInfo) ImportPackageInfo(org.wso2.ballerinalang.programfile.ImportPackageInfo) PackageInfo(org.wso2.ballerinalang.programfile.PackageInfo) CallableUnitInfo(org.wso2.ballerinalang.programfile.CallableUnitInfo) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Aggregations

BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)3 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)2 StructureRefCPEntry (org.wso2.ballerinalang.programfile.cpentries.StructureRefCPEntry)2 UTF8CPEntry (org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Stack (java.util.Stack)1 Collectors (java.util.stream.Collectors)1 XMLConstants (javax.xml.XMLConstants)1 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)1 BallerinaFile (org.ballerinalang.composer.service.ballerina.parser.service.model.BallerinaFile)1