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