Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ina-lang into fix-issue-40614
  • Loading branch information
KavinduZoysa committed Aug 10, 2023
2 parents f6f1a71 + 33bab3d commit 494ae5c
Show file tree
Hide file tree
Showing 135 changed files with 9,350 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ public Optional<TypeSymbol> typeOf(LineRange range) {
}

private BType getDeterminedType(BLangNode node, LineRange range) {
if (node.getKind() == NodeKind.INVOCATION && node.getDeterminedType().getKind() == TypeKind.FUTURE) {
if (node.getKind() == NodeKind.INVOCATION && node.getDeterminedType() != null
&& node.getDeterminedType().getKind() == TypeKind.FUTURE) {
BLangInvocation invocationNode = (BLangInvocation) node;
if (invocationNode.isAsync()
&& PositionUtil.withinBlock(range.startLine(), invocationNode.getName().getPosition())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Map<String, List<String>> getPackages() {
}
String orgName = file.getName();
File[] filesList = this.bala.resolve(orgName).toFile().listFiles();
if (filesList == null) {
if (filesList == null || filesList.length == 0) {
continue;
}
List<String> pkgList = new ArrayList<>();
Expand All @@ -178,23 +178,24 @@ public Map<String, List<String>> getPackages() {
if (pkgs == null) {
continue;
}
String version = null;
List<String> versions = new ArrayList<>();
for (File listFile : pkgs) {
if (listFile.isHidden() || !listFile.isDirectory()) {
continue;
}
version = listFile.getName();
break;
versions.add(listFile.getName());
}
if (version == null) {
if (versions.isEmpty()) {
continue;
}
try {
PackageVersion.from(version);
} catch (ProjectException ignored) {
continue;
for (String version : versions) {
try {
PackageVersion.from(version);
} catch (ProjectException ignored) {
continue;
}
pkgList.add(pkgDir.getName() + ":" + version);
}
pkgList.add(pkgDir.getName() + ":" + version);
}
packagesMap.put(orgName, pkgList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1631,41 +1631,27 @@ public BType readType(int cpI) throws IOException {
}
return finiteType;
case TypeTags.OBJECT:
boolean service = inputStream.readByte() == 1;

pkgCpIndex = inputStream.readInt();
pkgId = getPackageId(pkgCpIndex);

String objName = getStringCPEntryValue(inputStream);
var objFlags = (inputStream.readBoolean() ? Flags.CLASS : 0) | Flags.PUBLIC;
objFlags = inputStream.readBoolean() ? objFlags | Flags.CLIENT : objFlags;
long objSymFlags = inputStream.readLong();
BObjectTypeSymbol objectSymbol;

if (Symbols.isFlagOn(objFlags, Flags.CLASS)) {
objectSymbol = Symbols.createClassSymbol(objFlags, names.fromString(objName),
env.pkgSymbol.pkgID, null, env.pkgSymbol,
symTable.builtinPos, COMPILED_SOURCE, false);
if (Symbols.isFlagOn(objSymFlags, Flags.CLASS)) {
objectSymbol = Symbols.createClassSymbol(objSymFlags, names.fromString(objName),
env.pkgSymbol.pkgID, null, env.pkgSymbol,
symTable.builtinPos, COMPILED_SOURCE, false);
} else {
objectSymbol = Symbols.createObjectSymbol(objFlags, names.fromString(objName),
env.pkgSymbol.pkgID, null, env.pkgSymbol,
symTable.builtinPos, COMPILED_SOURCE);
objectSymbol = Symbols.createObjectSymbol(objSymFlags, names.fromString(objName),
env.pkgSymbol.pkgID, null, env.pkgSymbol,
symTable.builtinPos, COMPILED_SOURCE);
}

objectSymbol.scope = new Scope(objectSymbol);
BObjectType objectType;
// Below is a temporary fix, need to fix this properly by using the type tag
objectType = new BObjectType(objectSymbol);

if (service) {
objectType.flags |= Flags.SERVICE;
objectSymbol.flags |= Flags.SERVICE;
}
if (isImmutable(flags)) {
objectSymbol.flags |= Flags.READONLY;
}
if (Symbols.isFlagOn(flags, Flags.ANONYMOUS)) {
objectSymbol.flags |= Flags.ANONYMOUS;
}
objectType.flags = flags;
objectSymbol.type = objectType;
addShapeCP(objectType, cpI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SIMPLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STREAM_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPE_CHECKER;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPE_CONVERTER;
Expand Down Expand Up @@ -1361,7 +1361,7 @@ static String getTargetClass(BType targetType) {
targetTypeClass = MAP_VALUE;
break;
case TypeTags.TABLE:
targetTypeClass = TABLE_VALUE_IMPL;
targetTypeClass = TABLE_VALUE;
break;
case TypeTags.STREAM:
targetTypeClass = STREAM_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_RUNTIME;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STRAND_METADATA;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STREAM_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TABLE_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TABLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPEDESC;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_XML;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.HANDLE_DESCRIPTOR_FOR_STRING_CONCAT;
Expand All @@ -144,7 +144,7 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_MAP_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_REGEX_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_STREAM_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_TABLE_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_TABLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_TYPEDESC_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.RETURN_XML_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.STRING_BUILDER_APPEND;
Expand Down Expand Up @@ -243,7 +243,7 @@ public static String getFieldTypeSignature(BType bType) {
case TypeTags.STREAM:
return GET_STREAM_VALUE;
case TypeTags.TABLE:
return GET_TABLE_VALUE_IMPL;
return GET_TABLE_VALUE;
case TypeTags.ARRAY:
case TypeTags.TUPLE:
return GET_ARRAY_VALUE;
Expand Down Expand Up @@ -434,7 +434,7 @@ public static String getArgTypeSignature(BType bType) {
case TypeTags.STREAM:
return GET_STREAM_VALUE;
case TypeTags.TABLE:
return GET_TABLE_VALUE_IMPL;
return GET_TABLE_VALUE;
case TypeTags.INVOKABLE:
return GET_FUNCTION_POINTER;
case TypeTags.TYPEDESC:
Expand Down Expand Up @@ -489,7 +489,7 @@ public static String generateReturnType(BType bType) {
case TypeTags.STREAM:
return RETURN_STREAM_VALUE;
case TypeTags.TABLE:
return RETURN_TABLE_VALUE_IMPL;
return RETURN_TABLE_VALUE;
case TypeTags.FUTURE:
return RETURN_FUTURE_VALUE;
case TypeTags.TYPEDESC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_TYPE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.THROWABLE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TOML_DETAILS;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TRANSACTION_CONTEXT_CLASS;
Expand Down Expand Up @@ -253,7 +252,7 @@ public class JvmSignatures {
public static final String GET_STRING = "L" + STRING_VALUE + ";";
public static final String GET_STRING_AT = "(L" + B_STRING_VALUE + ";J)L" + B_STRING_VALUE + ";";
public static final String GET_STRING_FROM_ARRAY = "(J)L" + OBJECT + ";";
public static final String GET_TABLE_VALUE_IMPL = "L" + TABLE_VALUE_IMPL + ";";
public static final String GET_TABLE_VALUE = "L" + TABLE_VALUE + ";";
public static final String GET_THROWABLE = "L" + THROWABLE + ";";
public static final String GET_TUPLE_TYPE_IMPL = "L" + TUPLE_TYPE_IMPL + ";";
public static final String GET_TYPE = "L" + TYPE + ";";
Expand Down Expand Up @@ -418,7 +417,7 @@ public class JvmSignatures {
public static final String RETURN_MAP_VALUE = ")L" + MAP_VALUE + ";";
public static final String RETURN_OBJECT = "()L" + OBJECT + ";";
public static final String RETURN_STREAM_VALUE = ")L" + STREAM_VALUE + ";";
public static final String RETURN_TABLE_VALUE_IMPL = ")L" + TABLE_VALUE_IMPL + ";";
public static final String RETURN_TABLE_VALUE = ")L" + TABLE_VALUE + ";";
public static final String RETURN_TYPEDESC_VALUE = ")L" + TYPEDESC_VALUE + ";";
public static final String RETURN_XML_VALUE = ")L" + XML_VALUE + ";";
public static final String SCHEDULE_LOCAL = "([L" + OBJECT + ";L" + B_FUNCTION_POINTER + ";L" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_OBJECT;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_REGEXP;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STREAM_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TABLE_VALUE_IMPL;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TABLE_VALUE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPE;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPEDESC;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPE_REF_TYPE_IMPL;
Expand Down Expand Up @@ -985,7 +985,8 @@ private void populateFunctionParameters(MethodVisitor mv, BInvokableTypeSymbol i
} else {
mv.visitInsn(ICONST_0);
}
BInvokableSymbol bInvokableSymbol = invokableSymbol.defaultValues.get(paramSymbol.originalName.value);
BInvokableSymbol bInvokableSymbol = invokableSymbol.defaultValues.get(
Utils.decodeIdentifier(paramSymbol.name.value));
if (bInvokableSymbol == null) {
mv.visitInsn(ACONST_NULL);
} else {
Expand Down Expand Up @@ -1086,7 +1087,7 @@ public static String getTypeDesc(BType bType) {
case TypeTags.STREAM:
return GET_STREAM_VALUE;
case TypeTags.TABLE:
return GET_TABLE_VALUE_IMPL;
return GET_TABLE_VALUE;
case TypeTags.DECIMAL:
return GET_BDECIMAL;
case TypeTags.OBJECT:
Expand Down
Loading

0 comments on commit 494ae5c

Please sign in to comment.