]> Nishi Git Mirror - gwion.git/commitdiff
:art: Rename Func_Def->arg_list => args
authorfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 1 Apr 2019 13:19:36 +0000 (15:19 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 1 Apr 2019 13:19:36 +0000 (15:19 +0200)
12 files changed:
ast
include/gwion.h
src/emit/emit.c
src/gwion.c
src/lib/func.c
src/lib/instr.c
src/parse/check.c
src/parse/scan1.c
src/parse/scan2.c
tests/import/extend_array.c
tests/import/extend_event.c
tests/import/extend_pair.c

diff --git a/ast b/ast
index 0112a154df71cafe08e69427e0d8487cb9bdcafb..25337f99739d1844469e6fc2f3c07feda0d99b40 160000 (submodule)
--- a/ast
+++ b/ast
@@ -1 +1 @@
-Subproject commit 0112a154df71cafe08e69427e0d8487cb9bdcafb
+Subproject commit 25337f99739d1844469e6fc2f3c07feda0d99b40
index 622c18dcf6da8fdaf230e31c2696b5d8b4b5f0d9..11e5d7a2d475ff9eef46194af858e618406896bb 100644 (file)
@@ -7,7 +7,6 @@ typedef struct Gwion_* Gwion;
 struct Arg_;
 struct Gwion_ {
   PlugInfo* plug;
-// sym
 // mem
   Env      env;
   Emitter  emit;
index 75bfa88f6b904fde19e45b8e323d72bb7ddf6354..8ed143f2717023d30ab0eee52faa1d157560c1dd 100644 (file)
@@ -612,7 +612,7 @@ else
 
 ANN static m_uint vararg_size(const Exp_Call* exp_call, const Vector kinds) {
   Exp e = exp_call->args;
-  Arg_List l = exp_call->m_func->def->arg_list;
+  Arg_List l = exp_call->m_func->def->args;
   m_uint size = 0;
   while(e) {
     if(!l) {
@@ -1503,7 +1503,7 @@ ANN static m_bool emit_vararg_end(const Emitter emit, const m_uint offset) { GWD
 
 ANN static m_bool emit_vararg(const Emitter emit, const Exp_Dot* member) { GWDEBUG_EXE
   m_uint offset = emit->env->class_def ? SZ_INT : 0;
-  Arg_List l = emit->env->func->def->arg_list;
+  Arg_List l = emit->env->func->def->args;
   const m_str str = s_name(member->xid);
   while(l) {
     offset += l->type->size;
@@ -1658,8 +1658,8 @@ ANN static void emit_func_def_code(const Emitter emit, const Func func) { GWDEBU
 }
 
 ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def func_def) { GWDEBUG_EXE
-  if(func_def->arg_list)
-    emit_func_def_args(emit, func_def->arg_list);
+  if(func_def->args)
+    emit_func_def_args(emit, func_def->args);
   if(GET_FLAG(func_def, variadic))
     stack_alloc(emit);
   if(func_def->d.code->d.stmt_code.stmt_list)
index fe5ad9c48adf25c744016f957d21dd3ba666e3a5..15e71fe037e3be14c7ed204ef2b935c0fca833ed 100644 (file)
@@ -61,6 +61,7 @@ ANN VM* gwion_cpy(const VM* src) {
   gwion->emit = src->gwion->emit;
   gwion->env = src->gwion->env;
   gwion->freearg = src->gwion->freearg;
+  gwion->st = src->gwion->st;
   return gwion->vm;
 }
 ANN m_bool gwion_ini(const Gwion gwion, Arg* arg) {
index fa17d921e02ab4aa5a91344dc9118c1a764254c9..ce3fde4debb4c42911a3c46813d7744311e31768 100644 (file)
@@ -62,7 +62,7 @@ ANN2(1,3,4) m_bool check_lambda(const Env env, const Type owner,
     Exp_Lambda *l, const Func_Def def) {
   const m_uint scope = ((l->owner = owner)) ?
     env_push_type(env, owner) : env->scope->depth;
-  Arg_List base = def->arg_list, arg = l->arg;
+  Arg_List base = def->args, arg = l->arg;
   while(base && arg) {
     arg->td = base->td;
     base = base->next;
index e7f57a54e3819be7e358b780f6d149e47c90938b..e1671e8459ffaa712b2e346116c81b45b2646c18 100644 (file)
@@ -68,7 +68,7 @@ ANN static Func_Def from_base(const Env env, const struct dottmpl_ *dt, const Ty
   CHECK_OO(v)
   const Func_Def base = v->d.func_ref->def;
   const Func_Def def = new_func_def(base->td, insert_symbol(env->gwion->st, v->name),
-            base->arg_list, base->d.code, base->flag);
+            base->args, base->d.code, base->flag);
   def->tmpl = new_tmpl_list(base->tmpl->list, dt->overload);
   SET_FLAG(def, template);
   return def;
index 928de22dd63cfc32d667e64f218049d3f270acbb..0a7b1f736dc8335a662df081b27fa7ada955f391 100644 (file)
@@ -337,7 +337,7 @@ ANN2(1,2) static Func find_func_match_actual(const Env env, Func func, const Exp
   const m_bool implicit, const m_bool specific) {
   do {
     Exp e = args;
-    Arg_List e1 = func->def->arg_list;
+    Arg_List e1 = func->def->args;
     while(e) {
       if(!e1) {
         if(GET_FLAG(func->def, variadic))
@@ -409,7 +409,7 @@ ANN static Func _find_template_match(const Env env, const Value v, const Exp_Cal
         continue;
       base = value->d.func_ref->def;
       def = new_func_def(base->td, insert_symbol(v->name),
-                base->arg_list, base->d.code, base->flag);
+                base->args, base->d.code, base->flag);
       def->tmpl = new_tmpl_list(base->tmpl->list, (m_int)i);
       SET_FLAG(def, template);
     }
@@ -472,7 +472,7 @@ ANN2(1) static void* function_alternative(const Type f, const Exp args){
   Func up = f->d.func;
   do {
     gw_err("(%s)\t", up->name);
-    const Arg_List e = up->def->arg_list;
+    const Arg_List e = up->def->args;
     e ? print_arg(e) : (void)gw_err("\033[32mvoid\033[0m");
     gw_err("\n");
   } while((up = up->next));
@@ -512,7 +512,7 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) {
   Type_List tl[type_number];
   ID_List list = value->d.func_ref->def->tmpl->list;
   while(list) {
-    Arg_List arg = value->d.func_ref->def->arg_list;
+    Arg_List arg = value->d.func_ref->def->args;
     Exp template_arg = args;
     while(arg && template_arg) {
       char path[id_list_len(arg->td->xid)];
@@ -1049,7 +1049,7 @@ ANN static Value set_variadic(const Env env) {
 }
 
 ANN static void operator_func(const Func f) {
-  const Arg_List a = f->def->arg_list;
+  const Arg_List a = f->def->args;
   const m_bool is_unary = GET_FLAG(f->def, unary);
   const Type l = is_unary ? NULL : a->type;
   const Type r = is_unary ? a->type : a->next ? a->next->type : NULL;
@@ -1072,10 +1072,10 @@ ANN m_bool check_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
   env->func = func;
   ++env->scope->depth;
   nspc_push_value(env->curr);
-  if(!f->arg_list)
+  if(!f->args)
     UNSET_FLAG(f->func, pure);
   else
-    ret = check_func_args(env, f->arg_list);
+    ret = check_func_args(env, f->args);
   if(ret > 0) {
     const Value variadic = GET_FLAG(f, variadic) ? set_variadic(env) : NULL;
     if(!GET_FLAG(f, builtin) && check_stmt_code(env, &f->d.code->d.stmt_code) < 0)
index 5d4c8457b75528c6b341fdcbae00fa5d6f84c35a..4e3b1b2f4857c265b464fa7767dc0c5f98e7193b 100644 (file)
@@ -279,8 +279,8 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
     ERR_B(f->td->xid->pos, "dtor must be in class def!!")
   if(f->td)
     CHECK_OB((f->ret_type = known_type(env, f->td)))
-  if(f->arg_list)
-    CHECK_BB(scan1_args(env, f->arg_list))
+  if(f->args)
+    CHECK_BB(scan1_args(env, f->args))
   if(!GET_FLAG(f, builtin))
     CHECK_BB(scan1_stmt_code(env, &f->d.code->d.stmt_code))
   if(GET_FLAG(f, op) && env->class_def)
index 29516a1d46700f86a5d7734616bfa4eeaf03c925..2f36853956c74c3573e3dfed24d5a04a1280ea06 100644 (file)
@@ -61,7 +61,7 @@ ANN static Value arg_value(const Arg_List list) {
 }
 
 ANN static m_bool scan2_args(const Env env, const Func_Def f) { GWDEBUG_EXE
-  Arg_List list = f->arg_list;
+  Arg_List list = f->args;
   do {
     const Var_Decl var = list->var_decl;
     if(var->array)
@@ -91,8 +91,8 @@ ANN static Value scan2_func_assign(const Env env, const Func_Def d,
 
 ANN m_bool scan2_stmt_fptr(const Env env, const Stmt_Fptr ptr) { GWDEBUG_EXE
   struct Func_Def_ d = { .stack_depth=0 };
-  d.arg_list = ptr->args;
-  if(d.arg_list)
+  d.args = ptr->args;
+  if(d.args)
     CHECK_BB(scan2_args(env, &d))
   const Func_Def def = new_func_def(ptr->td, ptr->xid, ptr->args, NULL, ptr->td->flag);
   def->ret_type = ptr->ret_type;
@@ -400,12 +400,12 @@ ANN static m_bool scan2_func_def_builtin(const Func func, const m_str name) { GW
 }
 
 ANN static m_bool scan2_func_def_op(const Env env, const Func_Def f) { GWDEBUG_EXE
-  assert(f->arg_list);
+  assert(f->args);
   const Operator op = name2op(s_name(f->name));
   const Type l = GET_FLAG(f, unary) ? NULL :
-    f->arg_list->var_decl->value->type;
-  const Type r = GET_FLAG(f, unary) ? f->arg_list->var_decl->value->type :
-    f->arg_list->next ? f->arg_list->next->var_decl->value->type : NULL;
+    f->args->var_decl->value->type;
+  const Type r = GET_FLAG(f, unary) ? f->args->var_decl->value->type :
+    f->args->next ? f->args->next->var_decl->value->type : NULL;
   struct Op_Import opi = { .op=op, .lhs=l, .rhs=r, .ret=f->ret_type };
   CHECK_BB(env_add_op(env, &opi))
   if(env->class_def) {
@@ -506,7 +506,7 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
       if(GET_FLAG(func->def, variadic))
         f->stack_depth += SZ_INT;
       f->ret_type = type_decl_resolve(env, f->td);
-      return (f->arg_list && f->arg_list->type) ? scan2_args(env, f) : GW_OK;
+      return (f->args && f->args->type) ? scan2_args(env, f) : GW_OK;
     }
   }
   const Func base = get_func(env, f);
@@ -515,7 +515,7 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
   } else {
     f->func = base;
 }
-  if(f->arg_list)
+  if(f->args)
     CHECK_BB(scan2_args(env, f))
   if(!GET_FLAG(f, builtin) && f->d.code->d.stmt_code.stmt_list)
     CHECK_BB(scan2_func_def_code(env, f))
index 6780257b201adf7b9a8ee450d94f8e8e5f4636ea..e6d79e61db88384712ec43c3638ee6e8da8258b0 100644 (file)
@@ -8,12 +8,15 @@
 #include "object.h"
 #include "import.h"
 #include "instr.h"
+#include "vm.h"
+#include "gwion.h"
+#include "gwi.h"
 
 GWION_IMPORT(extend_array_test) {
   Type t_array_ext;
   CHECK_OB((t_array_ext = gwi_mk_type(gwi, "ArrayExt", SZ_INT, NULL)))
   CHECK_BB(gwi_class_ini(gwi, t_array_ext, NULL, NULL))
-  Type_Decl* td = new_type_decl(new_id_list(insert_symbol("float"), 0), 0);
+  Type_Decl* td = new_type_decl(new_id_list(insert_symbol(gwi->gwion->st, "float"), 0), 0);
   Exp e = new_exp_prim_int(1, 0);
   Array_Sub array = new_array_sub(e);
   add_type_decl_array(td, array);
index 92a8e9e68e159ea13bf31c4662e31801bd2423b3..3d00478808a3c4a4c5fb3eb3d5eaa0baf322896a 100644 (file)
@@ -8,6 +8,9 @@
 #include "object.h"
 #include "instr.h"
 #include "import.h"
+#include "vm.h"
+#include "gwion.h"
+#include "gwi.h"
 
 static CTOR(ev_ctor) { printf(" %p this to test ctor\n", (void*)o); }
 
@@ -15,7 +18,7 @@ GWION_IMPORT(extend_event_test) {
   Type t_ev ;
   CHECK_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL)))
   CHECK_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL))
-  Type_Decl* td = new_type_decl(new_id_list(insert_symbol("Event"), 0), 0);
+  Type_Decl* td = new_type_decl(new_id_list(insert_symbol(gwi->gwion->st, "Event"), 0), 0);
   CHECK_BB(gwi_class_ext(gwi, td))
   CHECK_BB(gwi_class_end(gwi))
   return GW_OK;
index 304a8d32a3f20be93aff86667829bb3ce6975de5..bd1f94f9e02998e3c647a36f33b0a6ac55f6d1b9 100644 (file)
@@ -8,6 +8,9 @@
 #include "object.h"
 #include "instr.h"
 #include "import.h"
+#include "vm.h"
+#include "gwion.h"
+#include "gwi.h"
 
 GWION_IMPORT(extend_pair_test) {
   m_str types[] = { "A", "B" };
@@ -16,9 +19,9 @@ GWION_IMPORT(extend_pair_test) {
   CHECK_BB(gwi_tmpl_ini(gwi, 2, types))
   CHECK_BB(gwi_class_ini(gwi, t_pair_ext, NULL, NULL))
   CHECK_BB(gwi_tmpl_end(gwi))
-  Type_Decl* td  = new_type_decl(new_id_list(insert_symbol("Pair"), 0), 0);
-  Type_Decl* td0 = new_type_decl(new_id_list(insert_symbol("A"), 0), 0);
-  Type_Decl* td1 = new_type_decl(new_id_list(insert_symbol("B"), 0), 0);
+  Type_Decl* td  = new_type_decl(new_id_list(insert_symbol(gwi->gwion->st, "Pair"), 0), 0);
+  Type_Decl* td0 = new_type_decl(new_id_list(insert_symbol(gwi->gwion->st, "A"), 0), 0);
+  Type_Decl* td1 = new_type_decl(new_id_list(insert_symbol(gwi->gwion->st, "B"), 0), 0);
   Type_List tl1  = new_type_list(td1, NULL);
   Type_List tl0  = new_type_list(td0, tl1);
   td->types = tl0;