Commit 41789c7120c1231d0b8f1bfdf61831f6157a920f

Thomas de Grivel 2024-06-15T13:38:56

move defstruct functionality from .facts files to .c3 files

diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 2590ffc..07fec09 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,7 +1,5 @@
 defmodule Plop do def a = 1 end
 Plop.a
-defmodule Plop do def a = 1 end
-Plop.a
 Plop
 defmodule Plop do def a = 1 end
 Plop.a
@@ -97,3 +95,5 @@ type(cow 1)
 a = cow 1
 a
 type(a)
+def operator_muul = %C3.Operator{sym: :****, symbol_value: cfn Tag "tag_mul" (Tag, Tag, Result), operator_precedence: 11, operator_associativity: :left}
+2 **** 4
diff --git a/lib/c3/0.1/c3/operator.c3 b/lib/c3/0.1/c3/operator.c3
new file mode 100644
index 0000000..5cb346f
--- /dev/null
+++ b/lib/c3/0.1/c3/operator.c3
@@ -0,0 +1,8 @@
+defmodule C3.Operator do
+
+  defstruct [sym: :+,
+             symbol_value: ?,
+	     operator_precedence: 0,
+	     operator_associativity: :left]
+
+end
diff --git a/lib/c3/0.1/c3/operator.facts b/lib/c3/0.1/c3/operator.facts
deleted file mode 100644
index 7f878c8..0000000
--- a/lib/c3/0.1/c3/operator.facts
+++ /dev/null
@@ -1,4 +0,0 @@
-%{module: C3.Facts.Dump,
-  version: 1}
-replace {C3.Operator, :is_a, :module}
-replace {C3.Operator, :defstruct, [sym: :+, symbol_value: ?, operator_precedence: 0, operator_associativity: :left]}
diff --git a/libc3/env.c b/libc3/env.c
index 79b753a..9ecfb28 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -1831,7 +1831,6 @@ bool env_module_is_loading_set (s_env *env, const s_sym *module,
 bool env_module_load (s_env *env, const s_sym *module, s_facts *facts)
 {
   bool b;
-  bool has_spec;
   s_str path = {0};
   s_tag tag_module_name;
   s_tag tag_load_time;
@@ -1884,15 +1883,11 @@ bool env_module_load (s_env *env, const s_sym *module, s_facts *facts)
                            &tag_time))
     goto rollback;
   tag_clean(&tag_time);
-  if (! env_struct_type_has_spec(env, module, &has_spec))
-    goto rollback;
-  if (has_spec && ! env_module_load_defstruct(env, module))
-    goto rollback;
   env_module_is_loading_set(env, module, false);
   return true;
  rollback:
   if (! facts_transaction_rollback(facts, &transaction)) {
-    exit(1);
+    abort();
     return false;
   }
   return false;
@@ -2412,7 +2407,7 @@ s_list ** env_struct_type_get_spec (s_env *env,
     assert(! "env_struct_type_get_spec: defstruct not found");
     return NULL;
   }
-  if (! env_eval_tag(env, found->object, &tmp))
+  if (! env_eval_tag(env, &tag_var, &tmp))
     return NULL;
   if (tmp.type != TAG_LIST ||
       ! list_is_plist(tmp.data.list)) {