mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
#rune "" to ''; Remove infix and postfix call notation
This commit is contained in:
+13
-5
@@ -271,8 +271,9 @@ CycleChecker *cycle_checker_add(CycleChecker *cc, Entity *e) {
|
||||
if (cc->path.e == NULL) {
|
||||
array_init(&cc->path, heap_allocator());
|
||||
}
|
||||
GB_ASSERT(e != NULL && e->kind == Entity_TypeName);
|
||||
array_add(&cc->path, e);
|
||||
if (e != NULL && e->kind == Entity_TypeName) {
|
||||
array_add(&cc->path, e);
|
||||
}
|
||||
return cc;
|
||||
}
|
||||
|
||||
@@ -508,6 +509,11 @@ void add_global_constant(gbAllocator a, String name, Type *type, ExactValue valu
|
||||
}
|
||||
|
||||
|
||||
void add_global_string_constant(gbAllocator a, String name, String value) {
|
||||
add_global_constant(a, name, t_untyped_string, make_exact_value_string(value));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_universal_scope(void) {
|
||||
// NOTE(bill): No need to free these
|
||||
@@ -528,9 +534,11 @@ void init_universal_scope(void) {
|
||||
|
||||
add_global_entity(make_entity_nil(a, str_lit("nil"), t_untyped_nil));
|
||||
|
||||
add_global_constant(a, str_lit("ODIN_OS"), t_untyped_string, make_exact_value_string(str_lit("windows")));
|
||||
add_global_constant(a, str_lit("ODIN_ARCH"), t_untyped_string, make_exact_value_string(str_lit("amd64")));
|
||||
add_global_constant(a, str_lit("ODIN_VERSION"), t_untyped_string, make_exact_value_string(str_lit(VERSION_STRING)));
|
||||
add_global_string_constant(a, str_lit("ODIN_OS"), str_lit("windows"));
|
||||
add_global_string_constant(a, str_lit("ODIN_ARCH"), str_lit("amd64"));
|
||||
add_global_string_constant(a, str_lit("ODIN_VENDOR"), str_lit("odin"));
|
||||
add_global_string_constant(a, str_lit("ODIN_VERSION"), str_lit(VERSION_STRING));
|
||||
add_global_string_constant(a, str_lit("ODIN_ENDIAN"), str_lit("little"));
|
||||
|
||||
|
||||
// Builtin Procedures
|
||||
|
||||
+14
-18
@@ -713,12 +713,10 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
|
||||
if (o.mode != Addressing_Invalid) {
|
||||
iota = o.value;
|
||||
} else {
|
||||
Token add_token = {Token_Add};
|
||||
iota = exact_binary_operator_value(add_token, iota, make_exact_value_integer(1));
|
||||
iota = exact_binary_operator_value(Token_Add, iota, make_exact_value_integer(1));
|
||||
}
|
||||
} else {
|
||||
Token add_token = {Token_Add};
|
||||
iota = exact_binary_operator_value(add_token, iota, make_exact_value_integer(1));
|
||||
iota = exact_binary_operator_value(Token_Add, iota, make_exact_value_integer(1));
|
||||
}
|
||||
|
||||
|
||||
@@ -1492,7 +1490,7 @@ void check_unary_expr(Checker *c, Operand *o, Token op, AstNode *node) {
|
||||
if (is_type_unsigned(type)) {
|
||||
precision = cast(i32)(8 * type_size_of(c->sizes, c->allocator, type));
|
||||
}
|
||||
o->value = exact_unary_operator_value(op, o->value, precision);
|
||||
o->value = exact_unary_operator_value(op.kind, o->value, precision);
|
||||
|
||||
if (is_type_typed(type)) {
|
||||
if (node != NULL) {
|
||||
@@ -1558,7 +1556,7 @@ void check_comparison(Checker *c, Operand *x, Operand *y, Token op) {
|
||||
} else {
|
||||
if (x->mode == Addressing_Constant &&
|
||||
y->mode == Addressing_Constant) {
|
||||
x->value = make_exact_value_bool(compare_exact_values(op, x->value, y->value));
|
||||
x->value = make_exact_value_bool(compare_exact_values(op.kind, x->value, y->value));
|
||||
} else {
|
||||
x->mode = Addressing_Value;
|
||||
|
||||
@@ -1645,7 +1643,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) {
|
||||
x->type = t_untyped_integer;
|
||||
}
|
||||
|
||||
x->value = exact_value_shift(be->op, x_val, make_exact_value_integer(amount));
|
||||
x->value = exact_value_shift(be->op.kind, x_val, make_exact_value_integer(amount));
|
||||
|
||||
if (is_type_typed(x->type)) {
|
||||
check_is_expressible(c, x, base_type(x->type));
|
||||
@@ -2168,7 +2166,7 @@ void check_binary_expr(Checker *c, Operand *x, AstNode *node) {
|
||||
if (op.kind == Token_Quo && is_type_integer(type)) {
|
||||
op.kind = Token_QuoEq; // NOTE(bill): Hack to get division of integers
|
||||
}
|
||||
x->value = exact_binary_operator_value(op, a, b);
|
||||
x->value = exact_binary_operator_value(op.kind, a, b);
|
||||
if (is_type_typed(type)) {
|
||||
if (node != NULL) {
|
||||
x->expr = node;
|
||||
@@ -3166,7 +3164,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
case BuiltinProc_min: {
|
||||
// min :: proc(a, b: comparable) -> comparable
|
||||
Type *type = base_type(operand->type);
|
||||
if (!is_type_comparable(type) || !is_type_numeric(type)) {
|
||||
if (!is_type_comparable(type) || !(is_type_numeric(type) || is_type_string(type))) {
|
||||
gbString type_str = type_to_string(operand->type);
|
||||
error(ast_node_token(call),
|
||||
"Expected a comparable numeric type to `min`, got `%s`",
|
||||
@@ -3182,7 +3180,7 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
if (b.mode == Addressing_Invalid) {
|
||||
return false;
|
||||
}
|
||||
if (!is_type_comparable(b.type) || !is_type_numeric(type)) {
|
||||
if (!is_type_comparable(b.type) || !(is_type_numeric(b.type) || is_type_string(b.type))) {
|
||||
gbString type_str = type_to_string(b.type);
|
||||
error(ast_node_token(call),
|
||||
"Expected a comparable numeric type to `min`, got `%s`",
|
||||
@@ -3195,10 +3193,9 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
b.mode == Addressing_Constant) {
|
||||
ExactValue x = a.value;
|
||||
ExactValue y = b.value;
|
||||
Token lt = {Token_Lt};
|
||||
|
||||
operand->mode = Addressing_Constant;
|
||||
if (compare_exact_values(lt, x, y)) {
|
||||
if (compare_exact_values(Token_Lt, x, y)) {
|
||||
operand->value = x;
|
||||
operand->type = a.type;
|
||||
} else {
|
||||
@@ -3235,10 +3232,10 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
case BuiltinProc_max: {
|
||||
// min :: proc(a, b: comparable) -> comparable
|
||||
Type *type = base_type(operand->type);
|
||||
if (!is_type_comparable(type) || !is_type_numeric(type)) {
|
||||
if (!is_type_comparable(type) || !(is_type_numeric(type) || is_type_string(type))) {
|
||||
gbString type_str = type_to_string(operand->type);
|
||||
error(ast_node_token(call),
|
||||
"Expected a comparable numeric type to `max`, got `%s`",
|
||||
"Expected a comparable numeric or string type to `max`, got `%s`",
|
||||
type_str);
|
||||
gb_string_free(type_str);
|
||||
return false;
|
||||
@@ -3251,10 +3248,10 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
if (b.mode == Addressing_Invalid) {
|
||||
return false;
|
||||
}
|
||||
if (!is_type_comparable(b.type) || !is_type_numeric(type)) {
|
||||
if (!is_type_comparable(b.type) || !(is_type_numeric(type) || is_type_string(type))) {
|
||||
gbString type_str = type_to_string(b.type);
|
||||
error(ast_node_token(call),
|
||||
"Expected a comparable numeric type to `max`, got `%s`",
|
||||
"Expected a comparable numeric or string type to `max`, got `%s`",
|
||||
type_str);
|
||||
gb_string_free(type_str);
|
||||
return false;
|
||||
@@ -3264,10 +3261,9 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
|
||||
b.mode == Addressing_Constant) {
|
||||
ExactValue x = a.value;
|
||||
ExactValue y = b.value;
|
||||
Token gt = {Token_Gt};
|
||||
|
||||
operand->mode = Addressing_Constant;
|
||||
if (compare_exact_values(gt, x, y)) {
|
||||
if (compare_exact_values(Token_Gt, x, y)) {
|
||||
operand->value = x;
|
||||
operand->type = a.type;
|
||||
} else {
|
||||
|
||||
+2
-1
@@ -683,7 +683,8 @@ bool is_type_comparable(Type *t) {
|
||||
return false;
|
||||
} break;
|
||||
case Type_Array:
|
||||
return is_type_comparable(t->Array.elem);
|
||||
return false;
|
||||
// return is_type_comparable(t->Array.elem);
|
||||
case Type_Vector:
|
||||
return is_type_comparable(t->Vector.elem);
|
||||
case Type_Proc:
|
||||
|
||||
Reference in New Issue
Block a user