mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-27 17:28:47 +00:00
refactor type check Arguments, add posibility to pass type into arguments
This commit is contained in:
parent
0da0c9f6f5
commit
cf9311eb8b
2 changed files with 86 additions and 46 deletions
|
|
@ -144,11 +144,46 @@ class Arguments {
|
|||
public:
|
||||
static Arguments expect_builtin(builtin::types::Type type,
|
||||
SourcesManager &sources_manager) {
|
||||
return {{sources_manager.get_type_storage()->primitive_type(type)}};
|
||||
return Arguments(sources_manager.get_type_storage()->primitive_type(type),
|
||||
{});
|
||||
}
|
||||
|
||||
public:
|
||||
nodes::MaybeTypeProxy expected_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, {});
|
||||
}
|
||||
|
||||
static Arguments maybe_pass(nodes::MaybeTypeProxy type) {
|
||||
return Arguments({}, type);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {}
|
||||
|
||||
private:
|
||||
nodes::MaybeTypeProxy expected_type_ = {};
|
||||
nodes::MaybeTypeProxy passed_type_ = {};
|
||||
};
|
||||
|
||||
class ContextHolder {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue