mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-06 06:58:46 +00:00
Arguments: change structure, pass in match (v0)
This commit is contained in:
parent
cf9311eb8b
commit
070b08dba4
2 changed files with 61 additions and 62 deletions
|
|
@ -142,44 +142,41 @@ public:
|
|||
|
||||
class Arguments {
|
||||
public:
|
||||
static Arguments expect_builtin(builtin::types::Type type,
|
||||
SourcesManager &sources_manager) {
|
||||
return Arguments(sources_manager.get_type_storage()->primitive_type(type),
|
||||
{});
|
||||
Arguments() = default;
|
||||
|
||||
Arguments expect_builtin(builtin::types::Type type,
|
||||
SourcesManager &sources_manager) const {
|
||||
Arguments copy(*this);
|
||||
copy.expected_type_ =
|
||||
sources_manager.get_type_storage()->primitive_type(type);
|
||||
}
|
||||
|
||||
static Arguments nothing() { return Arguments({}, {}); }
|
||||
|
||||
static Arguments expect(nodes::TypeProxy type) { return Arguments(type, {}); }
|
||||
|
||||
static Arguments pass(nodes::TypeProxy type) { return Arguments({}, type); }
|
||||
|
||||
static Arguments maybe_expect(nodes::MaybeTypeProxy type) {
|
||||
return Arguments(type, {});
|
||||
Arguments pass_builtin(builtin::types::Type type,
|
||||
SourcesManager &sources_manager) const {
|
||||
Arguments copy(*this);
|
||||
copy.passed_type_ =
|
||||
sources_manager.get_type_storage()->primitive_type(type);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static Arguments maybe_pass(nodes::MaybeTypeProxy type) {
|
||||
return Arguments({}, type);
|
||||
Arguments expect(nodes::MaybeTypeProxy type) const {
|
||||
Arguments copy(*this);
|
||||
copy.expected_type_ = type;
|
||||
return copy;
|
||||
}
|
||||
|
||||
static Arguments expect_and_pass(nodes::TypeProxy expected_type,
|
||||
nodes::TypeProxy passed_type) {
|
||||
return Arguments(expected_type, passed_type);
|
||||
}
|
||||
|
||||
static Arguments maybe_expect_and_pass(nodes::MaybeTypeProxy expected_type,
|
||||
nodes::MaybeTypeProxy passed_type) {
|
||||
return Arguments(expected_type, passed_type);
|
||||
Arguments pass(nodes::MaybeTypeProxy type) const {
|
||||
Arguments copy(*this);
|
||||
copy.passed_type_ = type;
|
||||
return copy;
|
||||
}
|
||||
|
||||
nodes::MaybeTypeProxy get_expected() const { return expected_type_; };
|
||||
|
||||
nodes::MaybeTypeProxy get_passed() const { return passed_type_; };
|
||||
|
||||
private:
|
||||
explicit Arguments(nodes::MaybeTypeProxy expected_type = {},
|
||||
nodes::MaybeTypeProxy passed_type = {})
|
||||
: expected_type_(expected_type), passed_type_(passed_type) {}
|
||||
// TODO: add check, that there is no passed type for some nodes ??
|
||||
// TODO: arguments builder ??
|
||||
|
||||
private:
|
||||
nodes::MaybeTypeProxy expected_type_ = {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue