mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-26 16:58:45 +00:00
contexts merged with type_info_contexts
This commit is contained in:
parent
e1b9d42da1
commit
6850863f58
7 changed files with 143 additions and 315 deletions
|
|
@ -16,7 +16,7 @@ void TypeCheckVisitor::Visit(SourceFile* node) {
|
|||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ void TypeCheckVisitor::Visit(NamespaceSources* node) {
|
|||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -37,20 +37,20 @@ void TypeCheckVisitor::Visit(Namespace* node) { // TODO: two var namespces for c
|
|||
if (node->link_typeclass_id_.has_value()) { // TODO: think about typeclass
|
||||
|
||||
std::vector<utils::IdType> requirements {node->link_typeclass_id_.value()};
|
||||
utils::IdType abstract_type = context_manager_.AddType(
|
||||
utils::IdType abstract_type = context_manager_.AddValue(
|
||||
info::type::AbstractType(utils::AbstractTypeModifier::Abstract, node->type, requirements),
|
||||
IsConstModifierToValueType(node->modifier.value()));
|
||||
|
||||
context_manager_.EnterVariableContext("self", // TODO: different name ??
|
||||
abstract_type);
|
||||
context_manager_.DefineLocalAbstractType(node->type, abstract_type);
|
||||
context_manager_.DefineLocalType(node->type, abstract_type);
|
||||
} else if (node->link_type_id_.has_value()) {
|
||||
Visitor::Visit(*namespace_visitor_.GetGlobalInfo()->GetTypeInfo<info::definition::AnyType>(node->link_type_id_.value()).value()->value); // handle error?
|
||||
|
||||
context_manager_.EnterVariableContext(
|
||||
"self", // TODO: different name
|
||||
context_manager_.AddType(
|
||||
info::type::DefinedType(node->link_type_id_.value(), current_type_, context_manager_.GetTypeManager()),
|
||||
context_manager_.AddValue(
|
||||
info::type::DefinedType(node->link_type_id_.value(), current_type_, context_manager_.GetValueManager()),
|
||||
IsConstModifierToValueType(node->modifier.value())));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -65,7 +65,7 @@ void TypeCheckVisitor::Visit(Namespace* node) { // TODO: two var namespces for c
|
|||
|
||||
namespace_visitor_.ExitNamespace();
|
||||
context_manager_.ExitContext();
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -80,18 +80,18 @@ void TypeCheckVisitor::Visit(AliasDefinitionStatement* node) {
|
|||
error_handling::HandleInternalError("Unimplemented",
|
||||
"TypeCheckVisitor.AliasDefinitionStatement");
|
||||
// if (!is_in_statement_) { // do nothing if alias is not applied
|
||||
// current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
// current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// context_manager_.EnterContext();
|
||||
//
|
||||
// for (auto& parameter : node->parameters) {
|
||||
// current_type_ = context_manager_.AddType(info::type::AbstractType(utils::AbstractTypeModifier::Abstract,
|
||||
// current_type_ = context_manager_.AddValue(info::type::AbstractType(utils::AbstractTypeModifier::Abstract,
|
||||
// parameter,
|
||||
// /*TODO*/{}),
|
||||
// utils::ValueType::Tmp);
|
||||
// context_manager_.DefineLocalAbstractType(parameter, current_type_);
|
||||
// context_manager_.DefineLocalType(parameter, current_type_);
|
||||
// }
|
||||
//
|
||||
// Visit(node->value.get());
|
||||
|
|
@ -108,7 +108,7 @@ void TypeCheckVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
Visitor::Visit(node->value);
|
||||
// current_type from value automatically passed to name definitions
|
||||
if (node->assignment_modifier == utils::AssignmentModifier::Assign) {
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, utils::ValueType::Tmp);
|
||||
// TODO: make type tmp recursively ??
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ void TypeCheckVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
Visitor::Visit(node->name);
|
||||
is_const_definition_ = std::nullopt;
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -130,16 +130,16 @@ void TypeCheckVisitor::Visit(FunctionDeclaration* node) {
|
|||
for (auto& parameter : node->parameters) { // declaration correctness check // TODO: needed??
|
||||
std::vector<utils::IdType> requirements;
|
||||
// TODO:
|
||||
current_type_ = context_manager_.AddType(
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::AbstractType(utils::AbstractTypeModifier::Abstract,
|
||||
parameter->type,
|
||||
requirements), // TODO: typeclasses-requirements
|
||||
utils::ValueType::Tmp);
|
||||
context_manager_.DefineLocalAbstractType(parameter->type, current_type_);
|
||||
context_manager_.DefineLocalType(parameter->type, current_type_);
|
||||
}
|
||||
Visit(node->type.get());
|
||||
context_manager_.ExitContext();
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
if (!was_in_statement) {
|
||||
is_in_statement_ = false;
|
||||
|
|
@ -167,18 +167,18 @@ void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
requirements.push_back(typeclass->typeclass_id_);
|
||||
}
|
||||
// TODO: add recursive typeclasses from typeclass tree
|
||||
current_type_ = context_manager_.AddType(info::type::AbstractType(utils::AbstractTypeModifier::Abstract,
|
||||
current_type_ = context_manager_.AddValue(info::type::AbstractType(utils::AbstractTypeModifier::Abstract,
|
||||
parameter.type,
|
||||
requirements),
|
||||
utils::ValueType::Tmp);
|
||||
if (!context_manager_.DefineLocalAbstractType(parameter.type, current_type_)) {
|
||||
if (!context_manager_.DefineLocalType(parameter.type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Can't define function parameter type: abstract type redefinition", node->base);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < node->definition->arguments.size(); ++i) {
|
||||
Visitor::Visit(*declaration.argument_types[i]);
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, utils::ValueType::Const); // TODO: var function arguments??
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, utils::ValueType::Const); // TODO: var function arguments??
|
||||
if (!context_manager_.DefineVariable(node->definition->arguments[i].name, current_type_)) { // TODO: watch to reference
|
||||
error_handling::HandleTypecheckError("Can't define function argument variable: name redefinition", node->base);
|
||||
}
|
||||
|
|
@ -188,12 +188,12 @@ void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
utils::IdType return_type = current_type_;
|
||||
|
||||
Visitor::Visit(node->value);
|
||||
if (!context_manager_.EqualTypes(return_type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(return_type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Wrong function return type", node->base);
|
||||
}
|
||||
|
||||
context_manager_.ExitContext();
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -201,7 +201,7 @@ void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(TypeDefinitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -217,13 +217,13 @@ void TypeCheckVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
|||
}
|
||||
// TODO: add recursive typeclasses from typeclass tree
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::AbstractType(node->modifier, node->type->type, requirements),
|
||||
current_type_ = context_manager_.AddValue(info::type::AbstractType(node->modifier, node->type->type, requirements),
|
||||
utils::ValueType::Tmp);
|
||||
if (!context_manager_.DefineLocalAbstractType(node->type->type, current_type_)) {
|
||||
if (!context_manager_.DefineLocalType(node->type->type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Can't define basic/bastract type: abstract type redefinition", node->base);
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -231,7 +231,7 @@ void TypeCheckVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(TypeclassDefinitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -244,7 +244,7 @@ void TypeCheckVisitor::Visit(PartitionStatement* node) {
|
|||
Visitor::Visit(node->value);
|
||||
|
||||
context_manager_.ExitContext();
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -253,19 +253,19 @@ void TypeCheckVisitor::Visit(PartitionStatement* node) {
|
|||
// Definition parts
|
||||
|
||||
void TypeCheckVisitor::Visit(FunctionDefinition* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(TypeDefinition* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(AnyAnnotatedType* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ void TypeCheckVisitor::Visit(TypeConstructorPattern* node) { // TODO: match name
|
|||
|
||||
Visitor::Visit(*type_info.value);
|
||||
current_type_ = TypeInContext(current_type_, context);
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -349,7 +349,7 @@ void TypeCheckVisitor::Visit(MatchCase* node) {
|
|||
is_const_definition_ = utils::IsConstModifier::Const; // TODO: or var??
|
||||
Visitor::Visit(node->value);
|
||||
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, utils::ValueType::Tmp);
|
||||
|
||||
CheckPattern(node->value, node->base);
|
||||
|
||||
|
|
@ -358,8 +358,8 @@ void TypeCheckVisitor::Visit(MatchCase* node) {
|
|||
if (node->condition.has_value()) {
|
||||
Visitor::Visit(node->condition.value());
|
||||
}
|
||||
if (!context_manager_.EqualTypes(
|
||||
context_manager_.AddType(info::type::InternalType::Bool, utils::ValueType::Tmp),
|
||||
if (!context_manager_.EqualValues(
|
||||
context_manager_.AddValue(info::type::InternalType::Bool, utils::ValueType::Tmp),
|
||||
current_type_)) {
|
||||
error_handling::HandleTypecheckError("Match case condition is not bool expression", node->base);
|
||||
}
|
||||
|
|
@ -396,14 +396,14 @@ void TypeCheckVisitor::Visit(Match* node) { // TODO: move value to match
|
|||
type = current_type_;
|
||||
is_type_found = true;
|
||||
} else {
|
||||
if (!context_manager_.EqualTypes(type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Match statement cases have different types", node->base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_type_found) {
|
||||
type = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
type = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
current_type_ = type;
|
||||
|
|
@ -417,7 +417,7 @@ void TypeCheckVisitor::Visit(Condition* node) {
|
|||
|
||||
for (size_t i = 0; i < node->conditions.size(); ++i) {
|
||||
Visitor::Visit(node->conditions[i]);
|
||||
if (!context_manager_.EqualTypes(context_manager_.AddType(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
if (!context_manager_.EqualValues(context_manager_.AddValue(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
error_handling::HandleTypecheckError("Condition statement condition is not bool expression", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ void TypeCheckVisitor::Visit(Condition* node) {
|
|||
if (i == 0) {
|
||||
type = current_type_;
|
||||
} else {
|
||||
if (!context_manager_.EqualTypes(type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Condition statement cases have different types", node->base);
|
||||
}
|
||||
}
|
||||
|
|
@ -437,13 +437,13 @@ void TypeCheckVisitor::Visit(Condition* node) {
|
|||
context_manager_.EnterContext();
|
||||
Visitor::Visit(node->statements[node->conditions.size()]);
|
||||
context_manager_.ExitContext();
|
||||
if (!context_manager_.EqualTypes(type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Condition statement else have different type from other cases", node->base);
|
||||
}
|
||||
current_type_ = type;
|
||||
} else {
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::OptionalType(type, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::OptionalType(type, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp); // ??
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ void TypeCheckVisitor::Visit(Condition* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(DoWhileLoop* node) {
|
||||
Visitor::Visit(node->condition);
|
||||
if (!context_manager_.EqualTypes(context_manager_.AddType(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
if (!context_manager_.EqualValues(context_manager_.AddValue(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
error_handling::HandleTypecheckError("Do while loop statement condition is not bool expression", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -460,14 +460,14 @@ void TypeCheckVisitor::Visit(DoWhileLoop* node) {
|
|||
Visitor::Visit(node->statement);
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(WhileLoop* node) {
|
||||
Visitor::Visit(node->condition);
|
||||
if (!context_manager_.EqualTypes(context_manager_.AddType(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
if (!context_manager_.EqualValues(context_manager_.AddValue(info::type::InternalType::Bool, utils::ValueType::Tmp), current_type_)) {
|
||||
error_handling::HandleTypecheckError("While loop statement condition is not bool expression", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -475,8 +475,8 @@ void TypeCheckVisitor::Visit(WhileLoop* node) {
|
|||
Visitor::Visit(node->statement);
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -484,7 +484,7 @@ void TypeCheckVisitor::Visit(WhileLoop* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(ForLoop* node) {
|
||||
Visitor::Visit(node->interval);
|
||||
std::optional<info::type::ArrayType*> maybe_interval_type = context_manager_.GetType<info::type::ArrayType>(current_type_);
|
||||
std::optional<info::type::ArrayType*> maybe_interval_type = context_manager_.GetValue<info::type::ArrayType>(current_type_);
|
||||
|
||||
if (!maybe_interval_type.has_value()) {
|
||||
error_handling::HandleTypecheckError("For loop interval type mismatch", node->base);
|
||||
|
|
@ -492,7 +492,7 @@ void TypeCheckVisitor::Visit(ForLoop* node) {
|
|||
|
||||
context_manager_.EnterContext();
|
||||
|
||||
current_type_ = context_manager_.ToModifiedType(maybe_interval_type.value()->GetElementsType(),
|
||||
current_type_ = context_manager_.ToModifiedValue(maybe_interval_type.value()->GetElementsType(),
|
||||
utils::IsConstModifierToValueType(node->variable_modifier));
|
||||
|
||||
is_const_definition_ = node->variable_modifier;
|
||||
|
|
@ -503,8 +503,8 @@ void TypeCheckVisitor::Visit(ForLoop* node) {
|
|||
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
|
|
@ -513,8 +513,8 @@ void TypeCheckVisitor::Visit(LoopLoop* node) {
|
|||
Visitor::Visit(node->statement);
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(0, current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -537,7 +537,7 @@ void TypeCheckVisitor::Visit(Block* node) {
|
|||
type = returned_type_.value();
|
||||
is_type_found = true;
|
||||
} else {
|
||||
if (!context_manager_.EqualTypes(type, returned_type_.value())) {
|
||||
if (!context_manager_.EqualValues(type, returned_type_.value())) {
|
||||
error_handling::HandleTypecheckError("Different return types in block", node->base);
|
||||
}
|
||||
}
|
||||
|
|
@ -547,7 +547,7 @@ void TypeCheckVisitor::Visit(Block* node) {
|
|||
context_manager_.EnterContext();
|
||||
|
||||
if (!is_type_found) {
|
||||
type = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
type = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
current_type_ = type;
|
||||
|
|
@ -563,7 +563,7 @@ void TypeCheckVisitor::Visit(ScopedStatement* node) {
|
|||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(LoopControlExpression& node) { // enum
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
// Operators
|
||||
|
|
@ -581,7 +581,7 @@ void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) {
|
|||
is_method = false;
|
||||
} else {
|
||||
Visitor::Visit(node->left_expression);
|
||||
auto maybe_left_type = context_manager_.GetType<info::type::DefinedType>(current_type_);
|
||||
auto maybe_left_type = context_manager_.GetValue<info::type::DefinedType>(current_type_);
|
||||
|
||||
utils::ValueType left_value_type = context_manager_.GetValueType(current_type_);
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) {
|
|||
utils::IdType left_expression_type = current_type_; // TODO: type in context of deduced types
|
||||
|
||||
Visitor::Visit(node->left_expression);
|
||||
if (!context_manager_.AddTypeRequirement(current_type_, left_expression_type)) {
|
||||
if (!context_manager_.AddValueRequirement(current_type_, left_expression_type)) {
|
||||
error_handling::HandleTypecheckError("Operator left expression has wrong type", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -653,7 +653,7 @@ void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) {
|
|||
utils::IdType right_expression_type = current_type_; // TODO: type in context of deduced types
|
||||
|
||||
Visitor::Visit(node->right_expression);
|
||||
if (!context_manager_.AddTypeRequirement(current_type_, right_expression_type)) {
|
||||
if (!context_manager_.AddValueRequirement(current_type_, right_expression_type)) {
|
||||
error_handling::HandleTypecheckError("Operator right expression has wrong type", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ void TypeCheckVisitor::Visit(UnaryOperatorExpression* node) {
|
|||
utils::IdType expression_type = current_type_; // TODO: type in context of deduced types
|
||||
|
||||
Visitor::Visit(node->expression);
|
||||
if (!context_manager_.AddTypeRequirement(current_type_, expression_type)) {
|
||||
if (!context_manager_.AddValueRequirement(current_type_, expression_type)) {
|
||||
error_handling::HandleTypecheckError("Operator expression has wrong type", node->base);
|
||||
}
|
||||
|
||||
|
|
@ -709,20 +709,20 @@ void TypeCheckVisitor::Visit(UnaryOperatorExpression* node) {
|
|||
void TypeCheckVisitor::Visit(ReferenceExpression* node) {
|
||||
Visit(node->expression.get());
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ReferenceToType(node->references, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ReferenceToType(node->references, current_type_, context_manager_.GetValueManager()),
|
||||
context_manager_.GetValueType(current_type_)); // ??
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(AccessExpression* node) {
|
||||
Visitor::Visit(node->id);
|
||||
if (!context_manager_.EqualTypes(context_manager_.AddType(info::type::InternalType::Int, utils::ValueType::Tmp), current_type_)) {
|
||||
if (!context_manager_.EqualValues(context_manager_.AddValue(info::type::InternalType::Int, utils::ValueType::Tmp), current_type_)) {
|
||||
error_handling::HandleTypecheckError("Access index has wrong type (not Int)", node->base);
|
||||
}
|
||||
|
||||
Visitor::Visit(node->name.get());
|
||||
|
||||
std::optional<info::type::ArrayType*> maybe_type_value = context_manager_.GetType<info::type::ArrayType>(current_type_);
|
||||
std::optional<info::type::ArrayType*> maybe_type_value = context_manager_.GetValue<info::type::ArrayType>(current_type_);
|
||||
|
||||
if (!maybe_type_value.has_value()) {
|
||||
error_handling::HandleTypecheckError("Access type is not array", node->base);
|
||||
|
|
@ -755,7 +755,7 @@ void TypeCheckVisitor::Visit(FunctionCallExpression* node) {
|
|||
if (std::holds_alternative<std::unique_ptr<SubExpressionToken>>(node->prefix.value())) {
|
||||
Visitor::Visit(*std::get<std::unique_ptr<SubExpressionToken>>(node->prefix.value()));
|
||||
|
||||
std::optional<info::type::DefinedType*> maybe_expression_type = context_manager_.GetType<info::type::DefinedType>(current_type_);
|
||||
std::optional<info::type::DefinedType*> maybe_expression_type = context_manager_.GetValue<info::type::DefinedType>(current_type_);
|
||||
|
||||
if (!maybe_expression_type.has_value()) {
|
||||
error_handling::HandleTypecheckError("There is no non-builtin methods for not defined type", node->base);
|
||||
|
|
@ -851,7 +851,7 @@ void TypeCheckVisitor::Visit(FunctionCallExpression* node) {
|
|||
utils::IdType argument_type = TypeInContext(current_type_, context);
|
||||
|
||||
Visitor::Visit(node->arguments[i]);
|
||||
context_manager_.AddTypeRequirement(current_type_, argument_type);
|
||||
context_manager_.AddValueRequirement(current_type_, argument_type);
|
||||
}
|
||||
|
||||
node->function_id_ = maybe_function_id.value(); // IMPORTANT
|
||||
|
|
@ -868,8 +868,8 @@ void TypeCheckVisitor::Visit(TupleExpression* node) {
|
|||
fields.push_back({std::nullopt, current_type_});
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::TupleType(std::nullopt, fields, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::TupleType(std::nullopt, fields, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -884,14 +884,14 @@ void TypeCheckVisitor::Visit(VariantExpression* node) {
|
|||
|
||||
// TODO: deal with expression tuple types, etc, ??
|
||||
std::vector<std::pair<std::optional<std::string>, utils::IdType>> constructor_fields {{std::nullopt, current_type_}};
|
||||
constructors.push_back(info::type::TupleType(std::nullopt, constructor_fields, context_manager_.GetTypeManager()));
|
||||
constructors.push_back(info::type::TupleType(std::nullopt, constructor_fields, context_manager_.GetValueManager()));
|
||||
}
|
||||
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::VariantType(std::nullopt, constructors, -1),
|
||||
current_type_ = context_manager_.AddValue(info::type::VariantType(std::nullopt, constructors, -1),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::VariantType(std::nullopt, constructors, -1),
|
||||
current_type_ = context_manager_.AddValue(info::type::VariantType(std::nullopt, constructors, -1),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -960,7 +960,7 @@ void TypeCheckVisitor::Visit(TypeConstructor* node) {
|
|||
|
||||
Visitor::Visit(node->parameters[i].value);
|
||||
|
||||
if (!context_manager_.EqualTypes(parameter_type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(parameter_type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Type constructor: wrong parameter type", node->base);
|
||||
}
|
||||
}
|
||||
|
|
@ -974,7 +974,7 @@ void TypeCheckVisitor::Visit(TypeConstructor* node) {
|
|||
Visitor::Visit(*type_info.value);
|
||||
|
||||
std::optional<info::type::VariantType*> maybe_variant_type =
|
||||
context_manager_.GetType<info::type::VariantType>(current_type_);
|
||||
context_manager_.GetValue<info::type::VariantType>(current_type_);
|
||||
|
||||
if (maybe_type_info.has_value()) {
|
||||
maybe_variant_type.value()->SetCurrentConstructor(constructor_info.order);
|
||||
|
|
@ -1000,7 +1000,7 @@ void TypeCheckVisitor::Visit(ArrayExpression* node) {
|
|||
if (i == 0) {
|
||||
elements_type = current_type_;
|
||||
} else {
|
||||
if (!context_manager_.EqualTypes(elements_type, current_type_)) {
|
||||
if (!context_manager_.EqualValues(elements_type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Different element types in array expression", node->base);
|
||||
}
|
||||
}
|
||||
|
|
@ -1010,8 +1010,8 @@ void TypeCheckVisitor::Visit(ArrayExpression* node) {
|
|||
error_handling::HandleInternalError("Element size is 0", "TypeCheckVisitor.ArrayExpression");
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(node->elements.size(), elements_type, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(node->elements.size(), elements_type, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1042,7 +1042,7 @@ void TypeCheckVisitor::Visit(NameExpression* node) {
|
|||
utils::ValueType variable_value_type = context_manager_.GetValueType(current_type_);
|
||||
|
||||
for (size_t i = 1; i < node->names.size(); ++i) {
|
||||
std::optional<utils::IdType> maybe_type_value = context_manager_.GetAnyType(current_type_)->GetFieldType(node->names[i].name);
|
||||
std::optional<utils::IdType> maybe_type_value = context_manager_.GetAnyValue(current_type_)->GetFieldType(node->names[i].name);
|
||||
if (!maybe_type_value.has_value()) {
|
||||
error_handling::HandleTypecheckError("Variable field not found", node->names[i].base);
|
||||
}
|
||||
|
|
@ -1050,7 +1050,7 @@ void TypeCheckVisitor::Visit(NameExpression* node) {
|
|||
current_type_ = maybe_type_value.value();
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, variable_value_type);
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, variable_value_type);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -1058,12 +1058,12 @@ void TypeCheckVisitor::Visit(NameExpression* node) {
|
|||
void TypeCheckVisitor::Visit(TupleName* node) {
|
||||
utils::IdType type = current_type_;
|
||||
|
||||
std::optional<info::type::DefinedType*> maybe_defined_type_value = context_manager_.GetType<info::type::DefinedType>(type);
|
||||
std::optional<info::type::DefinedType*> maybe_defined_type_value = context_manager_.GetValue<info::type::DefinedType>(type);
|
||||
if (maybe_defined_type_value.has_value()) {
|
||||
type = maybe_defined_type_value.value()->GetType();
|
||||
}
|
||||
|
||||
std::optional<info::type::TupleType*> maybe_type_value = context_manager_.GetType<info::type::TupleType>(type);
|
||||
std::optional<info::type::TupleType*> maybe_type_value = context_manager_.GetValue<info::type::TupleType>(type);
|
||||
|
||||
if (maybe_type_value.has_value()) {
|
||||
error_handling::HandleTypecheckError("Mismatched types in tuple variable definition", node->base);
|
||||
|
|
@ -1087,7 +1087,7 @@ void TypeCheckVisitor::Visit(TupleName* node) {
|
|||
current_type_ = maybe_type_value.value()->GetFields()[i].second;
|
||||
|
||||
if (value_type == utils::ValueType::Tmp) { // TODO: ??
|
||||
current_type_ = context_manager_.ToModifiedType(current_type_, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.ToModifiedValue(current_type_, utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
Visitor::Visit(node->names[i]);
|
||||
|
|
@ -1101,12 +1101,12 @@ void TypeCheckVisitor::Visit(TupleName* node) {
|
|||
void TypeCheckVisitor::Visit(VariantName* node) {
|
||||
utils::IdType type = current_type_;
|
||||
|
||||
std::optional<info::type::DefinedType*> maybe_defined_type_value = context_manager_.GetType<info::type::DefinedType>(type);
|
||||
std::optional<info::type::DefinedType*> maybe_defined_type_value = context_manager_.GetValue<info::type::DefinedType>(type);
|
||||
if (maybe_defined_type_value.has_value()) {
|
||||
type = maybe_defined_type_value.value()->GetType();
|
||||
}
|
||||
|
||||
std::optional<info::type::VariantType*> maybe_type_value = context_manager_.GetType<info::type::VariantType>(type);
|
||||
std::optional<info::type::VariantType*> maybe_type_value = context_manager_.GetValue<info::type::VariantType>(type);
|
||||
|
||||
if (!maybe_type_value.has_value()) {
|
||||
error_handling::HandleTypecheckError("Mismatched types in variant variable definition", node->base);
|
||||
|
|
@ -1128,17 +1128,17 @@ void TypeCheckVisitor::Visit(VariantName* node) {
|
|||
|
||||
for (size_t i = 0; i < node->names.size(); ++i) {
|
||||
if (maybe_type_value.value()->GetConstructors()[i].GetFields().empty()) {
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::OptionalType(context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp), context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::OptionalType(context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp), context_manager_.GetValueManager()),
|
||||
utils::IsConstModifierToValueType(is_const_definition_.value())); // TODO ??
|
||||
} else {
|
||||
info::type::TupleType constructor_type_value = maybe_type_value.value()->GetConstructors()[i];
|
||||
|
||||
utils::IdType constructor_type =
|
||||
context_manager_.AddType(std::move(constructor_type_value),
|
||||
context_manager_.AddValue(std::move(constructor_type_value),
|
||||
utils::IsConstModifierToValueType(is_const_definition_.value())); // TODO ??
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::OptionalType(constructor_type, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::OptionalType(constructor_type, context_manager_.GetValueManager()),
|
||||
utils::IsConstModifierToValueType(is_const_definition_.value())); // TODO ??
|
||||
}
|
||||
|
||||
|
|
@ -1163,13 +1163,13 @@ void TypeCheckVisitor::Visit(AnnotatedName* node) {
|
|||
error_handling::HandleTypecheckError("TupleName: value type expression not match from variable definition modifier", node->base);
|
||||
}
|
||||
|
||||
type = context_manager_.ToModifiedType(type, utils::IsConstModifierToValueType(is_const_definition_.value()));
|
||||
type = context_manager_.ToModifiedValue(type, utils::IsConstModifierToValueType(is_const_definition_.value()));
|
||||
if (!context_manager_.DefineVariable(node->name, type)) {
|
||||
error_handling::HandleTypecheckError("Variable name already present in context", node->base);
|
||||
}
|
||||
if (node->type.has_value()) {
|
||||
Visitor::Visit(node->type.value());
|
||||
if (!context_manager_.EqualTypes(type, current_type_)) { // TODO ??
|
||||
if (!context_manager_.EqualValues(type, current_type_)) { // TODO ??
|
||||
error_handling::HandleTypecheckError("Wrong type annotation in annotated name", node->base);
|
||||
}
|
||||
}
|
||||
|
|
@ -1192,8 +1192,8 @@ void TypeCheckVisitor::Visit(FunctionType* node) {
|
|||
utils::IdType return_type = argument_types.back();
|
||||
argument_types.pop_back();
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::FunctionType(argument_types, return_type, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::FunctionType(argument_types, return_type, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1212,8 +1212,8 @@ void TypeCheckVisitor::Visit(TupleType* node) {
|
|||
}
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::TupleType(node->type, fields, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::TupleType(node->type, fields, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1226,10 +1226,10 @@ void TypeCheckVisitor::Visit(VariantType* node) {
|
|||
for (auto& constructor : node->constructors) {
|
||||
if (std::holds_alternative<Constructor>(constructor)) {
|
||||
std::vector<std::pair<std::optional<std::string>, utils::IdType>> constructor_fields;
|
||||
constructors.push_back(info::type::TupleType(std::get<Constructor>(constructor), constructor_fields, context_manager_.GetTypeManager()));
|
||||
constructors.push_back(info::type::TupleType(std::get<Constructor>(constructor), constructor_fields, context_manager_.GetValueManager()));
|
||||
} else if (std::holds_alternative<std::unique_ptr<TupleType>>(constructor)) {
|
||||
Visit(std::get<std::unique_ptr<TupleType>>(constructor).get());
|
||||
std::optional<info::type::TupleType*> maybe_constructor = context_manager_.GetType<info::type::TupleType>(current_type_);
|
||||
std::optional<info::type::TupleType*> maybe_constructor = context_manager_.GetValue<info::type::TupleType>(current_type_);
|
||||
if (!maybe_constructor.has_value()) {
|
||||
error_handling::HandleInternalError("Entity of VariantType is not TupleType", "TypeCheckVisitor.VariantType");
|
||||
}
|
||||
|
|
@ -1239,7 +1239,7 @@ void TypeCheckVisitor::Visit(VariantType* node) {
|
|||
}
|
||||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::VariantType(node->type, constructors, -1),
|
||||
current_type_ = context_manager_.AddValue(info::type::VariantType(node->type, constructors, -1),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1256,9 +1256,9 @@ void TypeCheckVisitor::Visit(TypeExpression* node) {
|
|||
if (maybe_internal_type.has_value()) {
|
||||
// checks made in link_symbols_visitor
|
||||
|
||||
current_type_ = context_manager_.AddType<info::type::InternalType>(maybe_internal_type.value(), utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue<info::type::InternalType>(maybe_internal_type.value(), utils::ValueType::Tmp);
|
||||
} else {
|
||||
std::optional<utils::IdType> maybe_local_abstract_type = context_manager_.GetLocalAbstractType(node->type.type);
|
||||
std::optional<utils::IdType> maybe_local_abstract_type = context_manager_.GetLocalType(node->type.type);
|
||||
if (node->path.empty() && maybe_local_abstract_type.has_value()) {
|
||||
current_type_ = maybe_local_abstract_type.value();
|
||||
} else if (node->type.type_id_.has_value()) { // TODO: chack that names are different (always true ??)
|
||||
|
|
@ -1278,8 +1278,8 @@ void TypeCheckVisitor::Visit(TypeExpression* node) {
|
|||
}
|
||||
|
||||
if (node->array_size.has_value()) {
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ArrayType(node->array_size.value(), current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ArrayType(node->array_size.value(), current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
|
|
@ -1289,8 +1289,8 @@ void TypeCheckVisitor::Visit(TypeExpression* node) {
|
|||
void TypeCheckVisitor::Visit(ExtendedScopedAnyType* node) {
|
||||
Visitor::Visit(node->type);
|
||||
|
||||
current_type_ = context_manager_.AddType(
|
||||
info::type::ReferenceToType(node->references, current_type_, context_manager_.GetTypeManager()),
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::ReferenceToType(node->references, current_type_, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1313,37 +1313,37 @@ void TypeCheckVisitor::Visit(ParametrizedType* node) {} // Handled in TypeExpres
|
|||
// Identifiers, constants, etc. -----------------
|
||||
|
||||
void TypeCheckVisitor::Visit(FloatNumberLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Float, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Float, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(NumberLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Int, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Int, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(StringLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::String, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::String, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(CharLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Char, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Char, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(UnitLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(BoolLiteral* node) {
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Bool, utils::ValueType::Tmp);
|
||||
current_type_ = context_manager_.AddValue(info::type::InternalType::Bool, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
@ -1390,9 +1390,9 @@ void TypeCheckVisitor::CollectTypeExpressionContext(const TypeExpression& type_e
|
|||
|
||||
utils::IdType TypeCheckVisitor::TypeInContext(utils::IdType type,
|
||||
const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
info::type::Type type_in_context = *context_manager_.GetAnyType(type);
|
||||
info::type::Type type_in_context = *context_manager_.GetAnyValue(type);
|
||||
type_in_context.InContext(context);
|
||||
return context_manager_.AddType(std::move(type_in_context), utils::ValueType::Tmp);
|
||||
return context_manager_.AddValue(std::move(type_in_context), utils::ValueType::Tmp);
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::CheckPattern(Pattern& node, const BaseNode& base_node) { // <-> ScopedPattern
|
||||
|
|
@ -1405,7 +1405,7 @@ void TypeCheckVisitor::CheckPattern(Pattern& node, const BaseNode& base_node) {
|
|||
break;
|
||||
case 1:
|
||||
Visitor::Visit(*std::get<std::unique_ptr<Literal>>(node));
|
||||
if (context_manager_.EqualTypes(current_type_, value_type)) { // TODO: better solution ??
|
||||
if (context_manager_.EqualValues(current_type_, value_type)) { // TODO: better solution ??
|
||||
error_handling::HandleTypecheckError("Literal and value have different types", base_node);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue