Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Jan 11, 2023
2 parents 596afa5 + 9ead5e6 commit b887fe6
Show file tree
Hide file tree
Showing 1,544 changed files with 92,599 additions and 102,967 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/language_server_simulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: ["master", "2201.1.x", "2201.2.x", "2201.2.2-stage", "2201.3.x", "2201.3.0-stage"]
branch: ["master", "2201.2.x", "2201.3.x", "2201.3.0-stage"]
skipGenerators: ["", "IMPORT_STATEMENT"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_publish_timestamped_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
branch: ['master', '2201.0.x', '2201.1.x', '2201.2.x']
branch: ['master', '2201.2.x', '2201.3.x']
timeout-minutes: 240
if: github.repository_owner == 'ballerina-platform'
steps:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/pull_request_full_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ jobs:
do git clone https://github.com/ballerina-platform/${module_name}.git; \
done
- name: Checkout non-default branch
run: |
for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); \
do
cd $module_name
git fetch origin
git checkout -t origin/update4 || :
cd ..
done
# - name: Checkout non-default branch
# run: |
# for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); \
# do
# cd $module_name
# git fetch origin
# git checkout -t origin/update4 || :
# cd ..
# done

- name: Update Lang Version in Module
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 2201.[0-9]+.x
- 2201.[0-9]+.[0-9]+-stage
- native-build
- revert-client-decl-master

jobs:
ubuntu_build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 2201.[0-9]+.x
- 2201.[0-9]+.[0-9]+-stage
- native-build
- revert-client-decl-master

jobs:
windows_build:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ velocity.log
/composer/modules/web/dist-electron
extractedDistribution
misc/testerina/modules/report-tools/node_modules/
generated

# gradle
.gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.ballerina.runtime.api.types.ObjectType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BFunctionPointer;
import io.ballerina.runtime.api.values.BFuture;
Expand Down Expand Up @@ -183,7 +184,7 @@ public BFuture invokeMethodAsync(BObject object, String methodName, String stran
Type returnType, Object... args) {
try {
validateArgs(object, methodName);
ObjectType objectType = object.getType();
ObjectType objectType = (ObjectType) TypeUtils.getReferredType(object.getType());
boolean isIsolated = objectType.isIsolated() && objectType.isIsolated(methodName);
FutureValue future = scheduler.createFuture(null, callback, properties, returnType, strandName, metadata);
AsyncUtils.getArgsWithDefaultValues(scheduler, object, methodName, new Callback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.JsonType;
import io.ballerina.runtime.api.types.MapType;
import io.ballerina.runtime.api.types.ReferenceType;
import io.ballerina.runtime.api.types.StructureType;
import io.ballerina.runtime.api.types.TableType;
import io.ballerina.runtime.api.types.Type;
Expand Down Expand Up @@ -284,16 +285,23 @@ public static Object convertToJson(Object value, List<TypeValuePair> unresolvedV
return null;
}
Type sourceType = TypeChecker.getType(value);
if (sourceType.getTag() <= TypeTags.BOOLEAN_TAG && TypeChecker.checkIsType(value, jsonType)) {
if (TypeUtils.getReferredType(sourceType).getTag() <= TypeTags.BOOLEAN_TAG && TypeChecker.checkIsType(value,
jsonType)) {
return value;
}
TypeValuePair typeValuePair = new TypeValuePair(value, jsonType);
if (unresolvedValues.contains(typeValuePair)) {
throw createCyclicValueReferenceError(value);
}
unresolvedValues.add(typeValuePair);
Object newValue;
Object newValue = getJsonObject(value, unresolvedValues, jsonType, sourceType);
unresolvedValues.remove(typeValuePair);
return newValue;
}

private static Object getJsonObject(Object value, List<TypeValuePair> unresolvedValues, Type jsonType,
Type sourceType) {
Object newValue;
switch (sourceType.getTag()) {
case TypeTags.XML_TAG:
case TypeTags.XML_ELEMENT_TAG:
Expand All @@ -309,7 +317,7 @@ public static Object convertToJson(Object value, List<TypeValuePair> unresolvedV
break;
case TypeTags.TABLE_TAG:
BTable bTable = (BTable) value;
Type constrainedType = ((TableType) bTable.getType()).getConstrainedType();
Type constrainedType = ((TableType) sourceType).getConstrainedType();
if (constrainedType.getTag() == TypeTags.MAP_TAG) {
newValue = convertMapConstrainedTableToJson((BTable) value, unresolvedValues);
} else {
Expand All @@ -324,11 +332,14 @@ public static Object convertToJson(Object value, List<TypeValuePair> unresolvedV
case TypeTags.MAP_TAG:
newValue = convertMapToJson((BMap<?, ?>) value, unresolvedValues);
break;
case TypeTags.TYPE_REFERENCED_TYPE_TAG:
newValue = getJsonObject(value, unresolvedValues, jsonType,
((ReferenceType) sourceType).getReferredType());
break;
case TypeTags.ERROR_TAG:
default:
throw createConversionError(value, jsonType);
}
unresolvedValues.remove(typeValuePair);
return newValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static String getStringValue(Object value, BLink parent) {
return "";
}

Type type = TypeChecker.getType(value);
Type type = TypeUtils.getReferredType(TypeChecker.getType(value));

if (type.getTag() == TypeTags.STRING_TAG) {
return ((BString) value).getValue();
Expand Down Expand Up @@ -203,7 +203,7 @@ public static String getStringValue(Object value, BLink parent) {

if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) {
BObject objectValue = (BObject) value;
ObjectType objectType = objectValue.getType();
ObjectType objectType = (ObjectType) TypeUtils.getReferredType(objectValue.getType());
for (MethodType func : objectType.getMethods()) {
if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 &&
func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) {
Expand All @@ -228,7 +228,7 @@ public static String getExpressionStringValue(Object value, BLink parent) {
return "()";
}

Type type = TypeChecker.getType(value);
Type type = TypeUtils.getReferredType(TypeChecker.getType(value));

if (type.getTag() == TypeTags.STRING_TAG) {
return "\"" + ((BString) value).getValue() + "\"";
Expand Down Expand Up @@ -274,7 +274,7 @@ public static String getExpressionStringValue(Object value, BLink parent) {

if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) {
AbstractObjectValue objectValue = (AbstractObjectValue) value;
ObjectType objectType = objectValue.getType();
ObjectType objectType = (ObjectType) TypeUtils.getReferredType(objectValue.getType());
for (MethodType func : objectType.getMethods()) {
if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 &&
func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) {
Expand Down Expand Up @@ -357,7 +357,7 @@ public static Object parseExpressionStringValue(String value, BLink parent) thro
public static String getJsonString(Object value) {
Object jsonValue = JsonUtils.convertToJson(value, new ArrayList<>());

Type type = TypeChecker.getType(jsonValue);
Type type = TypeUtils.getReferredType(TypeChecker.getType(jsonValue));
switch (type.getTag()) {
case TypeTags.NULL_TAG:
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_INT;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_JSON;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_MAP;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NEVER;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NULL;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STREAM;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STRING;
Expand All @@ -55,23 +56,26 @@ private TypeUtils() {
}

public static boolean isValueType(Type type) {
if (type == TYPE_INT || type == TYPE_BYTE ||
type == TYPE_FLOAT ||
type == TYPE_DECIMAL || type == TYPE_STRING ||
type == TYPE_BOOLEAN) {
return true;
}

if (type != null && type.getTag() == TypeTags.FINITE_TYPE_TAG) {
// All the types in value space should be value types.
for (Object value : ((BFiniteType) type).valueSpace) {
if (!isValueType(TypeChecker.getType(value))) {
return false;
Type referredType = TypeUtils.getReferredType(type);
switch (referredType.getTag()) {
case TypeTags.INT_TAG:
case TypeTags.BYTE_TAG:
case TypeTags.FLOAT_TAG:
case TypeTags.DECIMAL_TAG:
case TypeTags.BOOLEAN_TAG:
case TypeTags.STRING_TAG:
return true;
case TypeTags.FINITE_TYPE_TAG:
for (Object value : ((BFiniteType) referredType).valueSpace) {
if (!isValueType(TypeChecker.getType(value))) {
return false;
}
}
}
return true;
return true;
default:
return false;

}
return false;
}

public static Type getTypeFromName(String typeName) {
Expand Down Expand Up @@ -110,6 +114,8 @@ public static Type getTypeFromName(String typeName) {
return TYPE_ERROR;
case TypeConstants.ANYDATA_TNAME:
return TYPE_ANYDATA;
case TypeConstants.NEVER_TNAME:
return TYPE_NEVER;
default:
throw new IllegalStateException("Unknown type name");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package io.ballerina.runtime.api.values;

import io.ballerina.runtime.api.types.ObjectType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.internal.scheduling.Strand;
import io.ballerina.runtime.internal.values.RefValue;

Expand All @@ -36,7 +36,7 @@ public interface BObject extends RefValue {

BFuture start(Strand strand, String funcName, Object... args);

ObjectType getType();
Type getType();

Object get(BString fieldName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package io.ballerina.runtime.internal;

import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.internal.values.ArrayValue;
import io.ballerina.runtime.internal.values.DecimalValue;
Expand Down Expand Up @@ -279,7 +280,7 @@ public void serialize(Object json) throws IOException {
return;
}

switch (TypeChecker.getType(json).getTag()) {
switch (TypeUtils.getReferredType(TypeChecker.getType(json)).getTag()) {
case TypeTags.ARRAY_TAG:
if (json instanceof StreamingJsonValue) {
((StreamingJsonValue) json).serialize(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static boolean isJSONObject(Object json) {
return false;
}

Type type = ((RefValue) json).getType();
Type type = TypeUtils.getReferredType(((RefValue) json).getType());
int typeTag = type.getTag();
return typeTag == TypeTags.MAP_TAG || typeTag == TypeTags.RECORD_TYPE_TAG;
}
Expand Down Expand Up @@ -398,7 +398,7 @@ public static Object convertUnionTypeToJSON(Object source, JsonType targetType)
return null;
}

Type type = TypeChecker.getType(source);
Type type = TypeUtils.getReferredType(TypeChecker.getType(source));
switch (type.getTag()) {
case TypeTags.INT_TAG:
case TypeTags.FLOAT_TAG:
Expand Down Expand Up @@ -438,8 +438,8 @@ public static BError getErrorIfUnmergeable(Object j1, Object j2, List<ObjectPair
return null;
}

Type j1Type = TypeChecker.getType(j1);
Type j2Type = TypeChecker.getType(j2);
Type j1Type = TypeUtils.getReferredType(TypeChecker.getType(j1));
Type j2Type = TypeUtils.getReferredType(TypeChecker.getType(j2));

if (j1Type.getTag() != TypeTags.MAP_TAG || j2Type.getTag() != TypeTags.MAP_TAG) {
return ErrorCreator.createError(BallerinaErrorReasons.MERGE_JSON_ERROR,
Expand Down Expand Up @@ -491,8 +491,8 @@ public static Object mergeJson(Object j1, Object j2, boolean checkMergeability)
}

if (checkMergeability) {
Type j1Type = TypeChecker.getType(j1);
Type j2Type = TypeChecker.getType(j2);
Type j1Type = TypeUtils.getReferredType(TypeChecker.getType(j1));
Type j2Type = TypeUtils.getReferredType(TypeChecker.getType(j2));

if (j1Type.getTag() != TypeTags.MAP_TAG || j2Type.getTag() != TypeTags.MAP_TAG) {
return ErrorCreator.createError(BallerinaErrorReasons.MERGE_JSON_ERROR,
Expand Down Expand Up @@ -697,7 +697,7 @@ private static ArrayValue convertRefArrayToJSON(BArray refValueArray) {
json.append(null);
}

Type type = TypeChecker.getType(value);
Type type = TypeUtils.getReferredType(TypeChecker.getType(value));
switch (type.getTag()) {
case TypeTags.JSON_TAG:
json.append(value);
Expand Down Expand Up @@ -784,7 +784,7 @@ private static void populateJSON(BMap<BString, Object> json, BString key, Object
return;
}

Type type = TypeChecker.getType(value);
Type type = TypeUtils.getReferredType(TypeChecker.getType(value));
switch (type.getTag()) {
case TypeTags.INT_TAG:
case TypeTags.FLOAT_TAG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.JsonUtils;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.internal.types.BArrayType;
Expand Down Expand Up @@ -310,7 +311,7 @@ private State finalizeObject() {
}

Object parentNode = this.nodesStack.pop();
if (TypeChecker.getType(parentNode).getTag() == TypeTags.MAP_TAG) {
if (TypeUtils.getReferredType(TypeChecker.getType(parentNode)).getTag() == TypeTags.MAP_TAG) {
((MapValueImpl<BString, Object>) parentNode).put(StringUtils.fromString(fieldNames.pop()),
currentJsonNode);
currentJsonNode = parentNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BIterator;
import io.ballerina.runtime.api.values.BMap;
Expand Down Expand Up @@ -104,7 +105,7 @@ private static class DefaultJSONObjectGenerator implements JSONObjectGenerator {
public Object transform(BMap<?, ?> record) {
MapValue<BString, Object> objNode = new MapValueImpl<>(new BMapType(PredefinedTypes.TYPE_JSON));
for (Map.Entry entry : record.entrySet()) {
Type type = TypeChecker.getType(entry.getValue());
Type type = TypeUtils.getReferredType(TypeChecker.getType(entry.getValue()));
BString keyName = StringUtils.fromString(entry.getKey().toString());
constructJsonData(record, objNode, keyName, type);
}
Expand Down Expand Up @@ -151,7 +152,7 @@ private static void constructJsonData(BMap<?, ?> record, MapValue<BString, Objec
case TypeTags.RECORD_TYPE_TAG:
MapValue<BString, Object> jsonData = new MapValueImpl<>(new BMapType(PredefinedTypes.TYPE_JSON));
for (Map.Entry entry : record.getMapValue(key).entrySet()) {
Type internalType = TypeChecker.getType(entry.getValue());
Type internalType = TypeUtils.getReferredType(TypeChecker.getType(entry.getValue()));
BString internalKeyName = StringUtils.fromString(entry.getKey().toString());
constructJsonData(record.getMapValue(key), jsonData, internalKeyName, internalType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public static Long hash(Object obj, Node parent) {
} else {
return (long) obj.hashCode();
}
} else if (obj instanceof Long) {
return (long) obj;
} else {
return (long) obj.hashCode();
}
Expand Down
Loading

0 comments on commit b887fe6

Please sign in to comment.