Type check binary expressions

This commit is contained in:
2024-05-28 23:39:04 +02:00
parent b7beb7e601
commit 8c2ea58693
10 changed files with 158 additions and 11 deletions

View File

@ -134,7 +134,9 @@ namespace elna::source
enum class operation
{
dereference,
argument
argument,
arithmetic,
comparison
};
/**

View File

@ -82,6 +82,7 @@ namespace elna::source
void visit(integer_literal *literal) override;
void visit(boolean_literal *literal) override;
void visit(unary_expression *expression) override;
void visit(binary_expression *expression) override;
void visit(call_statement *statement) override;
void visit(constant_definition *definition) override;
};

View File

@ -26,6 +26,9 @@ namespace elna::source
* \return The type size in bytes.
*/
virtual std::size_t size() const noexcept;
friend bool operator==(const type& lhs, const type& rhs) noexcept;
friend bool operator!=(const type& lhs, const type& rhs) noexcept;
};
/**
@ -43,6 +46,9 @@ namespace elna::source
* \param byte_size The type size in bytes.
*/
primitive_type(const std::string& type_name, const std::size_t byte_size);
bool operator==(const primitive_type& that) const noexcept;
bool operator!=(const primitive_type& that) const noexcept;
};
/**
@ -60,6 +66,9 @@ namespace elna::source
* \param byte_size The type size in bytes.
*/
pointer_type(std::shared_ptr<const type> base_type, const std::size_t byte_size);
bool operator==(const pointer_type& that) const noexcept;
bool operator!=(const pointer_type& that) const noexcept;
};
/**
@ -77,8 +86,14 @@ namespace elna::source
* \param byte_size Function pointer size.
*/
procedure_type(std::vector<std::shared_ptr<const type>> arguments, const std::size_t byte_size);
bool operator==(const procedure_type& that) const noexcept;
bool operator!=(const procedure_type& that) const noexcept;
};
bool operator==(const type& lhs, const type& rhs) noexcept;
bool operator!=(const type& lhs, const type& rhs) noexcept;
inline const primitive_type boolean_type{ "Boolean", 1 };
inline const primitive_type int_type{ "Int", 4 };
}