mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Merge branch 'master' of https://github.com/gingerBill/Odin
This commit is contained in:
+3
-3
@@ -4619,10 +4619,10 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h
|
|||||||
|
|
||||||
bool implicit_is_found = is_entity_implicitly_imported(e, entity);
|
bool implicit_is_found = is_entity_implicitly_imported(e, entity);
|
||||||
bool is_not_exported = !is_entity_exported(entity);
|
bool is_not_exported = !is_entity_exported(entity);
|
||||||
if (!implicit_is_found) {
|
if (entity->kind == Entity_ImportName) {
|
||||||
is_not_exported = false;
|
|
||||||
} else if (entity->kind == Entity_ImportName) {
|
|
||||||
is_not_exported = true;
|
is_not_exported = true;
|
||||||
|
} else if (!implicit_is_found) {
|
||||||
|
is_not_exported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_not_exported) {
|
if (is_not_exported) {
|
||||||
|
|||||||
+2
-1
@@ -1734,7 +1734,8 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
|
|||||||
DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
|
DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
|
||||||
Entity *e = nullptr;
|
Entity *e = nullptr;
|
||||||
|
|
||||||
if (is_ast_node_type(init)) {
|
if (is_ast_node_type(init) ||
|
||||||
|
(vd->type != nullptr && vd->type->kind == AstNode_TypeType)) {
|
||||||
e = make_entity_type_name(c->allocator, d->scope, token, nullptr);
|
e = make_entity_type_name(c->allocator, d->scope, token, nullptr);
|
||||||
if (vd->type != nullptr) {
|
if (vd->type != nullptr) {
|
||||||
error(name, "A type declaration cannot have an type parameter");
|
error(name, "A type declaration cannot have an type parameter");
|
||||||
|
|||||||
+2
-3
@@ -6370,9 +6370,8 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
|
|||||||
case_ast_node(ds, DeferStmt, node);
|
case_ast_node(ds, DeferStmt, node);
|
||||||
ir_emit_comment(proc, str_lit("DeferStmt"));
|
ir_emit_comment(proc, str_lit("DeferStmt"));
|
||||||
isize scope_index = proc->scope_index;
|
isize scope_index = proc->scope_index;
|
||||||
if (ds->stmt->kind == AstNode_BlockStmt) {
|
// TODO(bill): What was the original rationale behind this line?
|
||||||
scope_index--;
|
// if (ds->stmt->kind == AstNode_BlockStmt) scope_index--;
|
||||||
}
|
|
||||||
ir_add_defer_node(proc, scope_index, ds->stmt);
|
ir_add_defer_node(proc, scope_index, ds->stmt);
|
||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -183,10 +183,9 @@ void ir_print_proc_type_without_pointer(irFileBuffer *f, irModule *m, Type *t) {
|
|||||||
ir_fprintf(f, " (");
|
ir_fprintf(f, " (");
|
||||||
if (t->Proc.return_by_pointer) {
|
if (t->Proc.return_by_pointer) {
|
||||||
ir_print_type(f, m, reduce_tuple_to_single_type(t->Proc.results));
|
ir_print_type(f, m, reduce_tuple_to_single_type(t->Proc.results));
|
||||||
ir_fprintf(f, "* sret noalias ");
|
// ir_fprintf(f, "* sret noalias ");
|
||||||
if (param_count > 0) {
|
ir_fprintf(f, "* noalias ");
|
||||||
ir_fprintf(f, ", ");
|
if (param_count > 0) ir_fprintf(f, ", ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
isize param_index = 0;
|
isize param_index = 0;
|
||||||
for (isize i = 0; i < param_count; i++) {
|
for (isize i = 0; i < param_count; i++) {
|
||||||
@@ -247,10 +246,14 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
|
|||||||
case Basic_any: ir_fprintf(f, "%%..any"); return;
|
case Basic_any: ir_fprintf(f, "%%..any"); return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type_Pointer:
|
case Type_Pointer: {
|
||||||
ir_print_type(f, m, t->Pointer.elem);
|
if (!is_type_named(t->Pointer.elem) && is_type_empty_struct(t->Pointer.elem)) {
|
||||||
ir_fprintf(f, "*");
|
ir_print_type(f, m, t_rawptr);
|
||||||
return;
|
} else {
|
||||||
|
ir_print_type(f, m, t->Pointer.elem);
|
||||||
|
ir_fprintf(f, "*");
|
||||||
|
}
|
||||||
|
} return;
|
||||||
case Type_Array:
|
case Type_Array:
|
||||||
ir_fprintf(f, "[%lld x ", t->Array.count);
|
ir_fprintf(f, "[%lld x ", t->Array.count);
|
||||||
ir_print_type(f, m, t->Array.elem);
|
ir_print_type(f, m, t->Array.elem);
|
||||||
@@ -333,12 +336,16 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
|
|||||||
|
|
||||||
|
|
||||||
case Type_Named:
|
case Type_Named:
|
||||||
if (is_type_struct(t) || is_type_union(t)) {
|
switch (base_type(t)->kind) {
|
||||||
|
case Type_Struct:
|
||||||
|
case Type_Union: {
|
||||||
String *name = map_get(&m->entity_names, hash_pointer(t->Named.type_name));
|
String *name = map_get(&m->entity_names, hash_pointer(t->Named.type_name));
|
||||||
GB_ASSERT_MSG(name != nullptr, "%.*s %p", LIT(t->Named.name), t->Named.type_name);
|
GB_ASSERT_MSG(name != nullptr, "%.*s %p", LIT(t->Named.name), t->Named.type_name);
|
||||||
ir_print_encoded_local(f, *name);
|
ir_print_encoded_local(f, *name);
|
||||||
} else {
|
} break;
|
||||||
|
default:
|
||||||
ir_print_type(f, m, base_type(t));
|
ir_print_type(f, m, base_type(t));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case Type_Tuple:
|
case Type_Tuple:
|
||||||
@@ -1718,9 +1725,6 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) {
|
|||||||
void ir_print_type_name(irFileBuffer *f, irModule *m, irValue *v) {
|
void ir_print_type_name(irFileBuffer *f, irModule *m, irValue *v) {
|
||||||
GB_ASSERT(v->kind == irValue_TypeName);
|
GB_ASSERT(v->kind == irValue_TypeName);
|
||||||
Type *bt = base_type(ir_type(v));
|
Type *bt = base_type(ir_type(v));
|
||||||
if (!is_type_struct(bt) && !is_type_union(bt)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ir_print_encoded_local(f, v->TypeName.name);
|
ir_print_encoded_local(f, v->TypeName.name);
|
||||||
ir_fprintf(f, " = type ");
|
ir_fprintf(f, " = type ");
|
||||||
ir_print_type(f, m, base_type(v->TypeName.type));
|
ir_print_type(f, m, base_type(v->TypeName.type));
|
||||||
|
|||||||
+13
-3
@@ -3250,12 +3250,22 @@ AstNode *parse_value_decl(AstFile *f, Array<AstNode *> names, CommentGroup docs)
|
|||||||
Array<AstNode *> values = {};
|
Array<AstNode *> values = {};
|
||||||
|
|
||||||
Token colon = expect_token_after(f, Token_Colon, "identifier list");
|
Token colon = expect_token_after(f, Token_Colon, "identifier list");
|
||||||
type = parse_type_attempt(f);
|
if (f->curr_token.kind == Token_type) {
|
||||||
|
type = ast_type_type(f, advance_token(f), nullptr);
|
||||||
|
is_mutable = false;
|
||||||
|
} else {
|
||||||
|
type = parse_type_attempt(f);
|
||||||
|
}
|
||||||
|
|
||||||
if (f->curr_token.kind == Token_Eq ||
|
if (f->curr_token.kind == Token_Eq ||
|
||||||
f->curr_token.kind == Token_Colon) {
|
f->curr_token.kind == Token_Colon) {
|
||||||
Token sep = advance_token(f);
|
Token sep = {};
|
||||||
is_mutable = sep.kind != Token_Colon;
|
if (!is_mutable) {
|
||||||
|
sep = expect_token_after(f, Token_Colon, "type");
|
||||||
|
} else {
|
||||||
|
sep = advance_token(f);
|
||||||
|
is_mutable = sep.kind != Token_Colon;
|
||||||
|
}
|
||||||
values = parse_rhs_expr_list(f);
|
values = parse_rhs_expr_list(f);
|
||||||
if (values.count > names.count) {
|
if (values.count > names.count) {
|
||||||
syntax_error(f->curr_token, "Too many values on the right hand side of the declaration");
|
syntax_error(f->curr_token, "Too many values on the right hand side of the declaration");
|
||||||
|
|||||||
@@ -881,6 +881,10 @@ bool is_type_empty_union(Type *t) {
|
|||||||
t = base_type(t);
|
t = base_type(t);
|
||||||
return t->kind == Type_Union && t->Union.variants.count == 0;
|
return t->kind == Type_Union && t->Union.variants.count == 0;
|
||||||
}
|
}
|
||||||
|
bool is_type_empty_struct(Type *t) {
|
||||||
|
t = base_type(t);
|
||||||
|
return t->kind == Type_Struct && !t->Struct.is_raw_union && t->Struct.fields.count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_type_valid_for_keys(Type *t) {
|
bool is_type_valid_for_keys(Type *t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user