From: Brendan Hansen Date: Tue, 12 Jan 2021 16:49:40 +0000 (-0600) Subject: polymorphic variables on compound types X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ec9e64bee16c4c82a322d8d53abf1cb34a9a94d3;p=onyx.git polymorphic variables on compound types --- diff --git a/bin/onyx b/bin/onyx index 795bdb46..4d6e3d91 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/misc/onyx.sublime-syntax b/misc/onyx.sublime-syntax index 70ab1624..0a1a7578 100644 --- a/misc/onyx.sublime-syntax +++ b/misc/onyx.sublime-syntax @@ -67,9 +67,10 @@ contexts: captures: 1: meta.function-call.onyx - - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*:' + - match: '([a-zA-Z_][a-zA-Z0-9_]*)(,\s*([a-zA-Z_][a-zA-Z0-9_]*))*\s*:' captures: 1: variable + 2: variable double_quoted_string: - meta_scope: string.quoted.double.onyx diff --git a/onyx.exe b/onyx.exe index d254d18e..56839afc 100644 Binary files a/onyx.exe and b/onyx.exe differ diff --git a/src/onyxutils.c b/src/onyxutils.c index efd2a486..2fca21dd 100644 --- a/src/onyxutils.c +++ b/src/onyxutils.c @@ -320,6 +320,23 @@ static PolySolveResult solve_poly_type(AstNode* target, AstType* type_expr, Type break; } + case Ast_Kind_Type_Compound: { + if (elem.actual->kind != Type_Kind_Compound) break; + if (bh_arr_length(elem.actual->Compound.types) != bh_arr_length(((AstCompoundType *) elem.type_expr)->types)) break; + + AstCompoundType* ct = (AstCompoundType *) elem.type_expr; + + fori (i, 0, bh_arr_length(ct->types)) { + bh_arr_push(elem_queue, ((PolySolveElem) { + .kind = PSK_Type, + .type_expr = ct->types[i], + .actual = elem.actual->Compound.types[i], + })); + } + + break; + } + default: break; } }