-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29792 from grainier/fix-28262-v2
Improve runtime anonymous type resolution
- Loading branch information
Showing
11 changed files
with
749 additions
and
16 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
...rc/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/TypeHashComparator.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,42 @@ | ||
/* | ||
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. 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 org.wso2.ballerinalang.compiler.bir.codegen.internal; | ||
|
||
import org.wso2.ballerinalang.compiler.bir.model.BIRNode.BIRTypeDefinition; | ||
import org.wso2.ballerinalang.compiler.semantics.analyzer.TypeHashVisitor; | ||
|
||
import java.util.Comparator; | ||
|
||
/** | ||
* BType hash comparator to sort BIRTypeDefinitions according its type hash code. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public class TypeHashComparator implements Comparator<BIRTypeDefinition> { | ||
|
||
private final TypeHashVisitor typeHashVisitor = new TypeHashVisitor(); | ||
|
||
@Override | ||
public int compare(BIRTypeDefinition o1, BIRTypeDefinition o2) { | ||
Integer o1TypeHash = typeHashVisitor.visit(o1.type); | ||
typeHashVisitor.reset(); | ||
Integer o2TypeHash = typeHashVisitor.visit(o2.type); | ||
typeHashVisitor.reset(); | ||
return Integer.compare(o1TypeHash, o2TypeHash); | ||
} | ||
} |
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.