Fix constant typeid comparisons. Allow methods to use & and * and constants. Improved error messages. Updated String type with generic append.

This commit is contained in:
Christoffer Lerno
2022-07-23 23:08:27 +02:00
committed by Christoffer Lerno
parent c1de3f059e
commit 7e0a29ef40
11 changed files with 117 additions and 50 deletions

View File

@@ -102,7 +102,8 @@ bool expr_const_compare(const ExprConst *left, const ExprConst *right, BinaryOp
is_eq = !strncmp(left->string.chars, right->string.chars, left->string.len);
break;
case CONST_TYPEID:
return left->typeid == right->typeid;
is_eq = left->typeid == right->typeid;
break;
case CONST_ERR:
case CONST_ENUM:
{
@@ -151,6 +152,15 @@ bool expr_const_compare(const ExprConst *left, const ExprConst *right, BinaryOp
return (op == BINARYOP_EQ) && is_eq;
}
bool expr_const_in_range(const ExprConst *left, const ExprConst *right, const ExprConst *right_to)
{
if (right == right_to)
{
return expr_const_compare(left, right, BINARYOP_EQ);
}
return expr_const_compare(left, right, BINARYOP_GE) && expr_const_compare(left, right_to, BINARYOP_LE);
}
bool float_const_fits_type(const ExprConst *expr_const, TypeKind kind)
{
Real hi_limit;