mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Add unselector_expr
This commit is contained in:
+1
-4
@@ -1353,10 +1353,7 @@ void check_is_expressible(Checker *c, Operand *o, Type *type) {
|
|||||||
|
|
||||||
bool check_is_not_addressable(Checker *c, Operand *o) {
|
bool check_is_not_addressable(Checker *c, Operand *o) {
|
||||||
if (o->mode == Addressing_OptionalOk) {
|
if (o->mode == Addressing_OptionalOk) {
|
||||||
AstNode *expr = unparen_expr(o->expr);
|
AstNode *expr = unselector_expr(o->expr);
|
||||||
while (expr->kind == AstNode_SelectorExpr) {
|
|
||||||
expr = expr->SelectorExpr.selector;
|
|
||||||
}
|
|
||||||
if (expr->kind != AstNode_TypeAssertion) {
|
if (expr->kind != AstNode_TypeAssertion) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -714,10 +714,7 @@ Entity *entity_of_node(CheckerInfo *i, AstNode *expr) {
|
|||||||
return entity_of_ident(i, expr);
|
return entity_of_ident(i, expr);
|
||||||
case_end;
|
case_end;
|
||||||
case_ast_node(se, SelectorExpr, expr);
|
case_ast_node(se, SelectorExpr, expr);
|
||||||
AstNode *s = se->selector;
|
AstNode *s = unselector_expr(se->selector);
|
||||||
while (s->kind == AstNode_SelectorExpr) {
|
|
||||||
s = s->SelectorExpr.selector;
|
|
||||||
}
|
|
||||||
if (s->kind == AstNode_Ident) {
|
if (s->kind == AstNode_Ident) {
|
||||||
return entity_of_ident(i, s);
|
return entity_of_ident(i, s);
|
||||||
}
|
}
|
||||||
@@ -3113,10 +3110,10 @@ void check_parsed_files(Checker *c) {
|
|||||||
|
|
||||||
TIME_SECTION("add type information");
|
TIME_SECTION("add type information");
|
||||||
// Add "Basic" type information
|
// Add "Basic" type information
|
||||||
for (isize i = 0; i < gb_count_of(basic_types)-1; i++) {
|
for (isize i = 0; i < Basic_COUNT; i++) {
|
||||||
Type *t = &basic_types[i];
|
Type *t = &basic_types[i];
|
||||||
if (t->Basic.size > 0 &&
|
if (t->Basic.size > 0 &&
|
||||||
t->Basic.kind != Basic_llvm_bool) {
|
(t->Basic.flags & BasicFlag_LLVM) == 0) {
|
||||||
add_type_info_type(c, t);
|
add_type_info_type(c, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3133,7 +3130,7 @@ void check_parsed_files(Checker *c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_SECTION("check entry poiny");
|
TIME_SECTION("check entry point");
|
||||||
if (!build_context.is_dll) {
|
if (!build_context.is_dll) {
|
||||||
Scope *s = c->info.init_scope;
|
Scope *s = c->info.init_scope;
|
||||||
GB_ASSERT(s != nullptr);
|
GB_ASSERT(s != nullptr);
|
||||||
|
|||||||
+2
-5
@@ -30,11 +30,8 @@ struct TypeAndValue {
|
|||||||
|
|
||||||
|
|
||||||
// ExprInfo stores information used for "untyped" expressions
|
// ExprInfo stores information used for "untyped" expressions
|
||||||
struct ExprInfo {
|
struct ExprInfo : TypeAndValue {
|
||||||
AddressingMode mode;
|
bool is_lhs; // Debug info
|
||||||
Type * type; // Type_Basic
|
|
||||||
ExactValue value;
|
|
||||||
bool is_lhs; // Debug info
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gb_inline ExprInfo make_expr_info(AddressingMode mode, Type *type, ExactValue value, bool is_lhs) {
|
gb_inline ExprInfo make_expr_info(AddressingMode mode, Type *type, ExactValue value, bool is_lhs) {
|
||||||
|
|||||||
+2
-5
@@ -4164,11 +4164,8 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
|
|||||||
String procedure = proc->entity->token.string;
|
String procedure = proc->entity->token.string;
|
||||||
TokenPos pos = ast_node_token(ce->proc).pos;
|
TokenPos pos = ast_node_token(ce->proc).pos;
|
||||||
if (ce->args.count > 0) {
|
if (ce->args.count > 0) {
|
||||||
AstNode *ident = ce->args[0];;
|
AstNode *ident = unselector_expr(ce->args[0]);
|
||||||
|
GB_ASSERT(ident->kind == AstNode_Ident);
|
||||||
while (ident->kind == AstNode_SelectorExpr) {
|
|
||||||
ident = ident->SelectorExpr.selector;
|
|
||||||
}
|
|
||||||
Entity *e = entity_of_ident(proc->module->info, ident);
|
Entity *e = entity_of_ident(proc->module->info, ident);
|
||||||
GB_ASSERT(e != nullptr);
|
GB_ASSERT(e != nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -1410,6 +1410,17 @@ AstNode *unparen_expr(AstNode *node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AstNode *unselector_expr(AstNode *node) {
|
||||||
|
node = unparen_expr(node);
|
||||||
|
if (node == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
while (node->kind == AstNode_SelectorExpr) {
|
||||||
|
node = node->SelectorExpr.selector;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
AstNode *parse_value(AstFile *f);
|
AstNode *parse_value(AstFile *f);
|
||||||
|
|
||||||
Array<AstNode *> parse_element_list(AstFile *f) {
|
Array<AstNode *> parse_element_list(AstFile *f) {
|
||||||
|
|||||||
+3
-1
@@ -63,6 +63,8 @@ enum BasicFlag {
|
|||||||
BasicFlag_Rune = GB_BIT(7),
|
BasicFlag_Rune = GB_BIT(7),
|
||||||
BasicFlag_Untyped = GB_BIT(8),
|
BasicFlag_Untyped = GB_BIT(8),
|
||||||
|
|
||||||
|
BasicFlag_LLVM = GB_BIT(10),
|
||||||
|
|
||||||
BasicFlag_Numeric = BasicFlag_Integer | BasicFlag_Float | BasicFlag_Complex,
|
BasicFlag_Numeric = BasicFlag_Integer | BasicFlag_Float | BasicFlag_Complex,
|
||||||
BasicFlag_Ordered = BasicFlag_Integer | BasicFlag_Float | BasicFlag_String | BasicFlag_Pointer | BasicFlag_Rune,
|
BasicFlag_Ordered = BasicFlag_Integer | BasicFlag_Float | BasicFlag_String | BasicFlag_Pointer | BasicFlag_Rune,
|
||||||
BasicFlag_ConstantType = BasicFlag_Boolean | BasicFlag_Numeric | BasicFlag_String | BasicFlag_Pointer | BasicFlag_Rune,
|
BasicFlag_ConstantType = BasicFlag_Boolean | BasicFlag_Numeric | BasicFlag_String | BasicFlag_Pointer | BasicFlag_Rune,
|
||||||
@@ -244,7 +246,7 @@ void selection_add_index(Selection *s, isize index) {
|
|||||||
gb_global Type basic_types[] = {
|
gb_global Type basic_types[] = {
|
||||||
{Type_Basic, {Basic_Invalid, 0, 0, STR_LIT("invalid type")}},
|
{Type_Basic, {Basic_Invalid, 0, 0, STR_LIT("invalid type")}},
|
||||||
|
|
||||||
{Type_Basic, {Basic_llvm_bool, BasicFlag_Boolean, 1, STR_LIT("llvm bool")}},
|
{Type_Basic, {Basic_llvm_bool, BasicFlag_Boolean | BasicFlag_LLVM, 1, STR_LIT("llvm bool")}},
|
||||||
|
|
||||||
{Type_Basic, {Basic_bool, BasicFlag_Boolean, 1, STR_LIT("bool")}},
|
{Type_Basic, {Basic_bool, BasicFlag_Boolean, 1, STR_LIT("bool")}},
|
||||||
{Type_Basic, {Basic_b8, BasicFlag_Boolean, 1, STR_LIT("b8")}},
|
{Type_Basic, {Basic_b8, BasicFlag_Boolean, 1, STR_LIT("b8")}},
|
||||||
|
|||||||
Reference in New Issue
Block a user