mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-24 07:48:46 +00:00
utils to typecheck name expression, ccls config
This commit is contained in:
parent
f688dd99a2
commit
c969dac7cc
3 changed files with 100 additions and 14 deletions
|
|
@ -17,8 +17,8 @@ class State {
|
|||
|
||||
public:
|
||||
struct VariableInfo {
|
||||
nodes::TypeProxy type;
|
||||
nodes::NameDefinition::Modifier modifier;
|
||||
nodes::TypeProxy type;
|
||||
nodes::NameDefinition::Modifier modifier;
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -29,11 +29,12 @@ public:
|
|||
"Insert variable into contexts_ with zero elements in State");
|
||||
}
|
||||
|
||||
return contexts_.back().variables.insert({name, VariableInfo{type, modifier}}).second;
|
||||
return contexts_.back()
|
||||
.variables.insert({name, VariableInfo{type, modifier}})
|
||||
.second;
|
||||
}
|
||||
|
||||
std::optional<VariableInfo>
|
||||
find_variable(const std::string &name) {
|
||||
std::optional<VariableInfo> find_variable(const std::string &name) {
|
||||
for (ssize_t i = contexts_.size(); i >= 0; --i) {
|
||||
auto iter = contexts_[i].variables.find(name);
|
||||
if (iter != contexts_[i].variables.end()) {
|
||||
|
|
@ -134,8 +135,7 @@ public:
|
|||
public:
|
||||
nodes::MaybeTypeProxy brought_type;
|
||||
nodes::MaybeTypeProxy returned_type;
|
||||
std::unordered_map<std::string, VariableInfo>
|
||||
variables;
|
||||
std::unordered_map<std::string, VariableInfo> variables;
|
||||
|
||||
private:
|
||||
const nodes::Node &node;
|
||||
|
|
@ -266,6 +266,15 @@ find_name_definition_handle_errors(const std::string &name,
|
|||
const nodes::Node &node,
|
||||
SourcesManager &sources_manager);
|
||||
|
||||
std::optional<nodes::TypeProxy>
|
||||
unfold_user_defined_type_handle_errors(nodes::TypeProxy type,
|
||||
const nodes::Node &node,
|
||||
SourcesManager &sources_manager);
|
||||
|
||||
std::optional<nodes::TypeProxy> get_field_type_by_name_handle_errors(
|
||||
nodes::TypeProxy type, const std::string &field, const nodes::Node &node,
|
||||
SourcesManager &sources_manager);
|
||||
|
||||
void type_check_error(const std::string &message, const nodes::Node &node,
|
||||
SourcesManager &sources_manager);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue