mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Remove derived from context; Fix parsing issue for typeid specializations in record parameters; Fix runtime printing of types
This commit is contained in:
@@ -1528,6 +1528,8 @@ parse_field_list :: proc(p: ^Parser, follow: token.Kind, allowed_flags: ast.Fiel
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_signature := (allowed_flags & Field_Flags_Signature_Params) == Field_Flags_Signature_Params;
|
||||||
|
|
||||||
any_polymorphic_names := check_procedure_name_list(p, names);
|
any_polymorphic_names := check_procedure_name_list(p, names);
|
||||||
set_flags = check_field_flag_prefixes(p, len(names), allowed_flags, set_flags);
|
set_flags = check_field_flag_prefixes(p, len(names), allowed_flags, set_flags);
|
||||||
|
|
||||||
@@ -1538,7 +1540,7 @@ parse_field_list :: proc(p: ^Parser, follow: token.Kind, allowed_flags: ast.Fiel
|
|||||||
if p.curr_tok.kind != token.Eq {
|
if p.curr_tok.kind != token.Eq {
|
||||||
type = parse_var_type(p, allowed_flags);
|
type = parse_var_type(p, allowed_flags);
|
||||||
tt := ast.unparen_expr(type);
|
tt := ast.unparen_expr(type);
|
||||||
if !any_polymorphic_names {
|
if is_signature && !any_polymorphic_names {
|
||||||
if ti, ok := tt.derived.(ast.Typeid_Type); ok && ti.specialization != nil {
|
if ti, ok := tt.derived.(ast.Typeid_Type); ok && ti.specialization != nil {
|
||||||
error(p, tt.pos, "specialization of typeid is not allowed without polymorphic names");
|
error(p, tt.pos, "specialization of typeid is not allowed without polymorphic names");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ Context :: struct {
|
|||||||
thread_id: int,
|
thread_id: int,
|
||||||
|
|
||||||
user_data: any,
|
user_data: any,
|
||||||
|
user_ptr: rawptr,
|
||||||
user_index: int,
|
user_index: int,
|
||||||
|
|
||||||
derived: any, // May be used for derived data types
|
derived: any, // May be used for derived data types
|
||||||
|
|||||||
+30
-26
@@ -223,6 +223,21 @@ print_type :: proc(fd: os.Handle, ti: ^Type_Info) {
|
|||||||
print_type(fd, info.underlying);
|
print_type(fd, info.underlying);
|
||||||
}
|
}
|
||||||
os.write_byte(fd, ']');
|
os.write_byte(fd, ']');
|
||||||
|
|
||||||
|
case Type_Info_Opaque:
|
||||||
|
os.write_string(fd, "opaque ");
|
||||||
|
print_type(fd, info.elem);
|
||||||
|
|
||||||
|
case Type_Info_Simd_Vector:
|
||||||
|
if info.is_x86_mmx {
|
||||||
|
os.write_string(fd, "intrinsics.x86_mmx");
|
||||||
|
} else {
|
||||||
|
os.write_string(fd, "intrinsics.vector(");
|
||||||
|
print_u64(fd, u64(info.count));
|
||||||
|
os.write_string(fd, ", ");
|
||||||
|
print_type(fd, info.elem);
|
||||||
|
os.write_byte(fd, ')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,38 +300,27 @@ bounds_check_error :: proc "contextless" (file: string, line, column: int, index
|
|||||||
handle_error(file, line, column, index, count);
|
handle_error(file, line, column, index, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slice_handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||||
|
fd := os.stderr;
|
||||||
|
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
||||||
|
os.write_string(fd, " Invalid slice indices: ");
|
||||||
|
print_i64(fd, i64(lo));
|
||||||
|
os.write_string(fd, ":");
|
||||||
|
print_i64(fd, i64(hi));
|
||||||
|
os.write_string(fd, ":");
|
||||||
|
print_i64(fd, i64(len));
|
||||||
|
os.write_byte(fd, '\n');
|
||||||
|
debug_trap();
|
||||||
|
}
|
||||||
|
|
||||||
slice_expr_error_hi :: proc "contextless" (file: string, line, column: int, hi: int, len: int) {
|
slice_expr_error_hi :: proc "contextless" (file: string, line, column: int, hi: int, len: int) {
|
||||||
if 0 <= hi && hi <= len do return;
|
if 0 <= hi && hi <= len do return;
|
||||||
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
slice_handle_error(file, line, column, 0, hi, len);
|
||||||
fd := os.stderr;
|
|
||||||
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
|
||||||
os.write_string(fd, " Invalid slice indices: ");
|
|
||||||
print_i64(fd, i64(lo));
|
|
||||||
os.write_string(fd, ":");
|
|
||||||
print_i64(fd, i64(hi));
|
|
||||||
os.write_string(fd, ":");
|
|
||||||
print_i64(fd, i64(len));
|
|
||||||
os.write_byte(fd, '\n');
|
|
||||||
debug_trap();
|
|
||||||
}
|
|
||||||
handle_error(file, line, column, 0, hi, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||||
if 0 <= lo && lo <= len && lo <= hi && hi <= len do return;
|
if 0 <= lo && lo <= len && lo <= hi && hi <= len do return;
|
||||||
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
slice_handle_error(file, line, column, lo, hi, len);
|
||||||
fd := os.stderr;
|
|
||||||
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
|
||||||
os.write_string(fd, " Invalid slice indices: ");
|
|
||||||
print_i64(fd, i64(lo));
|
|
||||||
os.write_string(fd, ":");
|
|
||||||
print_i64(fd, i64(hi));
|
|
||||||
os.write_string(fd, ":");
|
|
||||||
print_i64(fd, i64(len));
|
|
||||||
os.write_byte(fd, '\n');
|
|
||||||
debug_trap();
|
|
||||||
}
|
|
||||||
handle_error(file, line, column, lo, hi, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int, low, high, max: int) {
|
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int, low, high, max: int) {
|
||||||
|
|||||||
+3
-2
@@ -3024,6 +3024,7 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi
|
|||||||
isize total_name_count = 0;
|
isize total_name_count = 0;
|
||||||
bool allow_ellipsis = allowed_flags&FieldFlag_ellipsis;
|
bool allow_ellipsis = allowed_flags&FieldFlag_ellipsis;
|
||||||
bool seen_ellipsis = false;
|
bool seen_ellipsis = false;
|
||||||
|
bool is_signature = (allowed_flags & FieldFlag_Signature) == FieldFlag_Signature;
|
||||||
|
|
||||||
while (f->curr_token.kind != follow &&
|
while (f->curr_token.kind != follow &&
|
||||||
f->curr_token.kind != Token_Colon &&
|
f->curr_token.kind != Token_Colon &&
|
||||||
@@ -3064,7 +3065,7 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi
|
|||||||
if (f->curr_token.kind != Token_Eq) {
|
if (f->curr_token.kind != Token_Eq) {
|
||||||
type = parse_var_type(f, allow_ellipsis, allow_typeid_token);
|
type = parse_var_type(f, allow_ellipsis, allow_typeid_token);
|
||||||
Ast *tt = unparen_expr(type);
|
Ast *tt = unparen_expr(type);
|
||||||
if (!any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) {
|
if (is_signature && !any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) {
|
||||||
syntax_error(type, "Specialization of typeid is not allowed without polymorphic names");
|
syntax_error(type, "Specialization of typeid is not allowed without polymorphic names");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3121,7 +3122,7 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi
|
|||||||
if (f->curr_token.kind != Token_Eq) {
|
if (f->curr_token.kind != Token_Eq) {
|
||||||
type = parse_var_type(f, allow_ellipsis, allow_typeid_token);
|
type = parse_var_type(f, allow_ellipsis, allow_typeid_token);
|
||||||
Ast *tt = unparen_expr(type);
|
Ast *tt = unparen_expr(type);
|
||||||
if (!any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) {
|
if (is_signature && !any_polymorphic_names && tt->kind == Ast_TypeidType && tt->TypeidType.specialization != nullptr) {
|
||||||
syntax_error(type, "Specialization of typeid is not allowed without polymorphic names");
|
syntax_error(type, "Specialization of typeid is not allowed without polymorphic names");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user