Skip to content

Commit cc175cc

Browse files
committed
fix(compiler): add spaces around operator for autocast augment
1 parent a0d69a4 commit cc175cc

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

compiler/src/compiler/compiler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void compiler::perform_assign(std::pair<std::string, ykobject> &lhs,
7474
(lhs.second.datatype_->const_unwrap()->is_a_number() ||
7575
lhs.second.datatype_->const_unwrap()->is_bool())) {
7676
// Number cast that we can do here
77-
body_ << lhs.first << operator_token->token_;
77+
body_ << lhs.first << " " << operator_token->token_ << " ";
7878
cast_numbers(castable, lhs, rhs);
7979
if (lhs.second.is_primitive_or_obj() &&
8080
lhs.second.datatype_->const_unwrap()->is_f32() &&
@@ -87,7 +87,7 @@ void compiler::perform_assign(std::pair<std::string, ykobject> &lhs,
8787
} else {
8888
body_ << rhs.first;
8989
}
90-
LOG_COMP("cast assign:" << lhs.first << " = " << rhs.first);
90+
LOG_COMP("cast assign:" << lhs.first << " " << operator_token->token_ << " " << rhs.first);
9191
} else if (rhs.second.is_primitive_or_obj() &&
9292
rhs.second.datatype_->const_unwrap()->is_a_string() &&
9393
operator_token->type_ == token_type::EQ) {

compiler/test_data/compiler_tests/output/autocastboolcount.tokens

+16-16
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,24 @@
9393
["output.c",11,6,"\n","NEW_LINE"],
9494
["output.c",12,1," ","INDENT"],
9595
["output.c",12,9,"yy__a","NAME"],
96-
["output.c",12,14,"+=","PLUS_EQ"],
97-
["output.c",12,16,"(","PAREN_OPEN"],
98-
["output.c",12,17,"(","PAREN_OPEN"],
99-
["output.c",12,18,"int32_t","NAME"],
100-
["output.c",12,25,")","PAREN_CLOSE"],
101-
["output.c",12,26,"(","PAREN_OPEN"],
102-
["output.c",12,27,"(","PAREN_OPEN"],
96+
["output.c",12,15,"+=","PLUS_EQ"],
97+
["output.c",12,18,"(","PAREN_OPEN"],
98+
["output.c",12,19,"(","PAREN_OPEN"],
99+
["output.c",12,20,"int32_t","NAME"],
100+
["output.c",12,27,")","PAREN_CLOSE"],
103101
["output.c",12,28,"(","PAREN_OPEN"],
104-
["output.c",12,29,"yy__b","NAME"],
105-
["output.c",12,34,")","PAREN_CLOSE"],
106-
["output.c",12,38,"1","INTEGER_DECIMAL"],
107-
["output.c",12,40,":","COLON"],
108-
["output.c",12,42,"0","INTEGER_DECIMAL"],
109-
["output.c",12,43,")","PAREN_CLOSE"],
110-
["output.c",12,44,")","PAREN_CLOSE"],
102+
["output.c",12,29,"(","PAREN_OPEN"],
103+
["output.c",12,30,"(","PAREN_OPEN"],
104+
["output.c",12,31,"yy__b","NAME"],
105+
["output.c",12,36,")","PAREN_CLOSE"],
106+
["output.c",12,40,"1","INTEGER_DECIMAL"],
107+
["output.c",12,42,":","COLON"],
108+
["output.c",12,44,"0","INTEGER_DECIMAL"],
111109
["output.c",12,45,")","PAREN_CLOSE"],
112-
["output.c",12,46,";","SEMICOLON"],
113-
["output.c",12,47,"\n","NEW_LINE"],
110+
["output.c",12,46,")","PAREN_CLOSE"],
111+
["output.c",12,47,")","PAREN_CLOSE"],
112+
["output.c",12,48,";","SEMICOLON"],
113+
["output.c",12,49,"\n","NEW_LINE"],
114114
["output.c",13,1," ","INDENT"],
115115
["output.c",13,5,"}","CURLY_BRACKET_CLOSE"],
116116
["output.c",13,6,"\n","NEW_LINE"],

compiler/test_data/compiler_tests/output/autocastboolcount.yaka.output.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int32_t yy__main()
1010
bool yy__b = true;
1111
for (int32_t yy__x = INT32_C(0);(yy__x < INT32_C(10));yy__x = (yy__x + INT32_C(1)))
1212
{
13-
yy__a+=((int32_t)(((yy__b) ? 1 : 0)));
13+
yy__a += ((int32_t)(((yy__b) ? 1 : 0)));
1414
}
1515
yk__printlnint((intmax_t)yy__a);
1616
return INT32_C(0);

0 commit comments

Comments
 (0)