-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fixConstRefModsToo
Signed-off-by: Lydia Duncan <[email protected]>
- Loading branch information
Showing
67 changed files
with
2,346 additions
and
330 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2024 Hewlett Packard Enterprise Development LP | ||
* Other additional copyright holders may be indicated within. | ||
* | ||
* The entirety of this work is licensed 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. | ||
*/ | ||
|
||
#ifndef CHPL_TYPES_FN_ITERATOR_TYPE_H | ||
#define CHPL_TYPES_FN_ITERATOR_TYPE_H | ||
|
||
#include "chpl/types/Type.h" | ||
#include "chpl/types/QualifiedType.h" | ||
#include "chpl/resolution/resolution-types.h" | ||
#include "chpl/types/IteratorType.h" | ||
|
||
namespace chpl { | ||
namespace types { | ||
|
||
class FnIteratorType final : public IteratorType { | ||
private: | ||
/* | ||
The iterator procedure that was invoked to construct an iterator of this | ||
type. E.g,, the type of `foo()` will contain `iter foo()` as the iterator | ||
function. | ||
*/ | ||
const resolution::TypedFnSignature* iteratorFn_; | ||
|
||
FnIteratorType(QualifiedType yieldType, const resolution::TypedFnSignature* iteratorFn) | ||
: IteratorType(typetags::FnIteratorType, std::move(yieldType)), iteratorFn_(iteratorFn) {} | ||
|
||
bool contentsMatchInner(const Type* other) const override { | ||
auto rhs = (FnIteratorType*) other; | ||
return this->yieldType_ == rhs->yieldType_ && | ||
this->iteratorFn_ == rhs->iteratorFn_; | ||
} | ||
|
||
void markUniqueStringsInner(Context* context) const override; | ||
|
||
static const owned <FnIteratorType>& | ||
getFnIteratorType(Context* context, | ||
QualifiedType yieldType, | ||
const resolution::TypedFnSignature* iteratorFn); | ||
|
||
public: | ||
static const FnIteratorType* get(Context* context, | ||
QualifiedType yieldType, | ||
const resolution::TypedFnSignature* iteratorFn); | ||
|
||
const resolution::TypedFnSignature* iteratorFn() const { | ||
return iteratorFn_; | ||
} | ||
}; | ||
|
||
} // end namespace types | ||
} // end namespace chpl | ||
|
||
#endif |
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,57 @@ | ||
/* | ||
* Copyright 2024 Hewlett Packard Enterprise Development LP | ||
* Other additional copyright holders may be indicated within. | ||
* | ||
* The entirety of this work is licensed 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. | ||
*/ | ||
|
||
#ifndef CHPL_TYPES_ITERATOR_TYPE_H | ||
#define CHPL_TYPES_ITERATOR_TYPE_H | ||
|
||
#include "chpl/types/Type.h" | ||
#include "chpl/types/QualifiedType.h" | ||
|
||
namespace chpl { | ||
namespace types { | ||
|
||
class IteratorType : public Type { | ||
protected: | ||
/* | ||
The type produced by this iterator. E.g., in a loop such | ||
as the right hand side in the below assignment: | ||
var A = foreach i in 1..10 do (i,i); | ||
the yield type is (int, int). | ||
*/ | ||
QualifiedType yieldType_; | ||
|
||
IteratorType(typetags::TypeTag tag, QualifiedType yieldType) | ||
: Type(tag), yieldType_(std::move(yieldType)) {} | ||
|
||
Genericity genericity() const override { | ||
return CONCRETE; | ||
} | ||
|
||
public: | ||
const QualifiedType& yieldType() const { | ||
return yieldType_; | ||
} | ||
}; | ||
|
||
} // end namespace types | ||
} // end namespace chpl | ||
|
||
#endif |
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,124 @@ | ||
/* | ||
* Copyright 2024 Hewlett Packard Enterprise Development LP | ||
* Other additional copyright holders may be indicated within. | ||
* | ||
* The entirety of this work is licensed 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. | ||
*/ | ||
|
||
#ifndef CHPL_TYPES_LOOP_EXPR_ITERATOR_TYPE_H | ||
#define CHPL_TYPES_LOOP_EXPR_ITERATOR_TYPE_H | ||
|
||
#include "chpl/types/Type.h" | ||
#include "chpl/types/QualifiedType.h" | ||
#include "chpl/types/IteratorType.h" | ||
|
||
namespace chpl { | ||
namespace types { | ||
|
||
class LoopExprIteratorType final : public IteratorType { | ||
private: | ||
/* | ||
Whether the loop expression is zippered. In production, zippered | ||
loop expressions contain all of their iterands and separately invoke | ||
leader/follower iterators on each one | ||
*/ | ||
bool isZippered_; | ||
/* | ||
Whether this loop can be iterated over in parallel. Some loops | ||
('for' and 'foreach') can't, even when their iterands support parallel | ||
iteration. | ||
*/ | ||
bool supportsParallel_; | ||
/* | ||
The type of the thing being iterated over, used for resolving the | ||
needed leader/follower iterators. If the loop is zippered, iterand | ||
should be a tuple type. | ||
*/ | ||
QualifiedType iterand_; | ||
/* | ||
The ID of the AST node that caused this loop type to be constructed. | ||
This is part of the type so that loop expressions created at different | ||
places are considered to have a different type. | ||
Note: this may need to change if we compiler-generated loop expressions, | ||
since the IDs of those would be nebulous. | ||
*/ | ||
ID sourceLocation_; | ||
|
||
LoopExprIteratorType(QualifiedType yieldType, | ||
bool isZippered, | ||
bool supportsParallel, | ||
QualifiedType iterand, | ||
ID sourceLocation) | ||
: IteratorType(typetags::LoopExprIteratorType, std::move(yieldType)), | ||
isZippered_(isZippered), supportsParallel_(supportsParallel), | ||
iterand_(std::move(iterand)), sourceLocation_(std::move(sourceLocation)) { | ||
if (isZippered_) { | ||
CHPL_ASSERT(iterand_.type() && iterand_.type()->isTupleType()); | ||
} | ||
} | ||
|
||
bool contentsMatchInner(const Type* other) const override { | ||
auto rhs = (LoopExprIteratorType*) other; | ||
return yieldType_ == rhs->yieldType_ && | ||
isZippered_ == rhs->isZippered_ && | ||
supportsParallel_ == rhs->supportsParallel_ && | ||
iterand_ == rhs->iterand_ && | ||
sourceLocation_ == rhs->sourceLocation_; | ||
} | ||
|
||
void markUniqueStringsInner(Context* context) const override { | ||
yieldType_.mark(context); | ||
iterand_.mark(context); | ||
sourceLocation_.mark(context); | ||
} | ||
|
||
static const owned<LoopExprIteratorType>& | ||
getLoopExprIteratorType(Context* context, | ||
QualifiedType yieldType, | ||
bool isZippered, | ||
bool supportsParallel, | ||
QualifiedType iterand, | ||
ID sourceLocation); | ||
|
||
public: | ||
static const LoopExprIteratorType* get(Context* context, | ||
QualifiedType yieldType, | ||
bool isZippered, | ||
bool supportsParallel, | ||
QualifiedType iterand, | ||
ID sourceLocation); | ||
|
||
bool isZippered() const { | ||
return isZippered_; | ||
} | ||
|
||
bool supportsParallel() const { | ||
return supportsParallel_; | ||
} | ||
|
||
const ID& sourceLocation() const { | ||
return sourceLocation_; | ||
} | ||
|
||
const QualifiedType& iterand() const { | ||
return iterand_; | ||
} | ||
}; | ||
|
||
} // end namespace types | ||
} // end namespace chpl | ||
|
||
#endif |
Oops, something went wrong.