mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-24 15:58:45 +00:00
typecheck for some expressions
This commit is contained in:
parent
070b08dba4
commit
61fa3a19a0
3 changed files with 78 additions and 52 deletions
|
|
@ -446,7 +446,7 @@ public:
|
|||
return TypeCheckResult();
|
||||
}
|
||||
|
||||
explicit TypeCheckResult(std::optional<TypeProxy> type) : type_(type) {}
|
||||
explicit TypeCheckResult(nodes::TypeProxy type) : type_(type) {}
|
||||
|
||||
//
|
||||
|
||||
|
|
@ -478,7 +478,7 @@ private:
|
|||
TypeCheckResult() = default;
|
||||
|
||||
private:
|
||||
std::optional<TypeProxy> type_;
|
||||
nodes::MaybeTypeProxy type_;
|
||||
};
|
||||
|
||||
} // namespace nodes
|
||||
|
|
|
|||
|
|
@ -186,8 +186,8 @@ private:
|
|||
class ContextHolder {
|
||||
public:
|
||||
ContextHolder(State &state, const nodes::Node &node,
|
||||
error_handling::ErrorLog &error_log)
|
||||
: state(state) {
|
||||
error_handling::ErrorLog &error_log, nodes::MaybeTypeProxy* context_exit_type)
|
||||
: state_(state), context_exit_type_(context_exit_type) {
|
||||
state.enter_context(node, error_log);
|
||||
}
|
||||
|
||||
|
|
@ -197,10 +197,17 @@ public:
|
|||
ContextHolder &operator=(const ContextHolder &) = delete;
|
||||
ContextHolder &operator=(ContextHolder &&) = delete;
|
||||
|
||||
~ContextHolder() { state.exit_context(); }
|
||||
~ContextHolder() {
|
||||
if (context_exit_type_) {
|
||||
*context_exit_type_ = state_.exit_context();
|
||||
} else {
|
||||
state_.exit_context();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
State &state;
|
||||
State &state_;
|
||||
nodes::MaybeTypeProxy* context_exit_type_;
|
||||
};
|
||||
|
||||
nodes::TypeCheckResult type_same_to_expected(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue