Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a typedesc instruction once for record and tuple types #39101

Closed
Closed
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5b8006c
Set owner of generated type definitions
chiranSachintha Dec 17, 2022
34f322f
Add type details to `NewStructure` instruction
chiranSachintha Dec 17, 2022
013bafe
Add details of enclosure map symbols to record type
chiranSachintha Dec 17, 2022
cd8d4a8
Use record reference type when creating mapping value
chiranSachintha Dec 17, 2022
679b9fa
Create runtime type instance only for the user defined type definitions
chiranSachintha Dec 17, 2022
dd89697
Fix checkstyle issues
chiranSachintha Dec 17, 2022
62293d5
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha Jan 3, 2023
c3c7690
Generate separate method to create typedesc instances
chiranSachintha Jan 3, 2023
193eb74
BIR test update
chiranSachintha Jan 3, 2023
08af771
Add typedesc details to NewArray instruction
chiranSachintha Jan 3, 2023
e0ce035
Use PackageID of type
chiranSachintha Jan 4, 2023
ed9d56f
Generate a typedesc instruction once for record and tuple types
chiranSachintha Jan 9, 2023
955f2eb
Implemente visitors for type node
chiranSachintha Jan 9, 2023
89b4981
Add BTypeReferenceType constructor for creating a read-only type refe…
chiranSachintha Jan 9, 2023
e5875ba
Generate type definition for tuple intersection with readonly
chiranSachintha Jan 9, 2023
2097769
Update BIR test
chiranSachintha Jan 9, 2023
4f85ee5
Update error meesage
chiranSachintha Jan 9, 2023
722f9e1
Use referred type of type reference
chiranSachintha Jan 10, 2023
83e3fa8
Update test
chiranSachintha Jan 10, 2023
d7dc555
Update code-coverage test
chiranSachintha Jan 10, 2023
2ea5364
Fix review suggestion
chiranSachintha Jan 10, 2023
c444f9f
Fix review suggestions
chiranSachintha Jan 10, 2023
0c6d138
Fix review suggestions
chiranSachintha Jan 10, 2023
849fe3c
Update code-coverage test
chiranSachintha Jan 10, 2023
a2d16cb
Update variable visibility tests
chiranSachintha Jan 10, 2023
3de6606
Visit member types of tupletypenode
chiranSachintha Jan 10, 2023
d39e353
Refactor tuple member visit logic
chiranSachintha Jan 10, 2023
247b1eb
Refactor logic in `mapToVarDcls` function
chiranSachintha Jan 11, 2023
0fbf9e4
Merge branch 'annot-tuple-members' of https://github.com/ballerina-pl…
chiranSachintha Jan 11, 2023
bde8535
Import BIntersectionType
chiranSachintha Jan 10, 2023
95560b2
Visit member types of tupletypenode
chiranSachintha Jan 10, 2023
c0ef0a5
Refactor error detail type handling logic
chiranSachintha Jan 11, 2023
b21e351
Generate new Typedesc Id
chiranSachintha Jan 16, 2023
7cae7b4
Add constructor to BIRGlobalVariableDcl class
chiranSachintha Jan 16, 2023
8d23d1a
Remove desugaring of local anonymous record type node to BLangUserDef…
chiranSachintha Jan 16, 2023
bba94d6
Add function to check for user-defined type
chiranSachintha Jan 16, 2023
d307469
Add support to create type descriptor instances for global variables
chiranSachintha Jan 16, 2023
b9c7552
Modify typenode visitors to generate type descriptor instructions dur…
chiranSachintha Jan 16, 2023
32e4e51
BIR test update
chiranSachintha Jan 16, 2023
0b954ee
Add enclMapSymbols set in record type node visitor
chiranSachintha Jan 16, 2023
87d3701
Refactor logic
chiranSachintha Jan 16, 2023
860a236
Update variable visibility tests
chiranSachintha Jan 16, 2023
1cf271a
Fix review suggestions
chiranSachintha Jan 17, 2023
247c05f
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha Mar 21, 2023
1db824f
Resolve conflicts
chiranSachintha Mar 21, 2023
d05c0c3
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha Apr 10, 2023
c2dd87b
Include global variables into top level nodes
chiranSachintha May 16, 2023
b9ac3b6
Rearrange top level nodes for improve order
chiranSachintha May 16, 2023
416ef62
Add closures to top level nodes
chiranSachintha May 16, 2023
a287874
Add annotations to typedesc instructions
chiranSachintha May 16, 2023
2e97c69
Exclude generation of typedesc for records prior to the initializatio…
chiranSachintha May 16, 2023
a07302f
Generation of typedesc for records type definitions
chiranSachintha May 16, 2023
3d7c1fe
Generate init function based on the order of top level nodes
chiranSachintha May 16, 2023
b977935
Update dependency relations logic
chiranSachintha May 21, 2023
3de5bb8
Add generated global level stmts related to annotations after generat…
chiranSachintha May 21, 2023
deeeb29
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha May 21, 2023
3ef8c5d
Update type of `astStructLiteralExpr`
chiranSachintha May 22, 2023
99943b2
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha Aug 23, 2023
6f37020
Get annotation from typedesc
chiranSachintha Oct 2, 2023
5072e8c
Rearrange top level nodes for improve order
chiranSachintha Oct 2, 2023
182e46c
Implement Block Statement for store TypeNode Details
chiranSachintha Oct 2, 2023
64522f5
Add global variables to top level nodes
chiranSachintha Oct 2, 2023
05f67bc
Generate a typedesc instruction when visiting type node
chiranSachintha Oct 2, 2023
c99c7d4
Desugar local record type nodes
chiranSachintha Oct 2, 2023
2299e82
Merge branch 'master' of https://github.com/ballerina-platform/baller…
chiranSachintha Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,4 @@ public static Type getReferredType(Type type) {
}
return constraint;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ private static boolean checkIsNeverTypeOrStructureTypeWithARequiredNeverMember(T
private static boolean checkIsLikeType(List<String> errors, Object sourceValue, Type targetType,
List<TypeValuePair> unresolvedValues,
boolean allowNumericConversion, String varName) {
Type sourceType = getType(sourceValue);
Type sourceType = getReferredType(getType(sourceValue));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change?
IIRC, we have switch cases that handle the type-reference-type inside checkIsType and checkIsLikeOnValue implementations.

if (checkIsType(sourceType, targetType, new ArrayList<>())) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public BTypeReferenceType(String typeName, Module pkg, int typeFlags, boolean re
this.readOnly = readOnly;
}

public BTypeReferenceType(Type referredType, boolean readOnly) {
this(referredType.getName(), referredType.getPkg(), (int) referredType.getFlags(), readOnly);
setReferredType(referredType);
}

public void setReferredType(Type referredType) {
this.referredType = referredType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.ballerina.runtime.internal.TypeConverter;
import io.ballerina.runtime.internal.diagnostics.RuntimeDiagnosticLog;
import io.ballerina.runtime.internal.types.BArrayType;
import io.ballerina.runtime.internal.types.BIntersectionType;
import io.ballerina.runtime.internal.values.ArrayValue;
import io.ballerina.runtime.internal.values.ArrayValueImpl;
import io.ballerina.runtime.internal.values.ErrorValue;
Expand Down Expand Up @@ -247,4 +248,11 @@ private static boolean isInvalidBallerinaValue(Object value) {

private RuntimeUtils() {
}

public static Type getEffectiveType(Type type) {
if (type.getTag() == TypeTags.INTERSECTION_TAG) {
return ((BIntersectionType) type).getEffectiveType();
}
return type;
chiranSachintha marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import static io.ballerina.runtime.internal.JsonInternalUtils.mergeJson;
import static io.ballerina.runtime.internal.ValueUtils.createSingletonTypedesc;
import static io.ballerina.runtime.internal.ValueUtils.getTypedescValue;
import static io.ballerina.runtime.internal.util.RuntimeUtils.getEffectiveType;
import static io.ballerina.runtime.internal.util.exceptions.BallerinaErrorReasons.INVALID_UPDATE_ERROR_IDENTIFIER;
import static io.ballerina.runtime.internal.util.exceptions.BallerinaErrorReasons.MAP_KEY_NOT_FOUND_ERROR;
import static io.ballerina.runtime.internal.util.exceptions.BallerinaErrorReasons.getModulePrefixedReason;
Expand Down Expand Up @@ -307,8 +308,8 @@ public void populateInitialValue(K key, V value) {
putValue(key, value);
} else {
BString fieldName = (BString) key;
if (MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value, (BRecordType) referredType,
true)) {
if (MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value,
(BRecordType) getEffectiveType(referredType), true)) {
putValue(key, value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import io.ballerina.runtime.api.values.BMapInitialValueEntry;
import io.ballerina.runtime.api.values.BTypedesc;
import io.ballerina.runtime.internal.scheduling.Strand;
import io.ballerina.runtime.internal.types.BTypeReferenceType;
import io.ballerina.runtime.internal.types.BTypedescType;
import io.ballerina.runtime.internal.util.exceptions.BallerinaException;

import java.util.Map;

import static io.ballerina.runtime.api.utils.TypeUtils.getReferredType;
import static io.ballerina.runtime.internal.util.RuntimeUtils.getEffectiveType;

/**
* <p>
Expand Down Expand Up @@ -92,6 +94,11 @@ public Object instantiate(Strand s, BInitialValueEntry[] initialValues) {
} else if (referredType.getTag() == TypeTags.TUPLE_TAG) {
return new TupleValueImpl(this.describingType, (BListInitialValueEntry[]) initialValues);
}
Type effectiveType = getEffectiveType(referredType);
if (effectiveType.getTag() == TypeTags.TUPLE_TAG) {
return new TupleValueImpl(new BTypeReferenceType(effectiveType, true),
(BListInitialValueEntry[]) initialValues);
}
// This method will be overridden for user-defined types, therefor this line shouldn't be reached.
throw new BallerinaException("Given type can't be instantiated at runtime : " + this.describingType);
}
Expand Down
Loading