-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3e746c
commit f519976
Showing
12 changed files
with
425 additions
and
28 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
semtypes/src/main/java/io/ballerina/types/CellAtomicType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.ballerina.types; | ||
|
||
/** | ||
* CellAtomicType node. | ||
* | ||
* @since 2201.10.0 | ||
*/ | ||
public final class CellAtomicType implements AtomicType { | ||
public final SemType ty; | ||
public final CellMutability mut; | ||
|
||
public static final CellAtomicType CELL_ATOMIC_VAL = from(PredefinedType.TOP, CellMutability.CELL_MUT_LIMITED); | ||
public static final CellAtomicType CELL_ATOMIC_NEVER = from(PredefinedType.NEVER, CellMutability.CELL_MUT_LIMITED); | ||
|
||
private CellAtomicType(SemType ty, CellMutability mut) { | ||
this.ty = ty; | ||
this.mut = mut; | ||
} | ||
|
||
public static CellAtomicType from(SemType ty, CellMutability mut) { | ||
return new CellAtomicType(ty, mut); | ||
} | ||
|
||
public enum CellMutability { | ||
CELL_MUT_NONE(0), | ||
CELL_MUT_LIMITED(1), | ||
CELL_MUT_UNLIMITED(2); | ||
|
||
private final int value; | ||
|
||
CellMutability(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
public static CellMutability fromValue(int value) { | ||
for (CellMutability mutability : values()) { | ||
if (mutability.value == value) { | ||
return mutability; | ||
} | ||
} | ||
throw new IllegalArgumentException("No enum constant with value " + value); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
semtypes/src/main/java/io/ballerina/types/CellSemType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.ballerina.types; | ||
|
||
/** | ||
* This is to represent a SemType belonging to cell basic type. | ||
* | ||
* @since 2201.10.0 | ||
*/ | ||
public class CellSemType extends ComplexSemType { | ||
|
||
public CellSemType(ProperSubtypeData[] subtypeDataList) { | ||
super(UniformTypeBitSet.from(0), PredefinedType.CELL, subtypeDataList); | ||
assert subtypeDataList.length == 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
semtypes/src/main/java/io/ballerina/types/subtypedata/CellSubtype.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.ballerina.types.subtypedata; | ||
|
||
import io.ballerina.types.CellAtomicType; | ||
import io.ballerina.types.CellSemType; | ||
import io.ballerina.types.ComplexSemType; | ||
import io.ballerina.types.Env; | ||
import io.ballerina.types.PredefinedType; | ||
import io.ballerina.types.SemType; | ||
import io.ballerina.types.TypeAtom; | ||
import io.ballerina.types.UniformTypeCode; | ||
|
||
import static io.ballerina.types.typeops.BddCommonOps.bddAtom; | ||
|
||
/** | ||
* CellSubType. | ||
* | ||
* @since 2201.10.0 | ||
*/ | ||
public class CellSubtype { | ||
|
||
public static CellSemType cellContaining(Env env, SemType ty, CellAtomicType.CellMutability mut) { | ||
CellAtomicType atomicCell = CellAtomicType.from(ty, mut); | ||
TypeAtom atom = env.cellAtom(atomicCell); | ||
BddNode bdd = bddAtom(atom); | ||
ComplexSemType complexSemType = (ComplexSemType) PredefinedType.uniformSubtype(UniformTypeCode.BT_CELL, bdd); | ||
return new CellSemType(complexSemType.subtypeDataList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.