]> Nishi Git Mirror - gwion.git/commitdiff
:art: Add Regex and other goodies
authorJérémie Astor <fennecdjay@gmail.com>
Thu, 28 Apr 2022 21:29:46 +0000 (23:29 +0200)
committerJérémie Astor <fennecdjay@gmail.com>
Thu, 28 Apr 2022 21:29:46 +0000 (23:29 +0200)
plug
src/import/import_cdef.c
src/lib/lib_func.c
src/parse/check.c
src/parse/template.c

diff --git a/plug b/plug
index 104ccd7458a57dc23c3fc1fb67782c692706ec40..bdadd7a53df9a8a6e618859ed4bb38afda0a3789 160000 (submodule)
--- a/plug
+++ b/plug
@@ -1 +1 @@
-Subproject commit 104ccd7458a57dc23c3fc1fb67782c692706ec40
+Subproject commit bdadd7a53df9a8a6e618859ed4bb38afda0a3789
index 0133f0ac5c7423231db21e1499e6f0291ea9fc45..82019c569aa24aa4c38e9f4e9f21b545842c04ea 100644 (file)
@@ -106,6 +106,7 @@ ANN Type gwi_struct_ini(const Gwi gwi, const m_str name) {
   CHECK_BO(check_typename_def(gwi, &ck));
   const Type t =
       new_type(gwi->gwion->mp, s_name(ck.sym), gwi->gwion->type[et_compound]);
+  t->size = 0;
   set_tflag(t, tflag_struct);
   if (!ck.sl)
     gwi_type_flag(t);
index c0f6eaab655ebbc3f1d11fca880cb3f25456b104..f4ffbc0fb7b711b6c71a31c1d941c4927f3d7664 100644 (file)
@@ -12,6 +12,7 @@
 #include "traverse.h"
 #include "template.h"
 #include "parse.h"
+#include "partial.h"
 
 static OP_CHECK(opck_func_call) {
   Exp_Binary *bin  = (Exp_Binary *)data;
@@ -712,6 +713,20 @@ static OP_EMIT(opem_spork) {
   return emit_exp_spork(emit, unary);
 }
 
+static OP_CHECK(opck_func_partial) {
+  Exp_Call *call = (Exp_Call*)data;
+  return partial_type(env, call);
+}
+
+static OP_CHECK(opck_class_partial) {
+  Exp_Call *call = (Exp_Call*)data;
+  struct Op_Import opi = {.op   = insert_symbol("@partial"),
+                          .lhs  = actual_type(env->gwion, call->func->type),
+                          .pos  = call->func->pos,
+                          .data = (uintptr_t)data};
+   return op_check(env, &opi);
+}
+
 static FREEARG(freearg_xork) { vmcode_remref((VM_Code)instr->m_val, gwion); }
 
 static FREEARG(freearg_dottmpl) {
@@ -750,6 +765,12 @@ GWION_IMPORT(func) {
   GWI_BB(gwi_oper_ini(gwi, "@function", "@function", NULL))
   GWI_BB(gwi_oper_add(gwi, opck_auto_fptr))
   GWI_BB(gwi_oper_end(gwi, "@=>", int_r_assign))
+  GWI_BB(gwi_oper_ini(gwi, "@function", NULL, NULL))
+  GWI_BB(gwi_oper_add(gwi, opck_func_partial))
+  GWI_BB(gwi_oper_end(gwi, "@partial", NULL))
+  GWI_BB(gwi_oper_ini(gwi, "Class", NULL, NULL))
+  GWI_BB(gwi_oper_add(gwi, opck_class_partial))
+  GWI_BB(gwi_oper_end(gwi, "@partial", NULL))
   gwi_register_freearg(gwi, SporkIni, freearg_xork);
   gwi_register_freearg(gwi, DotTmpl, freearg_dottmpl);
   return GW_OK;
index 4bfef633a4c40503deb0e3cfdba21b2df30cff7b..9c07fb5380a2a2c0d4cd048af78a99ad316e3e42 100644 (file)
@@ -988,7 +988,11 @@ ANN static Type check_exp_call_tmpl(const Env env, Exp_Call *exp, const Type t)
 ANN static Type check_exp_call(const Env env, Exp_Call *exp) {
   if (is_partial(env, exp->args)) {
     CHECK_OO(check_exp(env, exp->func));
-    return partial_type(env, exp);
+    struct Op_Import opi = {.op   = insert_symbol("@partial"),
+                            .lhs  = exp->func->type,
+                            .pos  = exp->func->pos,
+                            .data = (uintptr_t)exp};
+    return op_check(env, &opi);
   }
   if (exp->tmpl) {
     DECL_BO(const m_bool, ret, = func_check(env, exp));
index 7b5677ccd4d536cfe302623f75766f7fd2c40696..4052bec8a5f71d52459e4840adfe5a7aff8cfed3 100644 (file)
@@ -134,14 +134,15 @@ ANN static Type _scan_type(const Env env, const Type t, Type_Decl *td) {
     for(uint32_t i = 0; i < tl->len; i++) {
       Type_Decl *tmp = *mp_vector_at(tl, Type_Decl*, i);
       DECL_OO(const Type, t, = known_type(env, tmp));
-        Specialized *spec = mp_vector_at(sl, Specialized, i);
-        if(spec->traits) {
-          Symbol missing = miss_traits(t, spec);
-          if (missing) {
-            ERR_O(td->pos, "does not implement requested trait '{/}%s{0}'",
-                  s_name(missing));
-          }
+      if(!sl) continue;
+      Specialized *spec = mp_vector_at(sl, Specialized, i);
+      if(spec->traits) {
+        Symbol missing = miss_traits(t, spec);
+        if (missing) {
+          ERR_O(td->pos, "does not implement requested trait '{/}%s{0}'",
+                s_name(missing));
         }
+      }
     }
     struct Op_Import opi = {.op   = insert_symbol("@scan"),
                             .lhs  = t,