mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-07 07:28:44 +00:00
bool literals, fixes
This commit is contained in:
parent
b1aff1935d
commit
d31979166e
24 changed files with 179 additions and 46 deletions
|
|
@ -1,7 +1,10 @@
|
|||
#include <variant>
|
||||
|
||||
// for clangd
|
||||
#include "../include/global_info.hpp"
|
||||
#include "../include/types.hpp"
|
||||
#include "../include/error_handling.hpp"
|
||||
#include <variant>
|
||||
|
||||
|
||||
namespace info {
|
||||
|
||||
|
|
@ -15,7 +18,12 @@ void GlobalInfo::NamespaceVisitor::AddImport(definition::Import&& import_info,
|
|||
}
|
||||
|
||||
void GlobalInfo::NamespaceVisitor::AddEnterNamespace(const std::string& name,
|
||||
std::optional<utils::IsConstModifier> modifier) {
|
||||
std::optional<utils::IsConstModifier> modifier,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
if (type::ToInternalType(name).has_value()) {
|
||||
error_handling::HandleTypecheckError("Can't define basic type namespace", base_node);
|
||||
}
|
||||
|
||||
definition::Namespace* namespace_info = nullptr;
|
||||
if (modifier.has_value()) {
|
||||
if (modifier.value() == utils::IsConstModifier::Const) {
|
||||
|
|
@ -122,6 +130,10 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddFunctionDefinition(const std::str
|
|||
utils::IdType GlobalInfo::NamespaceVisitor::AddType(const std::string& type,
|
||||
definition::Type&& type_info,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
if (type::ToInternalType(type).has_value()) {
|
||||
error_handling::HandleTypecheckError("Can't redefine basic type", base_node);
|
||||
}
|
||||
|
||||
size_t id = 0;
|
||||
|
||||
auto type_id_iter = namespace_stack_.back()->types.find(type);
|
||||
|
|
@ -181,6 +193,10 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddType(const std::string& type,
|
|||
utils::IdType GlobalInfo::NamespaceVisitor::AddAbstractType(const std::string& abstract_type,
|
||||
definition::AbstractType&& abstract_type_info,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
if (type::ToInternalType(abstract_type).has_value()) {
|
||||
error_handling::HandleTypecheckError("Can't redefine basic type as abstract type", base_node);
|
||||
}
|
||||
|
||||
if (!FindAbstractType(abstract_type).has_value()) {
|
||||
utils::IdType id = global_info_.abstract_types_.size();
|
||||
global_info_.name_to_abstract_type_[abstract_type] = id;
|
||||
|
|
@ -197,6 +213,10 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddAbstractType(const std::string& a
|
|||
utils::IdType GlobalInfo::NamespaceVisitor::AddTypeclass(const std::string& typeclass,
|
||||
definition::Typeclass&& typeclass_info,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
if (type::ToInternalType(typeclass).has_value()) {
|
||||
error_handling::HandleTypecheckError("Can't redefine basic type as typeclass", base_node);
|
||||
}
|
||||
|
||||
if (!FindTypeclass(typeclass).has_value()) {
|
||||
size_t id = global_info_.typeclasses_.size();
|
||||
global_info_.name_to_typeclass_[typeclass] = id;
|
||||
|
|
@ -211,6 +231,10 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddTypeclass(const std::string& type
|
|||
utils::IdType GlobalInfo::NamespaceVisitor::AddConstructor(const std::string& constructor,
|
||||
definition::Constructor&& constructor_info,
|
||||
const interpreter::tokens::BaseNode& base_node) {
|
||||
if (type::ToInternalType(constructor).has_value()) {
|
||||
error_handling::HandleTypecheckError("Can't redefine basic type as constructor", base_node);
|
||||
}
|
||||
|
||||
auto constructor_id_iter = namespace_stack_.back()->constructors.find(constructor);
|
||||
|
||||
if (constructor_id_iter == namespace_stack_.back()->constructors.end()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue