From 56cc2637ac1deb9bebbf090e1a596fcb47f3aa34 Mon Sep 17 00:00:00 2001 From: Kevin Traini Date: Sat, 26 Aug 2023 16:50:49 +0200 Subject: [PATCH] Add resolution of BinaryCalcul --- src/lib/ast/AST.h | 89 +-- src/lib/ast/AbstractExpression.cpp | 4 +- src/lib/ast/ArrayOperator.cpp | 8 +- src/lib/ast/AssignationOperator.cpp | 8 +- src/lib/ast/BinaryCalcul.cpp | 31 + src/lib/ast/BooleanLiteral.cpp | 3 +- src/lib/ast/CharacterLiteral.cpp | 3 +- src/lib/ast/ClassicOperator.cpp | 8 +- src/lib/ast/FloatLiteral.cpp | 3 +- src/lib/ast/FunctionOperator.cpp | 10 +- src/lib/ast/Identifier.cpp | 5 +- src/lib/ast/IntegerLiteral.cpp | 3 +- src/lib/ast/PostUnaryCalcul.cpp | 5 +- src/lib/ast/PreUnaryCalcul.cpp | 5 +- src/lib/ast/StringLiteral.cpp | 3 +- src/lib/ast/VariableDeclaration.cpp | 5 +- src/lib/environment/Environment.cpp | 653 ++++++++++++++++++--- tests/unit/Fixtures/ast/binary_calcul1.fil | 5 + tests/unit/Fixtures/ast/binary_calcul2.fil | 3 + tests/unit/ast/AbstractExpressionTest.cpp | 11 +- tests/unit/ast/BinaryCalculTest.cpp | 22 +- tests/unit/ast/IdentifierTest.cpp | 4 +- 22 files changed, 715 insertions(+), 176 deletions(-) create mode 100644 tests/unit/Fixtures/ast/binary_calcul1.fil create mode 100644 tests/unit/Fixtures/ast/binary_calcul2.fil diff --git a/src/lib/ast/AST.h b/src/lib/ast/AST.h index 2e466209..8232d93e 100644 --- a/src/lib/ast/AST.h +++ b/src/lib/ast/AST.h @@ -81,8 +81,9 @@ namespace filc::ast { [[nodiscard]] auto getExpressionType() const -> AbstractType *; - virtual auto - resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector) -> void; + virtual auto resolveType(filc::environment::Environment *environment, + filc::message::MessageCollector *collector, + AbstractType *preferred_type = nullptr) -> void; private: bool _exported{false}; @@ -104,7 +105,8 @@ namespace filc::ast { [[nodiscard]] auto getName() const -> const std::string &; auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; private: std::string _name; @@ -128,32 +130,32 @@ namespace filc::ast { public: explicit BooleanLiteral(bool value); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class IntegerLiteral : public AbstractLiteral { public: explicit IntegerLiteral(int value); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class FloatLiteral : public AbstractLiteral { public: explicit FloatLiteral(double value); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class CharacterLiteral : public AbstractLiteral { public: explicit CharacterLiteral(char value); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; static auto stringToChar(const std::string &snippet, antlr4::Token *token = nullptr) -> char; }; @@ -162,8 +164,8 @@ namespace filc::ast { public: explicit StringLiteral(const std::string &value); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class VariableDeclaration : public AbstractExpression { @@ -182,8 +184,8 @@ namespace filc::ast { auto setAssignation(AbstractExpression *assignation) -> void; - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; private: bool _constant; @@ -244,7 +246,7 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - auto equals(const AbstractType &other) const -> bool override; + [[nodiscard]] auto equals(const AbstractType &other) const -> bool override; private: AbstractType *_inner_type; @@ -261,7 +263,7 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - auto equals(const AbstractType &other) const -> bool override; + [[nodiscard]] auto equals(const AbstractType &other) const -> bool override; private: AbstractType *_inner_type; @@ -284,7 +286,7 @@ namespace filc::ast { [[nodiscard]] auto getCalledOn() const -> AbstractType *; - auto equals(const AbstractType &other) const -> bool override; + [[nodiscard]] auto equals(const AbstractType &other) const -> bool override; private: std::vector _argument_types; @@ -311,16 +313,16 @@ namespace filc::ast { public: PreUnaryCalcul(Identifier *variable, Operator *p_operator); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class PostUnaryCalcul : public UnaryCalcul { public: PostUnaryCalcul(Identifier *variable, Operator *p_operator); - auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; }; class BinaryCalcul : public AbstractExpression { @@ -335,6 +337,9 @@ namespace filc::ast { [[nodiscard]] auto getOperator() const -> Operator *; + auto resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void override; + private: AbstractExpression *_left_expression; AbstractExpression *_right_expression; @@ -355,13 +360,13 @@ namespace filc::ast { [[nodiscard]] virtual auto dump() const -> std::string = 0; - [[nodiscard]] virtual auto dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] virtual auto dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * = 0; - [[nodiscard]] virtual auto dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] virtual auto dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * = 0; @@ -399,13 +404,13 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - [[nodiscard]] auto dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; - [[nodiscard]] auto dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; @@ -423,13 +428,13 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - [[nodiscard]] auto dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; - [[nodiscard]] auto dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; @@ -447,13 +452,13 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - [[nodiscard]] auto dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; - [[nodiscard]] auto dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; @@ -471,13 +476,13 @@ namespace filc::ast { [[nodiscard]] auto dump() const -> std::string override; - [[nodiscard]] auto dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; - [[nodiscard]] auto dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + [[nodiscard]] auto dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * override; diff --git a/src/lib/ast/AbstractExpression.cpp b/src/lib/ast/AbstractExpression.cpp index 576a4903..e655b8de 100644 --- a/src/lib/ast/AbstractExpression.cpp +++ b/src/lib/ast/AbstractExpression.cpp @@ -53,7 +53,9 @@ namespace filc::ast { _expression_type = expression_type; } - auto AbstractExpression::resolveType(filc::environment::Environment *environment, filc::message::MessageCollector *collector) -> void { + auto AbstractExpression::resolveType(filc::environment::Environment *environment, + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { throw std::logic_error("Not implemented"); } } diff --git a/src/lib/ast/ArrayOperator.cpp b/src/lib/ast/ArrayOperator.cpp index 7785c7ea..48e1fb1e 100644 --- a/src/lib/ast/ArrayOperator.cpp +++ b/src/lib/ast/ArrayOperator.cpp @@ -39,15 +39,15 @@ namespace filc::ast { return "[]"; } - auto ArrayOperator::dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto ArrayOperator::dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { throw std::logic_error("Should not be called"); } - auto ArrayOperator::dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto ArrayOperator::dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { _expression->resolveType(environment, collector); diff --git a/src/lib/ast/AssignationOperator.cpp b/src/lib/ast/AssignationOperator.cpp index f69ee822..fcb117f1 100644 --- a/src/lib/ast/AssignationOperator.cpp +++ b/src/lib/ast/AssignationOperator.cpp @@ -39,15 +39,15 @@ namespace filc::ast { return _inner_operator->dump() + "="; } - auto AssignationOperator::dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto AssignationOperator::dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { throw std::logic_error("Should not be called"); } - auto AssignationOperator::dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto AssignationOperator::dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { throw std::logic_error("Should not be called"); diff --git a/src/lib/ast/BinaryCalcul.cpp b/src/lib/ast/BinaryCalcul.cpp index b34b1a98..b5b783e8 100644 --- a/src/lib/ast/BinaryCalcul.cpp +++ b/src/lib/ast/BinaryCalcul.cpp @@ -22,6 +22,7 @@ * SOFTWARE. */ #include "AST.h" +#include "Error.h" namespace filc::ast { BinaryCalcul::BinaryCalcul(filc::ast::AbstractExpression *left_expression, filc::ast::Operator *p_operator, @@ -45,4 +46,34 @@ namespace filc::ast { delete _operator; delete _right_expression; } + + auto BinaryCalcul::resolveType(filc::environment::Environment *environment, + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { + _left_expression->resolveType(environment, collector); + auto *left_type = _left_expression->getExpressionType(); + _right_expression->resolveType(environment, collector); + auto *right_type = _right_expression->getExpressionType(); + if (left_type == nullptr || right_type == nullptr) { + return; + } + + auto operator_name = "operator" + _operator->dump(); + auto has_found_preferred = preferred_type != nullptr && + environment->hasName(operator_name, new LambdaType({left_type, right_type}, + preferred_type, left_type)); + auto has_found_left = environment->hasName(operator_name, new LambdaType({left_type, right_type}, + left_type, left_type)); + if ((preferred_type != nullptr && (!has_found_preferred || !has_found_left)) || !has_found_left) { + collector->addError( + new filc::message::Error(filc::message::ERROR, + "There is no operator " + getOperator()->dump() + + " for types " + left_type->dump() + " and " + right_type->dump(), + getPosition()) + ); + return; + } + + setExpressionType(has_found_preferred ? preferred_type : left_type); + } } diff --git a/src/lib/ast/BooleanLiteral.cpp b/src/lib/ast/BooleanLiteral.cpp index 0cc3b3d0..bc55e467 100644 --- a/src/lib/ast/BooleanLiteral.cpp +++ b/src/lib/ast/BooleanLiteral.cpp @@ -28,7 +28,8 @@ namespace filc::ast { : AbstractLiteral(value) {} auto BooleanLiteral::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (!environment->hasType("bool")) { environment->addType(new filc::ast::Type(new filc::ast::Identifier("bool"))); } diff --git a/src/lib/ast/CharacterLiteral.cpp b/src/lib/ast/CharacterLiteral.cpp index 9fdb298a..7f56c74a 100644 --- a/src/lib/ast/CharacterLiteral.cpp +++ b/src/lib/ast/CharacterLiteral.cpp @@ -56,7 +56,8 @@ namespace filc::ast { } auto CharacterLiteral::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (!environment->hasType("char")) { environment->addType(new filc::ast::Type(new filc::ast::Identifier("char"))); } diff --git a/src/lib/ast/ClassicOperator.cpp b/src/lib/ast/ClassicOperator.cpp index 11a935c1..d0deb063 100644 --- a/src/lib/ast/ClassicOperator.cpp +++ b/src/lib/ast/ClassicOperator.cpp @@ -76,15 +76,15 @@ namespace filc::ast { throw std::logic_error("Should not come here"); } - auto ClassicOperator::dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto ClassicOperator::dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { return new LambdaType({}, return_type, called_on); } - auto ClassicOperator::dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto ClassicOperator::dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { if (!environment->hasType("void")) { diff --git a/src/lib/ast/FloatLiteral.cpp b/src/lib/ast/FloatLiteral.cpp index 7a75619a..b0338013 100644 --- a/src/lib/ast/FloatLiteral.cpp +++ b/src/lib/ast/FloatLiteral.cpp @@ -28,7 +28,8 @@ namespace filc::ast { : AbstractLiteral(value) {} auto FloatLiteral::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (!environment->hasType("double")) { environment->addType(new filc::ast::Type(new filc::ast::Identifier("double"))); } diff --git a/src/lib/ast/FunctionOperator.cpp b/src/lib/ast/FunctionOperator.cpp index 4fb49894..560555a4 100644 --- a/src/lib/ast/FunctionOperator.cpp +++ b/src/lib/ast/FunctionOperator.cpp @@ -41,20 +41,20 @@ namespace filc::ast { return "()"; } - auto FunctionOperator::dumpPreLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto FunctionOperator::dumpPreLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { throw std::logic_error("Should not be called"); } - auto FunctionOperator::dumpPostLambdaType(filc::ast::AbstractType *return_type, - filc::ast::AbstractType *called_on, + auto FunctionOperator::dumpPostLambdaType(AbstractType *return_type, + AbstractType *called_on, filc::environment::Environment *environment, filc::message::MessageCollector *collector) const -> LambdaType * { std::vector args_types; for (const auto &expression: _expressions) { - expression->resolveType(environment, collector); + expression->resolveType(environment, collector, nullptr); auto *expression_type = expression->getExpressionType(); if (expression_type != nullptr) { args_types.push_back(expression_type); diff --git a/src/lib/ast/Identifier.cpp b/src/lib/ast/Identifier.cpp index 103c1139..fdd0d9c6 100644 --- a/src/lib/ast/Identifier.cpp +++ b/src/lib/ast/Identifier.cpp @@ -39,8 +39,9 @@ namespace filc::ast { } auto Identifier::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { - if (!environment->hasName(_name)) { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { + if (!environment->hasName(_name, preferred_type)) { collector->addError( new filc::message::Error(filc::message::ERROR, _name + " is not defined", getPosition()) ); diff --git a/src/lib/ast/IntegerLiteral.cpp b/src/lib/ast/IntegerLiteral.cpp index 90942524..8f347cf3 100644 --- a/src/lib/ast/IntegerLiteral.cpp +++ b/src/lib/ast/IntegerLiteral.cpp @@ -28,7 +28,8 @@ namespace filc::ast { : AbstractLiteral(value) {} auto IntegerLiteral::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (!environment->hasType("int")) { environment->addType(new filc::ast::Type(new filc::ast::Identifier("int"))); } diff --git a/src/lib/ast/PostUnaryCalcul.cpp b/src/lib/ast/PostUnaryCalcul.cpp index 5e7d57c7..e61097e4 100644 --- a/src/lib/ast/PostUnaryCalcul.cpp +++ b/src/lib/ast/PostUnaryCalcul.cpp @@ -29,8 +29,9 @@ namespace filc::ast { : UnaryCalcul(variable, p_operator) {} auto PostUnaryCalcul::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { - getVariable()->resolveType(environment, collector); + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { + getVariable()->resolveType(environment, collector, nullptr); auto *variable_type = getVariable()->getExpressionType(); if (variable_type == nullptr) { return; diff --git a/src/lib/ast/PreUnaryCalcul.cpp b/src/lib/ast/PreUnaryCalcul.cpp index 4391fd02..666c0c7c 100644 --- a/src/lib/ast/PreUnaryCalcul.cpp +++ b/src/lib/ast/PreUnaryCalcul.cpp @@ -29,8 +29,9 @@ namespace filc::ast { : UnaryCalcul(variable, p_operator) {} auto PreUnaryCalcul::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { - getVariable()->resolveType(environment, collector); + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { + getVariable()->resolveType(environment, collector, nullptr); auto *variable_type = getVariable()->getExpressionType(); if (variable_type == nullptr) { return; diff --git a/src/lib/ast/StringLiteral.cpp b/src/lib/ast/StringLiteral.cpp index 3e88eaaf..91bbef2d 100644 --- a/src/lib/ast/StringLiteral.cpp +++ b/src/lib/ast/StringLiteral.cpp @@ -29,7 +29,8 @@ namespace filc::ast { : AbstractLiteral(filc::utils::parseEscapedString(value.substr(1, value.length() - 2))) {} auto StringLiteral::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (!environment->hasType("char*")) { environment->addType(new filc::ast::Type(new filc::ast::Identifier("char*"))); } diff --git a/src/lib/ast/VariableDeclaration.cpp b/src/lib/ast/VariableDeclaration.cpp index 3a815f6c..271d083f 100644 --- a/src/lib/ast/VariableDeclaration.cpp +++ b/src/lib/ast/VariableDeclaration.cpp @@ -55,7 +55,8 @@ namespace filc::ast { } auto VariableDeclaration::resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void { + filc::message::MessageCollector *collector, + AbstractType *preferred_type) -> void { if (environment->hasName(_identifier->getName())) { collector->addError( new filc::message::Error(filc::message::ERROR, @@ -65,7 +66,7 @@ namespace filc::ast { return; } - _assignation->resolveType(environment, collector); + _assignation->resolveType(environment, collector, _type); auto *assignation_type = _assignation->getExpressionType(); if (assignation_type == nullptr) { return; diff --git a/src/lib/environment/Environment.cpp b/src/lib/environment/Environment.cpp index 095a2452..be23cf2a 100644 --- a/src/lib/environment/Environment.cpp +++ b/src/lib/environment/Environment.cpp @@ -120,114 +120,577 @@ namespace filc::environment { auto *char_pointer_type = new filc::ast::PointerType(new filc::ast::Type(new filc::ast::Identifier("char"))); auto *bool_type = new filc::ast::Type(new filc::ast::Identifier("bool")); auto *void_type = new filc::ast::Type(new filc::ast::Identifier("void")); - auto is_ok = global->addType(int_type) - && global->addType(double_type) - && global->addType(float_type) - && global->addType(char_type) - && global->addType(char_pointer_type) - && global->addType(bool_type) - && global->addType(void_type); - if (!is_ok) { + auto iok = global->addType(int_type) + && global->addType(double_type) + && global->addType(float_type) + && global->addType(char_type) + && global->addType(char_pointer_type) + && global->addType(bool_type) + && global->addType(void_type); + if (!iok) { throw std::logic_error("Fail to add base types to global environment"); } // Operators // - Assignations - is_ok = global->addName("operator=", new filc::ast::LambdaType({int_type, int_type}, int_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({int_type, double_type}, int_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({int_type, float_type}, int_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({int_type, char_type}, int_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({int_type, bool_type}, int_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({double_type, int_type}, double_type, void_type)) - && global->addName("operator=", - new filc::ast::LambdaType({double_type, double_type}, double_type, void_type)) - && global->addName("operator=", - new filc::ast::LambdaType({double_type, float_type}, double_type, void_type)) - && global->addName("operator=", - new filc::ast::LambdaType({double_type, char_type}, double_type, void_type)) - && global->addName("operator=", - new filc::ast::LambdaType({double_type, bool_type}, double_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({float_type, int_type}, float_type, void_type)) - && global->addName("operator=", - new filc::ast::LambdaType({float_type, double_type}, float_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({float_type, float_type}, float_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({float_type, char_type}, float_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({float_type, bool_type}, float_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({char_type, int_type}, char_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({char_type, double_type}, char_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({char_type, float_type}, char_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({char_type, char_type}, char_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({char_type, bool_type}, char_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({bool_type, int_type}, bool_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({bool_type, double_type}, bool_type, void_type)) - && - global->addName("operator=", new filc::ast::LambdaType({bool_type, float_type}, bool_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({bool_type, char_type}, bool_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({bool_type, bool_type}, bool_type, void_type)) - && global->addName("operator=", new filc::ast::LambdaType({char_pointer_type, char_pointer_type}, - char_pointer_type, void_type)); - if (!is_ok) { + iok = global->addName("operator=", new filc::ast::LambdaType({int_type, int_type}, int_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({int_type, double_type}, int_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({int_type, float_type}, int_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({int_type, char_type}, int_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({int_type, bool_type}, int_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({double_type, int_type}, double_type, void_type)) + && global->addName("operator=", + new filc::ast::LambdaType({double_type, double_type}, double_type, void_type)) + && global->addName("operator=", + new filc::ast::LambdaType({double_type, float_type}, double_type, void_type)) + && global->addName("operator=", + new filc::ast::LambdaType({double_type, char_type}, double_type, void_type)) + && global->addName("operator=", + new filc::ast::LambdaType({double_type, bool_type}, double_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({float_type, int_type}, float_type, void_type)) + && global->addName("operator=", + new filc::ast::LambdaType({float_type, double_type}, float_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({float_type, float_type}, float_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({float_type, char_type}, float_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({float_type, bool_type}, float_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({char_type, int_type}, char_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({char_type, double_type}, char_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({char_type, float_type}, char_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({char_type, char_type}, char_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({char_type, bool_type}, char_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({bool_type, int_type}, bool_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({bool_type, double_type}, bool_type, void_type)) + && + global->addName("operator=", new filc::ast::LambdaType({bool_type, float_type}, bool_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({bool_type, char_type}, bool_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({bool_type, bool_type}, bool_type, void_type)) + && global->addName("operator=", new filc::ast::LambdaType({char_pointer_type, char_pointer_type}, + char_pointer_type, void_type)); + if (!iok) { throw std::logic_error("Fail to add base assignations to global environment"); } // - Prefix unary - is_ok = global->addName("operator++", new filc::ast::LambdaType({}, int_type, int_type)) - && global->addName("operator--", new filc::ast::LambdaType({}, int_type, int_type)) - && global->addName("operator+", new filc::ast::LambdaType({}, int_type, int_type)) - && global->addName("operator-", new filc::ast::LambdaType({}, int_type, int_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(int_type), - int_type)) - && global->addName("operator++", new filc::ast::LambdaType({}, double_type, double_type)) - && global->addName("operator--", new filc::ast::LambdaType({}, double_type, double_type)) - && global->addName("operator+", new filc::ast::LambdaType({}, double_type, double_type)) - && global->addName("operator-", new filc::ast::LambdaType({}, double_type, double_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(double_type), - double_type)) - && global->addName("operator++", new filc::ast::LambdaType({}, float_type, float_type)) - && global->addName("operator--", new filc::ast::LambdaType({}, float_type, float_type)) - && global->addName("operator+", new filc::ast::LambdaType({}, float_type, float_type)) - && global->addName("operator-", new filc::ast::LambdaType({}, float_type, float_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(float_type), - float_type)) - && global->addName("operator++", new filc::ast::LambdaType({}, char_type, char_type)) - && global->addName("operator--", new filc::ast::LambdaType({}, char_type, char_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, char_pointer_type, char_type)) - && global->addName("operator!", new filc::ast::LambdaType({}, bool_type, bool_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(bool_type), - bool_type)) - && global->addName("operator++", new filc::ast::LambdaType({}, char_pointer_type, char_pointer_type)) - && global->addName("operator--", new filc::ast::LambdaType({}, char_pointer_type, char_pointer_type)) - && global->addName("operator&", new filc::ast::LambdaType({}, - new filc::ast::PointerType(char_pointer_type), - char_pointer_type)) - && global->addName("operator*", new filc::ast::LambdaType({}, char_type, char_pointer_type)); - if (!is_ok) { + iok = global->addName("operator++", new filc::ast::LambdaType({}, int_type, int_type)) + && global->addName("operator--", new filc::ast::LambdaType({}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({}, int_type, int_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(int_type), + int_type)) + && global->addName("operator++", new filc::ast::LambdaType({}, double_type, double_type)) + && global->addName("operator--", new filc::ast::LambdaType({}, double_type, double_type)) + && global->addName("operator+", new filc::ast::LambdaType({}, double_type, double_type)) + && global->addName("operator-", new filc::ast::LambdaType({}, double_type, double_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(double_type), + double_type)) + && global->addName("operator++", new filc::ast::LambdaType({}, float_type, float_type)) + && global->addName("operator--", new filc::ast::LambdaType({}, float_type, float_type)) + && global->addName("operator+", new filc::ast::LambdaType({}, float_type, float_type)) + && global->addName("operator-", new filc::ast::LambdaType({}, float_type, float_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(float_type), + float_type)) + && global->addName("operator++", new filc::ast::LambdaType({}, char_type, char_type)) + && global->addName("operator--", new filc::ast::LambdaType({}, char_type, char_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, char_pointer_type, char_type)) + && global->addName("operator!", new filc::ast::LambdaType({}, bool_type, bool_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, new filc::ast::PointerType(bool_type), + bool_type)) + && global->addName("operator++", new filc::ast::LambdaType({}, char_pointer_type, char_pointer_type)) + && global->addName("operator--", new filc::ast::LambdaType({}, char_pointer_type, char_pointer_type)) + && global->addName("operator&", new filc::ast::LambdaType({}, + new filc::ast::PointerType(char_pointer_type), + char_pointer_type)) + && global->addName("operator*", new filc::ast::LambdaType({}, char_type, char_pointer_type)); + if (!iok) { throw std::logic_error("Fail to add base prefix unary calcul to global environment"); } // - Postfix unary - is_ok = global->addName("operator++", new filc::ast::LambdaType({void_type}, int_type, int_type)) - && global->addName("operator--", new filc::ast::LambdaType({void_type}, int_type, int_type)) - && global->addName("operator++", new filc::ast::LambdaType({void_type}, double_type, double_type)) - && global->addName("operator--", new filc::ast::LambdaType({void_type}, double_type, double_type)) - && global->addName("operator++", new filc::ast::LambdaType({void_type}, float_type, float_type)) - && global->addName("operator--", new filc::ast::LambdaType({void_type}, float_type, float_type)) - && global->addName("operator++", new filc::ast::LambdaType({void_type}, char_type, char_type)) - && global->addName("operator--", new filc::ast::LambdaType({void_type}, char_type, char_type)) - && global->addName("operator++", new filc::ast::LambdaType({void_type}, char_pointer_type, - char_pointer_type)) - && global->addName("operator--", new filc::ast::LambdaType({void_type}, char_pointer_type, - char_pointer_type)) - && global->addName("operator[]", new filc::ast::LambdaType({int_type}, char_type, char_pointer_type)); - if (!is_ok) { + iok = global->addName("operator++", new filc::ast::LambdaType({void_type}, int_type, int_type)) + && global->addName("operator--", new filc::ast::LambdaType({void_type}, int_type, int_type)) + && global->addName("operator++", new filc::ast::LambdaType({void_type}, double_type, double_type)) + && global->addName("operator--", new filc::ast::LambdaType({void_type}, double_type, double_type)) + && global->addName("operator++", new filc::ast::LambdaType({void_type}, float_type, float_type)) + && global->addName("operator--", new filc::ast::LambdaType({void_type}, float_type, float_type)) + && global->addName("operator++", new filc::ast::LambdaType({void_type}, char_type, char_type)) + && global->addName("operator--", new filc::ast::LambdaType({void_type}, char_type, char_type)) + && global->addName("operator++", new filc::ast::LambdaType({void_type}, char_pointer_type, + char_pointer_type)) + && global->addName("operator--", new filc::ast::LambdaType({void_type}, char_pointer_type, + char_pointer_type)) + && global->addName("operator[]", new filc::ast::LambdaType({int_type}, char_type, char_pointer_type)); + if (!iok) { throw std::logic_error("Fail to add base postfix unary calcul to global environment"); } + // - Binary + iok = global->addName("operator*", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator*", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator*", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator*", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator*", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator/", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator/", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator/", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator/", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator/", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator%", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator%", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator%", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator%", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator%", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator+", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator-", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator<", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + && global->addName("operator<", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + && global->addName("operator<", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + && global->addName("operator<", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + && global->addName("operator<", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + && global->addName("operator>", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + && global->addName("operator>", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + && global->addName("operator>", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + && global->addName("operator>", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + && global->addName("operator>", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + && global->addName("operator==", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + && + global->addName("operator==", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + && global->addName("operator==", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + && global->addName("operator==", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + && global->addName("operator==", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + && global->addName("operator<=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + && + global->addName("operator<=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + && global->addName("operator<=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + && global->addName("operator<=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + && global->addName("operator<=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + && global->addName("operator>=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + && + global->addName("operator>=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + && global->addName("operator>=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + && global->addName("operator>=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + && global->addName("operator>=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + && global->addName("operator*=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator*=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator*=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator*=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator*=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator/=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator/=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator/=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator/=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator/=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator%=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator%=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator%=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator%=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator%=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator+=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator+=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator+=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator+=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator+=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + && global->addName("operator-=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + && global->addName("operator-=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + && global->addName("operator-=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + && global->addName("operator-=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + && global->addName("operator-=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)); + + // && global->addName("operator*", new filc::ast::LambdaType({double_type, int_type}, double_type, double_type)) + // && global->addName("operator*", new filc::ast::LambdaType({double_type, double_type}, double_type, double_type)) + // && global->addName("operator*", new filc::ast::LambdaType({double_type, float_type}, double_type, double_type)) + // && global->addName("operator*", new filc::ast::LambdaType({double_type, char_type}, double_type, double_type)) + // && global->addName("operator*", new filc::ast::LambdaType({double_type, bool_type}, double_type, double_type)) + // && global->addName("operator/", new filc::ast::LambdaType({double_type, int_type}, double_type, double_type)) + // && global->addName("operator/", new filc::ast::LambdaType({double_type, double_type}, double_type, double_type)) + // && global->addName("operator/", new filc::ast::LambdaType({double_type, float_type}, double_type, double_type)) + // && global->addName("operator/", new filc::ast::LambdaType({double_type, char_type}, double_type, double_type)) + // && global->addName("operator/", new filc::ast::LambdaType({double_type, bool_type}, double_type, double_type)) + // && global->addName("operator%", new filc::ast::LambdaType({double_type, int_type}, double_type, double_type)) + // && global->addName("operator%", new filc::ast::LambdaType({double_type, double_type}, double_type, double_type)) + // && global->addName("operator%", new filc::ast::LambdaType({double_type, float_type}, double_type, double_type)) + // && global->addName("operator%", new filc::ast::LambdaType({double_type, char_type}, double_type, double_type)) + // && global->addName("operator%", new filc::ast::LambdaType({double_type, bool_type}, double_type, double_type)) + // && global->addName("operator+", new filc::ast::LambdaType({double_type, int_type}, double_type, double_type)) + // && global->addName("operator+", new filc::ast::LambdaType({double_type, double_type}, double_type, double_type)) + // && global->addName("operator+", new filc::ast::LambdaType({double_type, float_type}, double_type, double_type)) + // && global->addName("operator+", new filc::ast::LambdaType({double_type, char_type}, double_type, double_type)) + // && global->addName("operator+", new filc::ast::LambdaType({double_type, bool_type}, double_type, double_type)) + // && global->addName("operator-", new filc::ast::LambdaType({double_type, int_type}, double_type, double_type)) + // && global->addName("operator-", new filc::ast::LambdaType({double_type, double_type}, double_type, double_type)) + // && global->addName("operator-", new filc::ast::LambdaType({double_type, float_type}, double_type, double_type)) + // && global->addName("operator-", new filc::ast::LambdaType({double_type, char_type}, double_type, double_type)) + // && global->addName("operator-", new filc::ast::LambdaType({double_type, bool_type}, double_type, double_type)) + // && global->addName("operator<", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && global->addName("operator<", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator<", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator<", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator<", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator>", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && global->addName("operator>", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator>", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator>", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator>", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator==", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && + // global->addName("operator==", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator==", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator==", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator==", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && + // global->addName("operator<=", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && + // global->addName("operator>=", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && + // global->addName("operator!=", new filc::ast::LambdaType({double_type, double_type}, bool_type, double_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({double_type, float_type}, bool_type, double_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({double_type, char_type}, bool_type, double_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({double_type, bool_type}, bool_type, double_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({double_type, int_type}, bool_type, double_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator||", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator||", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator||", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator||", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator||", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({double_type, int_type}, int_type, double_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({double_type, double_type}, int_type, double_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({double_type, float_type}, int_type, double_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({double_type, char_type}, int_type, double_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({double_type, bool_type}, int_type, double_type)) + // + // && global->addName("operator*", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator==", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator<=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator>=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator!=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // + // && global->addName("operator*", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator==", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator<=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator>=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator!=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // + // && global->addName("operator*", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator==", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator==", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator<=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator<=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator>=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator>=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && + // global->addName("operator!=", new filc::ast::LambdaType({int_type, double_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, float_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, char_type}, bool_type, int_type)) + // && global->addName("operator!=", new filc::ast::LambdaType({int_type, bool_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, int_type}, bool_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator&&", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator||", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator*=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator/=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator%=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator+=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, int_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, double_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, float_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, char_type}, int_type, int_type)) + // && global->addName("operator-=", new filc::ast::LambdaType({int_type, bool_type}, int_type, int_type)); + if (!iok) { + throw std::logic_error("Fail to add base binary calcul to global environment"); + } + return global; } diff --git a/tests/unit/Fixtures/ast/binary_calcul1.fil b/tests/unit/Fixtures/ast/binary_calcul1.fil new file mode 100644 index 00000000..a1c80327 --- /dev/null +++ b/tests/unit/Fixtures/ast/binary_calcul1.fil @@ -0,0 +1,5 @@ +module test + +var a: int = 2 + 2 +var b: int = 0 +b += a \ No newline at end of file diff --git a/tests/unit/Fixtures/ast/binary_calcul2.fil b/tests/unit/Fixtures/ast/binary_calcul2.fil new file mode 100644 index 00000000..755d17cb --- /dev/null +++ b/tests/unit/Fixtures/ast/binary_calcul2.fil @@ -0,0 +1,3 @@ +module test + +var truth: bool = 1 == 1 diff --git a/tests/unit/ast/AbstractExpressionTest.cpp b/tests/unit/ast/AbstractExpressionTest.cpp index 3e5fb361..923ea7d0 100644 --- a/tests/unit/ast/AbstractExpressionTest.cpp +++ b/tests/unit/ast/AbstractExpressionTest.cpp @@ -66,18 +66,19 @@ TEST(AbstractExpression, resolveType) { class : public filc::ast::AbstractExpression { } obj1; - ASSERT_THROW(obj1.resolveType(nullptr, nullptr), std::logic_error); - ASSERT_THROW(obj1.resolveType(new filc::environment::Environment, nullptr), std::logic_error); + ASSERT_THROW(obj1.resolveType(nullptr, nullptr, nullptr), std::logic_error); + ASSERT_THROW(obj1.resolveType(new filc::environment::Environment, nullptr, nullptr), std::logic_error); class : public filc::ast::AbstractExpression { public: auto resolveType(filc::environment::Environment *environment, - filc::message::MessageCollector *collector) -> void override { + filc::message::MessageCollector *collector, + filc::ast::AbstractType *preferred_type) -> void override { // Nothing } } obj2; - ASSERT_NO_THROW(obj2.resolveType(nullptr, nullptr)); - ASSERT_NO_THROW(obj2.resolveType(new filc::environment::Environment, nullptr)); + ASSERT_NO_THROW(obj2.resolveType(nullptr, nullptr, nullptr)); + ASSERT_NO_THROW(obj2.resolveType(new filc::environment::Environment, nullptr, nullptr)); } // NOLINTEND(readability-function-cognitive-complexity) \ No newline at end of file diff --git a/tests/unit/ast/BinaryCalculTest.cpp b/tests/unit/ast/BinaryCalculTest.cpp index f396b16c..ac43dd36 100644 --- a/tests/unit/ast/BinaryCalculTest.cpp +++ b/tests/unit/ast/BinaryCalculTest.cpp @@ -22,7 +22,7 @@ * SOFTWARE. */ #include "AST.h" -#include +#include "Parser.h" #include "test_tools.h" TEST(BinaryCalcul, constructor) { @@ -34,4 +34,24 @@ TEST(BinaryCalcul, constructor) { ASSERT_IDENTIFIER("a", bc1.getLeftExpression()); ASSERT_IDENTIFIER("b", bc1.getRightExpression()); ASSERT_CLASSIC_OPERATOR(PLUS, bc1.getOperator()); +} + +#define FIXTURES_PATH "../../tests/unit/Fixtures" + +#define COLLECTOR filc::message::MessageCollector::getCollector() + +TEST(BinaryCalcul, resolveType) { + filc::grammar::Parser parser1(FIXTURES_PATH "/ast/binary_calcul1.fil", COLLECTOR); + auto *program1 = parser1.getProgram(); + ASSERT_NO_THROW(program1->resolveEnvironment(COLLECTOR)); + ASSERT_THAT(program1->getExpressions(), SizeIs(3)); + ASSERT_TYPE("int", program1->getExpressions()[0]->getExpressionType()); + ASSERT_TYPE("int", program1->getExpressions()[1]->getExpressionType()); + ASSERT_TYPE("int", program1->getExpressions()[2]->getExpressionType()); + + filc::grammar::Parser parser2(FIXTURES_PATH "/ast/binary_calcul2.fil", COLLECTOR); + auto *program2 = parser2.getProgram(); + ASSERT_NO_THROW(program2->resolveEnvironment(COLLECTOR)); + ASSERT_THAT(program2->getExpressions(), SizeIs(1)); + ASSERT_TYPE("bool", program2->getExpressions()[0]->getExpressionType()); } \ No newline at end of file diff --git a/tests/unit/ast/IdentifierTest.cpp b/tests/unit/ast/IdentifierTest.cpp index 634e029a..ae49b934 100644 --- a/tests/unit/ast/IdentifierTest.cpp +++ b/tests/unit/ast/IdentifierTest.cpp @@ -35,12 +35,12 @@ TEST(Identifier, resolveType) { auto *environment = new filc::environment::Environment; filc::ast::Identifier id1("hello"); - id1.resolveType(environment, collector); + id1.resolveType(environment, collector, nullptr); ASSERT_TRUE(collector->hasErrors()); collector->printAll(); environment->addName("hello", new filc::ast::Type(new filc::ast::Identifier("int"))); - id1.resolveType(environment, collector); + id1.resolveType(environment, collector, nullptr); ASSERT_FALSE(collector->hasErrors()); ASSERT_TYPE("int", id1.getExpressionType()); } \ No newline at end of file