mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-27 16:01:47 -07:00
Fix enum type comparison; Start demo 003 code
This commit is contained in:
@@ -418,7 +418,7 @@ Entity *scope_insert_entity(Scope *s, Entity *entity) {
|
||||
|
||||
void check_scope_usage(Checker *c, Scope *scope) {
|
||||
// TODO(bill): Use this?
|
||||
#if 1
|
||||
#if 0
|
||||
gb_for_array(i, scope->elements.entries) {
|
||||
auto *entry = scope->elements.entries + i;
|
||||
Entity *e = entry->value;
|
||||
|
||||
@@ -599,12 +599,8 @@ b32 are_types_identical(Type *x, Type *y) {
|
||||
break;
|
||||
|
||||
case TypeRecord_Enum:
|
||||
if (are_types_identical(x->Record.enum_base, y->Record.enum_base)) {
|
||||
if (x->Record.field_count == y->Record.field_count) {
|
||||
return x->Record.fields == y->Record.fields;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
// NOTE(bill): Each enum is unique
|
||||
return x == y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1348,9 +1348,8 @@ isize ssa_type_info_index(CheckerInfo *info, Type *type) {
|
||||
}
|
||||
}
|
||||
if (entry_index < 0) {
|
||||
gb_printf_err("%s\n", type_to_string(type));
|
||||
compiler_error("Type_Info for `%s` could not be found", type_to_string(type));
|
||||
}
|
||||
GB_ASSERT(entry_index >= 0);
|
||||
return entry_index;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ i32 win32_exec_command_line_app(char *fmt, ...) {
|
||||
va_end(va);
|
||||
|
||||
if (CreateProcessA(NULL, cmd_line,
|
||||
NULL, NULL, true, 0, NULL, NULL,
|
||||
NULL, NULL, true, 0, NULL, NULL,
|
||||
&start_info, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
|
||||
|
||||
+25
-7
@@ -1499,7 +1499,14 @@ AstNode *parse_atom_expr(AstFile *f, b32 lhs) {
|
||||
|
||||
case Token_OpenBrace: {
|
||||
if (!lhs && is_literal_type(operand) && f->expr_level >= 0) {
|
||||
operand = parse_literal_value(f, operand);
|
||||
if (f->cursor[0].pos.line == f->cursor[-1].pos.line) {
|
||||
// TODO(bill): This is a hack due to optional semicolons
|
||||
// TODO(bill): It's probably much better to solve this by changing
|
||||
// the syntax for struct literals and array literals
|
||||
operand = parse_literal_value(f, operand);
|
||||
} else {
|
||||
loop = false;
|
||||
}
|
||||
} else {
|
||||
loop = false;
|
||||
}
|
||||
@@ -1553,13 +1560,24 @@ AstNode *parse_binary_expr(AstFile *f, b32 lhs, i32 prec_in) {
|
||||
|
||||
switch (op.kind) {
|
||||
case Token_DoublePrime: {
|
||||
// TODO(bill): Properly define semantic for in-fix and post-fix calls
|
||||
AstNode *proc = parse_identifier(f);
|
||||
AstNode *right = parse_binary_expr(f, false, prec+1);
|
||||
gbArray(AstNode *) args;
|
||||
gb_array_init_reserve(args, gb_arena_allocator(&f->arena), 2);
|
||||
gb_array_append(args, expression);
|
||||
gb_array_append(args, right);
|
||||
expression = make_call_expr(f, proc, args, op, ast_node_token(right), empty_token);
|
||||
/* if (f->cursor[0].kind == Token_OpenParen) {
|
||||
AstNode *call = parse_call_expr(f, proc);
|
||||
gb_array_append(call->CallExpr.args, expression);
|
||||
for (isize i = gb_array_count(call->CallExpr.args)-1; i > 0; i--) {
|
||||
gb_swap(AstNode *, call->CallExpr.args[i], call->CallExpr.args[i-1]);
|
||||
}
|
||||
|
||||
expression = call;
|
||||
} else */{
|
||||
AstNode *right = parse_binary_expr(f, false, prec+1);
|
||||
gbArray(AstNode *) args;
|
||||
gb_array_init_reserve(args, gb_arena_allocator(&f->arena), 2);
|
||||
gb_array_append(args, expression);
|
||||
gb_array_append(args, right);
|
||||
expression = make_call_expr(f, proc, args, op, ast_node_token(right), empty_token);
|
||||
}
|
||||
continue;
|
||||
} break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user