Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference type #375

Draft
wants to merge 25 commits into
base: feature
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6e919cc
Add reference type
TimaFrolov Mar 21, 2023
408c3c1
Merge branch 'feature-const' into feature-reference
TimaFrolov Mar 27, 2023
ad8a2c4
Better errors related to reference type
TimaFrolov Mar 27, 2023
373b82e
Add test for error related to reference type
TimaFrolov Mar 27, 2023
ad6ce5a
Add support of reference type to writer
TimaFrolov Mar 28, 2023
8f68d22
Merge branch 'feature' into feature-reference
TimaFrolov Mar 28, 2023
ee3cfb2
Fix typo
TimaFrolov Mar 28, 2023
1760084
Better error message for reference without declaration
TimaFrolov Mar 28, 2023
2eb9d70
move check in check_assignment_operands
TimaFrolov Mar 28, 2023
e12f240
Make error for reference to not lvalue
TimaFrolov Mar 28, 2023
a1e6e50
Fix typo in previous commit
TimaFrolov Mar 28, 2023
8d602f8
Fix binary, unary operations for reference and reference to struct be…
TimaFrolov Apr 1, 2023
7141eef
Fix bug occured in check assignment operands for reference type
TimaFrolov Apr 3, 2023
58f8158
Fix cast expression generation for reference type
TimaFrolov Apr 3, 2023
fcd7ad9
Merge branch 'feature-const' into feature-reference
TimaFrolov Apr 3, 2023
b4d83a4
Fix generating error for reference without init
TimaFrolov Apr 3, 2023
eefbfa2
Fix int to float& assignment in non-declaration
TimaFrolov Apr 10, 2023
530626d
Merge branch 'feature-const' into feature-reference
TimaFrolov Apr 10, 2023
ffdddda
rename test for reference without init
TimaFrolov Apr 10, 2023
f2126d8
Add comments for reference errors
TimaFrolov Apr 18, 2023
c496ca6
Fix typo
TimaFrolov Apr 18, 2023
d7e92a7
Fix reference type usage in subscript expression
TimaFrolov Apr 18, 2023
f3de088
Fix ternary operator
TimaFrolov May 9, 2023
af282c7
Merge branch 'feature' into feature-reference
TimaFrolov Jun 12, 2023
3dd45bb
Some work on reference types
TimaFrolov Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libs/compiler/AST.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ expression_t expression_get_class(const node *const nd)
case OP_SELECT:
return EXPR_MEMBER;
case OP_CAST:
return EXPR_CAST;
return EXPR_ARITHMETIC_CAST;
case OP_UNARY:
return EXPR_UNARY;
case OP_BINARY:
Expand Down Expand Up @@ -317,7 +317,7 @@ bool expression_member_is_arrow(const node *const nd)
}


node expression_cast(const item_t target_type, const item_t source_type, node *const expr, const location loc)
node expression_arithmetic_cast(const item_t target_type, const item_t source_type, node *const expr, const location loc)
{
node nd = node_insert(expr, OP_CAST, 5); // Операнд выражения

Expand Down
29 changes: 15 additions & 14 deletions libs/compiler/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ typedef enum CATEGORY
/** Expression class */
typedef enum EXPRESSION
{
EXPR_IDENTIFIER, /**< Identifier expression */
EXPR_LITERAL, /**< Literal expression */
EXPR_SUBSCRIPT, /**< Subscript expression */
EXPR_CALL, /**< Call expression */
EXPR_MEMBER, /**< Member expression */
EXPR_CAST, /**< Cast expression */
EXPR_UNARY, /**< Unary expression */
EXPR_BINARY, /**< Binary expression */
EXPR_TERNARY, /**< Ternary expression */
EXPR_ASSIGNMENT, /**< Assignment expression */
EXPR_INITIALIZER, /**< Initializer */
EXPR_EMPTY_BOUND, /**< Empty array size expression */
EXPR_INVALID, /**< Invalid expression */
EXPR_IDENTIFIER, /**< Identifier expression */
EXPR_LITERAL, /**< Literal expression */
EXPR_SUBSCRIPT, /**< Subscript expression */
EXPR_CALL, /**< Call expression */
EXPR_MEMBER, /**< Member expression */
EXPR_ARITHMETIC_CAST, /**< Arithmetic cast expression */
EXPR_REFERENCE_CAST, /**< Reference cast expression */
EXPR_UNARY, /**< Unary expression */
EXPR_BINARY, /**< Binary expression */
EXPR_TERNARY, /**< Ternary expression */
EXPR_ASSIGNMENT, /**< Assignment expression */
EXPR_INITIALIZER, /**< Initializer */
EXPR_EMPTY_BOUND, /**< Empty array size expression */
EXPR_INVALID, /**< Invalid expression */
} expression_t;

/** Statement class */
Expand Down Expand Up @@ -404,7 +405,7 @@ bool expression_member_is_arrow(const node *const nd);
*
* @return Cast expression
*/
node expression_cast(const item_t target_type, const item_t source_type, node *const expr, const location loc);
node expression_arithmetic_cast(const item_t target_type, const item_t source_type, node *const expr, const location loc);

/**
* Get source type of cast expression
Expand Down
Loading