-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
44 changed files
with
705 additions
and
412 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...erina-runtime/src/main/java/io/ballerina/runtime/api/types/ImmutableSemTypeFlyweight.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,41 @@ | ||
/* | ||
* Copyright (c) 2025, WSO2 LLC. (http://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.runtime.api.types; | ||
|
||
import io.ballerina.runtime.api.types.semtype.SemType; | ||
import io.ballerina.runtime.api.types.semtype.TypeCheckCache; | ||
|
||
public record ImmutableSemTypeFlyweight(SemType semType, int typeId, TypeCheckCache typeCheckCache) | ||
implements SemTypeFlyweight { | ||
|
||
@Override | ||
public void setSemType(SemType semType) { | ||
throw new UnsupportedOperationException("Cannot mutate immutable semType flyweight"); | ||
} | ||
|
||
@Override | ||
public void setTypeId(int typeId) { | ||
throw new UnsupportedOperationException("Cannot mutate immutable semType flyweight"); | ||
} | ||
|
||
@Override | ||
public void setTypeCheckCache(TypeCheckCache typeCheckCache) { | ||
throw new UnsupportedOperationException("Cannot mutate immutable semType flyweight"); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...llerina-runtime/src/main/java/io/ballerina/runtime/api/types/MutableSemTypeFlyweight.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,66 @@ | ||
/* | ||
* Copyright (c) 2025, WSO2 LLC. (http://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.runtime.api.types; | ||
|
||
import io.ballerina.runtime.api.types.semtype.SemType; | ||
import io.ballerina.runtime.api.types.semtype.TypeCheckCache; | ||
import io.ballerina.runtime.internal.types.TypeCheckableType; | ||
|
||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
public class MutableSemTypeFlyweight implements SemTypeFlyweight { | ||
|
||
AtomicReference<SemType> ref = new AtomicReference<>(); | ||
int typeId = -1; | ||
TypeCheckCache typeCheckCache = null; | ||
|
||
@Override | ||
public SemType semType() { | ||
return ref.get(); | ||
} | ||
|
||
@Override | ||
public int typeId() { | ||
return typeId; | ||
} | ||
|
||
@Override | ||
public TypeCheckCache typeCheckCache() { | ||
return typeCheckCache; | ||
} | ||
|
||
@Override | ||
public void setSemType(SemType semType) { | ||
if (semType instanceof TypeCheckableType wrapper) { | ||
ref.set(wrapper.semTypeFlyweight.semType()); | ||
} else { | ||
ref.set(semType); | ||
} | ||
} | ||
|
||
@Override | ||
public void setTypeId(int typeId) { | ||
this.typeId = typeId; | ||
} | ||
|
||
@Override | ||
public void setTypeCheckCache(TypeCheckCache typeCheckCache) { | ||
this.typeCheckCache = typeCheckCache; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/SemTypeFlyweight.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,37 @@ | ||
/* | ||
* Copyright (c) 2025, WSO2 LLC. (http://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.runtime.api.types; | ||
|
||
import io.ballerina.runtime.api.types.semtype.SemType; | ||
import io.ballerina.runtime.api.types.semtype.TypeCheckCache; | ||
|
||
public interface SemTypeFlyweight { | ||
|
||
SemType semType(); | ||
|
||
int typeId(); | ||
|
||
TypeCheckCache typeCheckCache(); | ||
|
||
void setSemType(SemType semType); | ||
|
||
void setTypeId(int typeId); | ||
|
||
void setTypeCheckCache(TypeCheckCache typeCheckCache); | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...ina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/BasicTypeBitSetImpl.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,47 @@ | ||
/* | ||
* Copyright (c) 2025, WSO2 LLC. (http://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.runtime.api.types.semtype; | ||
|
||
/** | ||
* Abstraction on top of bit set used to represent union of "all" of a given basic type. | ||
* | ||
* @since 2201.12.0 | ||
*/ | ||
public sealed class BasicTypeBitSetImpl implements BasicTypeBitSet permits SemTypeImpl { | ||
|
||
private final int all; | ||
|
||
public BasicTypeBitSetImpl(int all) { | ||
this.all = all; | ||
} | ||
|
||
@Override | ||
public int all() { | ||
return all; | ||
} | ||
|
||
@Override | ||
public BasicTypeBitSet union(BasicTypeBitSet basicTypeBitSet) { | ||
return new BasicTypeBitSetImpl(all() | basicTypeBitSet.all()); | ||
} | ||
|
||
@Override | ||
public BasicTypeBitSet intersection(BasicTypeBitSet basicTypeBitSet) { | ||
return new BasicTypeBitSetImpl(all() & basicTypeBitSet.all()); | ||
} | ||
} |
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
Oops, something went wrong.