diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 93faa4e..3e9a609 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,14 +1,3 @@
-beacoup
-beaucoup
-1 / 4
-(Ratio) 1 / 4
-(Ratio) 1 / 4 * 2
-1/4 * 2
-type(1/4)
-1/4 / 13/12
-1/4 / 13/12 * 2
-(Complex) 1
-1 +i 2
type(1 +i 2)
1 +i 2 +i 3
(1 +i 2) * (2 +i 3)
@@ -93,8 +82,18 @@ defmodule Plop do
def sq = fn (x) { x + x }
end
Plop.sq(4)
-defmodule Plop do defoperator :operator_add :+ cfn Tag "tag_mul" (Tag, Tag, Result) 10 :left end
-defmodule Plop do def sq = fn (x) { x + x } end
-Plop.sq(4)
-defoperator :operator_add :+ cfn Tag "tag_mul" (Tag, Tag, Result) 10 :left
-
++
+%C3.Operator{
+ sym: :****,
+ symbol_value: cfn Tag "tag_mul" (Tag, Tag, Result),
+ operator_precedence: 11,
+ operator_associativity: :left
+}
+%C3.Operator{sym: :****, symbol_value: cfn Tag "tag_mul" (Tag, Tag, Result), operator_precedence: 11}
+(Void) 0
+(Integer) 0
+(Integer) 10
+type((Integer) 10)
+type((Integer) 0)
+(Sw) 10
+(Uw) 10
diff --git a/lib/c3/0.1/c3/operator.facts b/lib/c3/0.1/c3/operator.facts
new file mode 100644
index 0000000..7f878c8
--- /dev/null
+++ b/lib/c3/0.1/c3/operator.facts
@@ -0,0 +1,4 @@
+%{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/lib/c3/0.1/f128.facts b/lib/c3/0.1/f128.facts
new file mode 100644
index 0000000..9acc7c4
--- /dev/null
+++ b/lib/c3/0.1/f128.facts
@@ -0,0 +1,5 @@
+%{module: C3.Facts.Dump,
+ version: 1}
+replace {F128, :is_a, :module}
+replace {F128, :symbol, F128.cast}
+replace {F128.cast, :symbol_value, cfn F128 "f128_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/f32.facts b/lib/c3/0.1/f32.facts
index 97420e9..83d2d79 100644
--- a/lib/c3/0.1/f32.facts
+++ b/lib/c3/0.1/f32.facts
@@ -2,4 +2,4 @@
version: 1}
replace {F32, :is_a, :module}
replace {F32, :symbol, F32.cast}
-replace {F32.cast, :symbol_value, cfn F32 "f32_init_cast" (Result, Tag)}
+replace {F32.cast, :symbol_value, cfn F32 "f32_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/f64.facts b/lib/c3/0.1/f64.facts
index fad6ffa..76afff9 100644
--- a/lib/c3/0.1/f64.facts
+++ b/lib/c3/0.1/f64.facts
@@ -2,4 +2,4 @@
version: 1}
replace {F64, :is_a, :module}
replace {F64, :symbol, F64.cast}
-replace {F64.cast, :symbol_value, cfn F64 "f64_init_cast" (Result, Tag)}
+replace {F64.cast, :symbol_value, cfn F64 "f64_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/integer.facts b/lib/c3/0.1/integer.facts
index 09cb5fc..3c36642 100644
--- a/lib/c3/0.1/integer.facts
+++ b/lib/c3/0.1/integer.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Integer, :is_a, :module}
replace {Integer, :symbol, Integer.cast}
-replace {Integer.cast, :symbol_value, cfn Integer "integer_init_cast" (Result, Tag)}
+replace {Integer.cast, :symbol_value, cfn Integer "integer_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/str.facts b/lib/c3/0.1/str.facts
index e485096..459033c 100644
--- a/lib/c3/0.1/str.facts
+++ b/lib/c3/0.1/str.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Str, :is_a, :module}
replace {Str, :symbol, Str.cast}
-replace {Str.cast, :symbol_value, cfn Str "str_init_cast" (Result, Tag)}
+replace {Str.cast, :symbol_value, cfn Str "str_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/sym.facts b/lib/c3/0.1/sym.facts
index 30ba24d..dd32895 100644
--- a/lib/c3/0.1/sym.facts
+++ b/lib/c3/0.1/sym.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Sym, :is_a, :module}
replace {Sym, :symbol, Sym.cast}
-replace {Sym.cast, :symbol_value, cfn Sym "sym_init_cast" (Result, Tag)}
+replace {Sym.cast, :symbol_value, cfn Sym "sym_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/u16.facts b/lib/c3/0.1/u16.facts
index 44f6ac4..70c376a 100644
--- a/lib/c3/0.1/u16.facts
+++ b/lib/c3/0.1/u16.facts
@@ -2,4 +2,4 @@
version: 1}
replace {U16, :is_a, :module}
replace {U16, :symbol, U16.cast}
-replace {U16.cast, :symbol_value, cfn U16 "u16_init_cast" (Result, Tag)}
+replace {U16.cast, :symbol_value, cfn U16 "u16_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/u32.facts b/lib/c3/0.1/u32.facts
index c4c8f6a..4d4d606 100644
--- a/lib/c3/0.1/u32.facts
+++ b/lib/c3/0.1/u32.facts
@@ -2,4 +2,4 @@
version: 1}
replace {U32, :is_a, :module}
replace {U32, :symbol, U32.cast}
-replace {U32.cast, :symbol_value, cfn U32 "u32_init_cast" (Result, Tag)}
+replace {U32.cast, :symbol_value, cfn U32 "u32_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/u64.facts b/lib/c3/0.1/u64.facts
index 3f70362..cd5339b 100644
--- a/lib/c3/0.1/u64.facts
+++ b/lib/c3/0.1/u64.facts
@@ -2,4 +2,4 @@
version: 1}
replace {U64, :is_a, :module}
replace {U64, :symbol, U64.cast}
-replace {U64.cast, :symbol_value, cfn U64 "u64_init_cast" (Result, Tag)}
+replace {U64.cast, :symbol_value, cfn U64 "u64_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/u8.facts b/lib/c3/0.1/u8.facts
index 7393b5d..c2459e1 100644
--- a/lib/c3/0.1/u8.facts
+++ b/lib/c3/0.1/u8.facts
@@ -2,4 +2,4 @@
version: 1}
replace {U8, :is_a, :module}
replace {U8, :symbol, U8.cast}
-replace {U8.cast, :symbol_value, cfn U8 "u8_init_cast" (Result, Tag)}
+replace {U8.cast, :symbol_value, cfn U8 "u8_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/uw.facts b/lib/c3/0.1/uw.facts
index 084216e..99fe9d1 100644
--- a/lib/c3/0.1/uw.facts
+++ b/lib/c3/0.1/uw.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Uw, :is_a, :module}
replace {Uw, :symbol, Uw.cast}
-replace {Uw.cast, :symbol_value, cfn Uw "uw_init_cast" (Result, Tag)}
+replace {Uw.cast, :symbol_value, cfn Uw "uw_init_cast" (Result, Sym, Tag)}
diff --git a/lib/c3/0.1/void.facts b/lib/c3/0.1/void.facts
index 39d5dfc..5243ce3 100644
--- a/lib/c3/0.1/void.facts
+++ b/lib/c3/0.1/void.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Void, :is_a, :module}
replace {Void, :symbol, Void.cast}
-replace {Void.cast, :symbol_value, cfn Void "void_init_cast" (Result, Tag)}
+replace {Void.cast, :symbol_value, cfn Void "void_init_cast" (Result, Sym, Tag)}
diff --git a/libc3/array.c b/libc3/array.c
index 6615a33..1d8a362 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -241,8 +241,12 @@ s_array * array_init_1 (s_array *array, const char *p)
return array;
}
-s_array * array_init_cast (s_array *array, const s_tag *tag)
+s_array * array_init_cast (s_array *array, const s_sym *type, const s_tag *tag)
{
+ assert(array);
+ assert(type);
+ assert(tag);
+ (void) type;
switch (tag->type) {
case TAG_ARRAY:
return array_init_copy(array, &tag->data.array);
diff --git a/libc3/array.h b/libc3/array.h
index fd20b0d..2f53517 100644
--- a/libc3/array.h
+++ b/libc3/array.h
@@ -20,7 +20,8 @@ void array_clean (s_array *a);
s_array * array_init (s_array *a, const s_sym *array_type,
uw dimension, const uw *dimensions);
s_array * array_init_1 (s_array *a, const char *p);
-s_array * array_init_cast (s_array *a, const s_tag *tag);
+s_array * array_init_cast (s_array *a, const s_sym *type,
+ const s_tag *tag);
s_array * array_init_copy (s_array *a, const s_array *src);
s_array * array_init_copy_shallow (s_array *a, const s_array *src);
s_array * array_init_void (s_array *array);
diff --git a/libc3/bool.c b/libc3/bool.c
index f4c07b4..f2bb8a6 100644
--- a/libc3/bool.c
+++ b/libc3/bool.c
@@ -18,11 +18,13 @@
#include "integer.h"
#include "io.h"
#include "ratio.h"
+#include "sym.h"
#include "tag_type.h"
-bool * bool_init_cast (bool *b, const s_tag *tag)
+bool * bool_init_cast (bool *b, const s_sym *type, const s_tag *tag)
{
assert(b);
+ assert(type);
assert(tag);
switch (tag->type) {
case TAG_BOOL: *b = tag->data.bool; return b;
@@ -45,8 +47,9 @@ bool * bool_init_cast (bool *b, const s_tag *tag)
case TAG_U32: *b = tag->data.u32 != 0; return b;
case TAG_U64: *b = tag->data.u64 != 0; return b;
case TAG_UW: *b = tag->data.uw != 0; return b;
- case TAG_PTAG: return tag->data.ptag ?
- bool_init_cast(b, tag->data.ptag) : (*b = false, b);
+ case TAG_PTAG:
+ return tag->data.ptag ?
+ bool_init_cast(b, type, tag->data.ptag) : (*b = false, b);
case TAG_PTR: *b = tag->data.ptr.p != 0; return b;
case TAG_PTR_FREE: *b = tag->data.ptr_free.p != 0; return b;
case TAG_ARRAY:
@@ -71,7 +74,13 @@ bool * bool_init_cast (bool *b, const s_tag *tag)
}
err_write_1("bool_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Bool");
+ if (type == &g_sym_Bool)
+ err_puts(" to Bool");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Bool");
+ }
assert(! "bool_cast: cannot cast to Bool");
return NULL;
}
diff --git a/libc3/bool.h b/libc3/bool.h
index 4daf91b..0c36b85 100644
--- a/libc3/bool.h
+++ b/libc3/bool.h
@@ -22,7 +22,7 @@
#include "types.h"
/* Stack-allocation compatible functions */
-bool * bool_init_cast (bool *b, const s_tag *tag);
+bool * bool_init_cast (bool *b, const s_sym *type, const s_tag *tag);
bool * bool_init_copy (bool *b, const bool *src);
/* Observers */
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index e4629ea..5b9f80d 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -748,7 +748,8 @@ sw buf_inspect_cast (s_buf *buf, const s_call *call)
assert(buf);
assert(call);
assert(call->arguments);
- assert(! list_next(call->arguments));
+ assert(list_next(call->arguments));
+ assert(! list_next(list_next(call->arguments)));
module = call->ident.module;
if ((r = buf_inspect_paren_sym(buf, module)) < 0)
return r;
@@ -756,7 +757,7 @@ sw buf_inspect_cast (s_buf *buf, const s_call *call)
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
- arg = &call->arguments->tag;
+ arg = &list_next(call->arguments)->tag;
if ((r = buf_inspect_tag(buf, arg)) < 0)
return r;
result += r;
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 143ae19..330b154 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -980,9 +980,11 @@ sw buf_parse_cast (s_buf *buf, s_call *dest)
if ((r = buf_ignore_spaces(buf)) < 0)
goto restore;
result += r;
- call_init_op_unary(&tmp);
+ call_init_op(&tmp);
ident_init(&tmp.ident, module, &g_sym_cast);
- if ((r = buf_parse_tag_primary(buf, &tmp.arguments->tag)) <= 0)
+ tag_init_sym(&tmp.arguments->tag, module);
+ if ((r = buf_parse_tag_primary(buf,
+ &list_next(tmp.arguments)->tag)) <= 0)
goto clean;
result += r;
*dest = tmp;
diff --git a/libc3/c3.c b/libc3/c3.c
index 97b4f46..b37b71e 100644
--- a/libc3/c3.c
+++ b/libc3/c3.c
@@ -112,7 +112,7 @@ s_tag * c3_if_then_else (const s_tag *cond, const s_tag *then,
s_tag tmp;
if (! env_eval_tag(&g_c3_env, cond, &tmp))
return NULL;
- if (! bool_init_cast(&b, &tmp)) {
+ if (! bool_init_cast(&b, &g_sym_Bool, &tmp)) {
tag_clean(&tmp);
return NULL;
}
diff --git a/libc3/call.c b/libc3/call.c
index a7cd4bb..9b25dfc 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -199,18 +199,29 @@ s_call * call_init_1 (s_call *call, const char *p)
s_call * call_init_call_cast (s_call *call, const s_sym *type)
{
+ s_list *next;
s_call tmp = {0};
tmp.ident.module = type;
tmp.ident.sym = &g_sym_cast;
- tmp.arguments = list_new(NULL);
- if (! tmp.arguments)
+ next = list_new(NULL);
+ if (! next)
+ return NULL;
+ tmp.arguments = list_new(next);
+ if (! tmp.arguments) {
+ list_delete_all(next);
return NULL;
+ }
+ tag_init_sym(&tmp.arguments->tag, type);
*call = tmp;
return call;
}
-s_call * call_init_cast (s_call *call, const s_tag *tag)
+s_call * call_init_cast (s_call *call, const s_sym *type,
+ const s_tag *tag)
{
+ assert(call);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_CALL:
return call_init_copy(call, &tag->data.call);
@@ -219,7 +230,13 @@ s_call * call_init_cast (s_call *call, const s_tag *tag)
}
err_write_1("call_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Call");
+ if (type == &g_sym_Call)
+ err_puts(" to Call");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Call");
+ }
assert(! "call_init_cast: cannot cast to Call");
return NULL;
}
diff --git a/libc3/call.h b/libc3/call.h
index 13044d9..c6f1a39 100644
--- a/libc3/call.h
+++ b/libc3/call.h
@@ -20,7 +20,8 @@ void call_clean (s_call *call);
s_call * call_init (s_call *call);
s_call * call_init_1 (s_call *call, const char *p);
s_call * call_init_call_cast (s_call *call, const s_sym *type);
-s_call * call_init_cast (s_call *call, const s_tag *tag);
+s_call * call_init_cast (s_call *call, const s_sym *type,
+ const s_tag *tag);
s_call * call_init_copy (s_call *call, const s_call *src);
s_call * call_init_op (s_call *call);
s_call * call_init_op_unary (s_call *call);
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 107e67a..fe94888 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -179,8 +179,9 @@ s_cfn * cfn_init (s_cfn *cfn, const s_sym *name, s_list *arg_types,
return cfn;
}
-s_cfn * cfn_init_cast (s_cfn *cfn, const s_tag *tag)
+s_cfn * cfn_init_cast (s_cfn *cfn, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_CFN:
return cfn_init_copy(cfn, &tag->data.cfn);
diff --git a/libc3/cfn.h b/libc3/cfn.h
index 3b1da26..8b81fb0 100644
--- a/libc3/cfn.h
+++ b/libc3/cfn.h
@@ -19,7 +19,7 @@
void cfn_clean (s_cfn *cfn);
s_cfn * cfn_init (s_cfn *cfn, const s_sym *name, s_list *arg_types,
const s_sym *result_type);
-s_cfn * cfn_init_cast (s_cfn *cfn, const s_tag *tag);
+s_cfn * cfn_init_cast (s_cfn *cfn, const s_sym *type, const s_tag *tag);
s_cfn * cfn_init_copy (s_cfn *cfn, const s_cfn *src);
/* Heap-allocation functions, call cfn_delete after use. */
diff --git a/libc3/character.c b/libc3/character.c
index 959efc5..73e1641 100644
--- a/libc3/character.c
+++ b/libc3/character.c
@@ -14,6 +14,7 @@
#include "character.h"
#include "integer.h"
#include "str.h"
+#include "sym.h"
#include "tag_type.h"
#include "ucd.h"
@@ -27,9 +28,11 @@ character character_1 (const char *p)
return c;
}
-character * character_init_cast (character *c, const s_tag *tag)
+character * character_init_cast (character *c, const s_sym *type,
+ const s_tag *tag)
{
assert(c);
+ assert(type);
assert(tag);
switch (tag->type) {
case TAG_CHARACTER: *c = tag->data.character; return c;
@@ -50,7 +53,13 @@ character * character_init_cast (character *c, const s_tag *tag)
}
err_write_1("character_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Character");
+ if (type == &g_sym_Character)
+ err_puts(" to Character");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Character");
+ }
assert(! "character_cast: cannot cast to Character");
return NULL;
}
diff --git a/libc3/character.h b/libc3/character.h
index a22fbd2..d244579 100644
--- a/libc3/character.h
+++ b/libc3/character.h
@@ -18,7 +18,8 @@
character character_1 (const char *p);
void character_hash_update (character c, t_hash *hash);
-character * character_init_cast (character *c, const s_tag *tag);
+character * character_init_cast (character *c, const s_sym *type,
+ const s_tag *tag);
character * character_init_copy (character *c, const character *src);
bool character_is_digit (character c);
bool character_is_lowercase (character c);
diff --git a/libc3/complex.c b/libc3/complex.c
index 9555196..7db55d2 100644
--- a/libc3/complex.c
+++ b/libc3/complex.c
@@ -16,6 +16,8 @@
#include "complex.h"
#include "f32.h"
#include "f64.h"
+#include "f128.h"
+#include "sym.h"
#include "tag.h"
#include "tag_init.h"
@@ -338,7 +340,7 @@ f32 complex_to_f32 (const s_complex *c)
f32 x;
assert(c);
complex_norm(c, &norm);
- f32_init_cast(&x, &norm);
+ f32_init_cast(&x, &g_sym_F32, &norm);
return x;
}
@@ -348,6 +350,16 @@ f64 complex_to_f64 (const s_complex *c)
f64 x;
assert(c);
complex_norm(c, &norm);
- f64_init_cast(&x, &norm);
+ f64_init_cast(&x, &g_sym_F64, &norm);
+ return x;
+}
+
+f128 complex_to_f128 (const s_complex *c)
+{
+ s_tag norm;
+ f128 x;
+ assert(c);
+ complex_norm(c, &norm);
+ f128_init_cast(&x, &g_sym_F128, &norm);
return x;
}
diff --git a/libc3/complex.h b/libc3/complex.h
index 425a8a4..6ca25e2 100644
--- a/libc3/complex.h
+++ b/libc3/complex.h
@@ -65,5 +65,6 @@ s_complex * complex_new_copy (const s_complex *a);
bool complex_is_zero (const s_complex *c);
f32 complex_to_f32 (const s_complex *c);
f64 complex_to_f64 (const s_complex *c);
+f128 complex_to_f128 (const s_complex *c);
#endif /* LIBC3_COMPLEX_H */
diff --git a/libc3/data.c b/libc3/data.c
index 5eb35db..3bdb75d 100644
--- a/libc3/data.c
+++ b/libc3/data.c
@@ -474,70 +474,68 @@ bool data_hash_update (const s_sym *type, t_hash *hash, const void *data)
return false;
}
-void * data_init_cast (const s_sym *type, void *data, const s_tag *tag)
+void * data_init_cast (void *data, const s_sym *type, const s_tag *tag)
{
const s_struct_type *st;
if (type == &g_sym_Array ||
sym_is_array_type(type))
- return array_init_cast(data, tag);
+ return array_init_cast(data, type, tag);
if (type == &g_sym_Bool)
- return bool_init_cast(data, tag);
+ return bool_init_cast(data, type, tag);
if (type == &g_sym_Call)
- return call_init_cast(data, tag);
+ return call_init_cast(data, type, tag);
if (type == &g_sym_Cfn)
- return cfn_init_cast(data, tag);
+ return cfn_init_cast(data, type, tag);
if (type == &g_sym_Character)
- return character_init_cast(data, tag);
+ return character_init_cast(data, type, tag);
if (type == &g_sym_F32)
- return f32_init_cast(data, tag);
+ return f32_init_cast(data, type, tag);
if (type == &g_sym_F64)
- return f64_init_cast(data, tag);
+ return f64_init_cast(data, type, tag);
if (type == &g_sym_Fact)
- return fact_init_cast(data, tag);
+ return fact_init_cast(data, type, tag);
if (type == &g_sym_Fn)
- return fn_init_cast(data, tag);
+ return fn_init_cast(data, type, tag);
if (type == &g_sym_Ident)
- return ident_init_cast(data, tag);
+ return ident_init_cast(data, type, tag);
if (type == &g_sym_Integer)
- return integer_init_cast(data, tag);
+ return integer_init_cast(data, type, tag);
if (type == &g_sym_List)
- return list_init_cast(data, tag);
+ return list_init_cast(data, type, tag);
if (type == &g_sym_Ptag)
- return ptag_init_cast(data, tag);
+ return ptag_init_cast(data, type, tag);
if (type == &g_sym_Ptr)
- return ptr_init_cast(data, tag);
+ return ptr_init_cast(data, type, tag);
if (type == &g_sym_PtrFree)
- return ptr_free_init_cast(data, tag);
+ return ptr_free_init_cast(data, type, tag);
if (type == &g_sym_Quote)
- return quote_init_cast(data, tag);
+ return quote_init_cast(data, type, tag);
if (type == &g_sym_S8)
- return s8_init_cast(data, tag);
+ return s8_init_cast(data, type, tag);
if (type == &g_sym_S16)
- return s16_init_cast(data, tag);
+ return s16_init_cast(data, type, tag);
if (type == &g_sym_S32)
- return s32_init_cast(data, tag);
+ return s32_init_cast(data, type, tag);
if (type == &g_sym_S64)
- return s64_init_cast(data, tag);
+ return s64_init_cast(data, type, tag);
if (type == &g_sym_Str)
- return str_init_cast(data, tag);
- if (type == &g_sym_Struct)
- return struct_init_cast(data, tag);
+ return str_init_cast(data, type, tag);
if (type == &g_sym_Sw)
- return sw_init_cast(data, tag);
+ return sw_init_cast(data, type, tag);
if (type == &g_sym_Sym)
- return sym_init_cast(data, tag);
+ return sym_init_cast(data, type, tag);
if (type == &g_sym_Tuple)
- return tuple_init_cast(data, tag);
+ return tuple_init_cast(data, type, tag);
if (type == &g_sym_U8)
- return u8_init_cast(data, tag);
+ return u8_init_cast(data, type, tag);
if (type == &g_sym_U16)
- return u16_init_cast(data, tag);
+ return u16_init_cast(data, type, tag);
if (type == &g_sym_U32)
- return u32_init_cast(data, tag);
+ return u32_init_cast(data, type, tag);
if (type == &g_sym_U64)
- return u64_init_cast(data, tag);
+ return u64_init_cast(data, type, tag);
if (type == &g_sym_Uw)
- return uw_init_cast(data, tag);
+ return uw_init_cast(data, type, tag);
if (type == &g_sym_Var)
return data;
if (type == &g_sym_Void)
@@ -550,7 +548,7 @@ void * data_init_cast (const s_sym *type, void *data, const s_tag *tag)
s_struct s = {0};
s.type = st;
s.data = data;
- return struct_init_cast(&s, tag);
+ return struct_init_cast(&s, type, tag);
}
err_write_1("data_init_cast: unknown type: ");
err_inspect_sym(&type);
diff --git a/libc3/data.h b/libc3/data.h
index 55b98ce..dbc3177 100644
--- a/libc3/data.h
+++ b/libc3/data.h
@@ -27,7 +27,7 @@ bool data_clean (const s_sym *type, void *v);
bool data_compare (const s_sym *type, const void *a, const void *b);
bool data_hash_update (const s_sym *type, t_hash *hash,
const void *s);
-void * data_init_cast (const s_sym *type, void *v, const s_tag *src);
+void * data_init_cast (void *v, const s_sym *type, const s_tag *src);
void * data_init_copy (const s_sym *type, void *v, const void *src);
#endif /* LIBC3_DATA_H */
diff --git a/libc3/env.c b/libc3/env.c
index 7d57dba..e56c29d 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -262,7 +262,7 @@ bool env_eval_array (s_env *env, const s_array *array, s_array *dest)
while (i < tmp.count) {
if (! env_eval_tag(env, tag, &tag_eval))
goto ko;
- if (! data_init_cast(tmp.element_type, data, &tag_eval)) {
+ if (! data_init_cast(data, tmp.element_type, &tag_eval)) {
err_write_1("env_eval_array: cannot cast ");
err_inspect_tag(&tag_eval);
err_write_1(" to ");
@@ -1266,8 +1266,8 @@ bool env_eval_struct (s_env *env, const s_struct *s, s_tag *dest)
if (s->tag) {
if (! env_eval_tag(env, s->tag + i, &tag))
goto ko;
- if (! data_init_cast(type, (s8 *) t->data + t->type->offset[i],
- &tag)) {
+ if (! data_init_cast((s8 *) t->data + t->type->offset[i],
+ type, &tag)) {
err_write_1("env_eval_struct: invalid type ");
err_write_1(tag_type_to_string(tag.type));
err_write_1(" for key ");
diff --git a/libc3/f128.c b/libc3/f128.c
index 6ec1c0d..5bce202 100644
--- a/libc3/f128.c
+++ b/libc3/f128.c
@@ -12,16 +12,19 @@
*/
#include <stdlib.h>
#include "assert.h"
+#include "f128.h"
#include "integer.h"
+#include "ratio.h"
+#include "sym.h"
#include "tag.h"
#include "tag_type.h"
-#include "f128.h"
#include "u64.h"
-f128 * f128_init_cast (f128 *x, const s_tag *tag)
+f128 * f128_init_cast (f128 *x, const s_sym *type, const s_tag *tag)
{
- assert(tag);
assert(x);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_BOOL:
*x = tag->data.bool ? 1.0 : 0.0;
@@ -41,6 +44,9 @@ f128 * f128_init_cast (f128 *x, const s_tag *tag)
case TAG_INTEGER:
*x = integer_to_f128(&tag->data.integer);
return x;
+ case TAG_RATIO:
+ *x = ratio_to_f128(&tag->data.ratio);
+ return x;
case TAG_SW:
*x = (f128) tag->data.sw;
return x;
@@ -76,7 +82,13 @@ f128 * f128_init_cast (f128 *x, const s_tag *tag)
}
err_write_1("f128_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to F128");
+ if (type == &g_sym_F128)
+ err_puts(" to F128");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka F128");
+ }
assert(! "f128_init_cast: cannot cast to F128");
return NULL;
}
diff --git a/libc3/f128.h b/libc3/f128.h
index aa9b317..261744d 100644
--- a/libc3/f128.h
+++ b/libc3/f128.h
@@ -15,7 +15,7 @@
#include "types.h"
-f128 * f128_init_cast (f128 *x, const s_tag *tag);
+f128 * f128_init_cast (f128 *x, const s_sym *type, const s_tag *tag);
f128 * f128_init_copy (f128 *x, const f128 *src);
f128 * f128_random (f128 *x);
diff --git a/libc3/f32.c b/libc3/f32.c
index a0bf135..3dc20aa 100644
--- a/libc3/f32.c
+++ b/libc3/f32.c
@@ -12,15 +12,19 @@
*/
#include <stdlib.h>
#include "assert.h"
+#include "f32.h"
#include "integer.h"
+#include "ratio.h"
+#include "sym.h"
#include "tag.h"
#include "tag_type.h"
-#include "ratio.h"
-#include "f32.h"
#include "u32.h"
-f32 * f32_init_cast (f32 *x, const s_tag *tag)
+f32 * f32_init_cast (f32 *x, const s_sym *type, const s_tag *tag)
{
+ assert(x);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_BOOL:
*x = tag->data.bool ? 1.0f : 0.0f;
@@ -75,7 +79,13 @@ f32 * f32_init_cast (f32 *x, const s_tag *tag)
}
err_write_1("f32_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to F32");
+ if (type == &g_sym_F32)
+ err_puts(" to F32");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka F32");
+ }
assert(! "f32_init_cast: cannot cast to F32");
return NULL;
}
diff --git a/libc3/f32.h b/libc3/f32.h
index d41eb7a..db5345a 100644
--- a/libc3/f32.h
+++ b/libc3/f32.h
@@ -15,7 +15,7 @@
#include "types.h"
-f32 * f32_init_cast (f32 *x, const s_tag *tag);
+f32 * f32_init_cast (f32 *x, const s_sym *type, const s_tag *tag);
f32 * f32_init_copy (f32 *x, const f32 *src);
f32 * f32_random (f32 *x);
diff --git a/libc3/f64.c b/libc3/f64.c
index 085caf0..4457968 100644
--- a/libc3/f64.c
+++ b/libc3/f64.c
@@ -12,17 +12,19 @@
*/
#include <stdlib.h>
#include "assert.h"
+#include "f64.h"
#include "integer.h"
+#include "ratio.h"
+#include "sym.h"
#include "tag.h"
#include "tag_type.h"
-#include "ratio.h"
-#include "f64.h"
#include "u64.h"
-f64 * f64_init_cast (f64 *x, const s_tag *tag)
+f64 * f64_init_cast (f64 *x, const s_sym *type, const s_tag *tag)
{
- assert(tag);
assert(x);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_BOOL:
*x = tag->data.bool ? 1.0 : 0.0;
@@ -74,7 +76,13 @@ f64 * f64_init_cast (f64 *x, const s_tag *tag)
}
err_write_1("f64_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to F64");
+ if (type == &g_sym_F64)
+ err_puts(" to F64");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka F64");
+ }
assert(! "f64_init_cast: cannot cast to F64");
return NULL;
}
diff --git a/libc3/f64.h b/libc3/f64.h
index 5a509be..c233ce0 100644
--- a/libc3/f64.h
+++ b/libc3/f64.h
@@ -15,7 +15,7 @@
#include "types.h"
-f64 * f64_init_cast (f64 *x, const s_tag *tag);
+f64 * f64_init_cast (f64 *x, const s_sym *type, const s_tag *tag);
f64 * f64_init_copy (f64 *x, const f64 *src);
f64 * f64_random (f64 *x);
diff --git a/libc3/fact.c b/libc3/fact.c
index 9dddeb7..2c61e69 100644
--- a/libc3/fact.c
+++ b/libc3/fact.c
@@ -15,6 +15,7 @@
#include "buf_inspect.h"
#include "hash.h"
#include "fact.h"
+#include "sym.h"
#include "tag.h"
uw fact_hash_uw (const s_fact *fact)
@@ -37,8 +38,12 @@ s_fact * fact_init (s_fact *fact, const s_tag *subject,
return fact;
}
-s_fact * fact_init_cast (s_fact *fact, const s_tag *tag)
+s_fact * fact_init_cast (s_fact *fact, const s_sym *type,
+ const s_tag *tag)
{
+ assert(fact);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_FACT:
return fact_init_copy(fact, &tag->data.fact);
@@ -47,7 +52,13 @@ s_fact * fact_init_cast (s_fact *fact, const s_tag *tag)
}
err_write_1("fact_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Fact");
+ if (type == &g_sym_Fact)
+ err_puts(" to Fact");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Fact");
+ }
assert(! "fact_init_cast: cannot cast to Fact");
return NULL;
}
diff --git a/libc3/fact.h b/libc3/fact.h
index f0fd778..d92af14 100644
--- a/libc3/fact.h
+++ b/libc3/fact.h
@@ -19,7 +19,8 @@
#define fact_clean(fact) do {} while(0)
s_fact * fact_init (s_fact *fact, const s_tag *subject,
const s_tag *predicate, const s_tag *object);
-s_fact * fact_init_cast (s_fact *fact, const s_tag *tag);
+s_fact * fact_init_cast (s_fact *fact, const s_sym *type,
+ const s_tag *tag);
s_fact * fact_init_copy (s_fact *fact, const s_fact *src);
/* Observers */
diff --git a/libc3/fn.c b/libc3/fn.c
index b528c8e..e2efcf7 100644
--- a/libc3/fn.c
+++ b/libc3/fn.c
@@ -20,6 +20,7 @@
#include "fn.h"
#include "fn_clause.h"
#include "list.h"
+#include "sym.h"
#include "tag_type.h"
s8 fn_arity (const s_fn *fn)
@@ -79,8 +80,11 @@ s_fn * fn_init_1 (s_fn *fn, char *p)
return fn;
}
-s_fn * fn_init_cast (s_fn *fn, const s_tag *tag)
+s_fn * fn_init_cast (s_fn *fn, const s_sym *type, const s_tag *tag)
{
+ assert(fn);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_FN:
return fn_init_copy(fn, &tag->data.fn);
@@ -89,7 +93,13 @@ s_fn * fn_init_cast (s_fn *fn, const s_tag *tag)
}
err_write_1("fn_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Fn");
+ if (type == &g_sym_Fn)
+ err_puts(" to Fn");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Fn");
+ }
assert(! "fn_init_cast: cannot cast to Fn");
return NULL;
}
diff --git a/libc3/fn.h b/libc3/fn.h
index 4f678e8..b76e111 100644
--- a/libc3/fn.h
+++ b/libc3/fn.h
@@ -25,7 +25,7 @@
void fn_clean (s_fn *fn);
s_fn * fn_init (s_fn *fn);
s_fn * fn_init_1 (s_fn *fn, char *p);
-s_fn * fn_init_cast (s_fn *fn, const s_tag *tag);
+s_fn * fn_init_cast (s_fn *fn, const s_sym *type, const s_tag *tag);
s_fn * fn_init_copy (s_fn *fn, const s_fn *src);
/* Heap-allocation functions, call fn_delete after use. */
diff --git a/libc3/ident.h b/libc3/ident.h
index 0c5b9cb..cd1d38f 100644
--- a/libc3/ident.h
+++ b/libc3/ident.h
@@ -23,7 +23,8 @@
s_ident * ident_init (s_ident *ident, const s_sym *module,
const s_sym *sym);
s_ident * ident_init_1 (s_ident *ident, const char *p);
-s_ident * ident_init_cast (s_ident *ident, const s_tag *tag);
+s_ident * ident_init_cast (s_ident *ident, const s_sym *type,
+ const s_tag *tag);
s_ident * ident_init_copy (s_ident *ident, const s_ident *src);
/* Modifiers */
diff --git a/libc3/integer.c b/libc3/integer.c
index 6ebe061..ad9bdd9 100644
--- a/libc3/integer.c
+++ b/libc3/integer.c
@@ -134,8 +134,10 @@ uw integer_bytes (const s_integer *i)
return (integer_bits(i) + 7) / 8;
}
-s_integer * integer_init_cast (s_integer *a, const s_tag *tag)
+s_integer * integer_init_cast (s_integer *a, const s_sym *type,
+ const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
return integer_init_u8(a, tag->data.bool ? 1 : 0);
diff --git a/libc3/integer.h b/libc3/integer.h
index 0513618..ab2bcd9 100644
--- a/libc3/integer.h
+++ b/libc3/integer.h
@@ -26,7 +26,8 @@
/* Stack allocation compatible functions */
s_integer * integer_init (s_integer *i);
s_integer * integer_init_1 (s_integer *i, const char *p);
-s_integer * integer_init_cast (s_integer *a, const s_tag *tag);
+s_integer * integer_init_cast (s_integer *a, const s_sym *type,
+ const s_tag *tag);
s_integer * integer_init_copy (s_integer *a, const s_integer *src);
s_integer * integer_init_f32 (s_integer *a, f32 x);
s_integer * integer_init_f64 (s_integer *a, f64 x);
diff --git a/libc3/list.c b/libc3/list.c
index 1110f51..5ecbef8 100644
--- a/libc3/list.c
+++ b/libc3/list.c
@@ -74,8 +74,12 @@ s_list * list_init_1 (s_list *list, const char *p, s_list *next)
return list;
}
-s_list ** list_init_cast (s_list **list, const s_tag *tag)
+s_list ** list_init_cast (s_list **list, const s_sym *type,
+ const s_tag *tag)
{
+ assert(list);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_LIST:
return list_init_copy(list,
@@ -85,7 +89,13 @@ s_list ** list_init_cast (s_list **list, const s_tag *tag)
}
err_write_1("list_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to List");
+ if (type == &g_sym_List)
+ err_puts(" to List");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka List");
+ }
assert(! "list_init_cast: cannot cast to List");
return NULL;
}
diff --git a/libc3/list.h b/libc3/list.h
index 225d987..d01c361 100644
--- a/libc3/list.h
+++ b/libc3/list.h
@@ -28,7 +28,8 @@
void list_clean (s_list *list);
s_list * list_init (s_list *list, s_list *next);
s_list * list_init_1 (s_list *list, const char *p, s_list *next);
-s_list ** list_init_cast (s_list **list, const s_tag *tag);
+s_list ** list_init_cast (s_list **list, const s_sym *type,
+ const s_tag *tag);
s_list ** list_init_copy (s_list **list, const s_list * const *src);
s_list * list_init_copy_tag (s_list *list, const s_tag *tag,
s_list *next);
diff --git a/libc3/ptag.c b/libc3/ptag.c
index 39c0091..a2cef3e 100644
--- a/libc3/ptag.c
+++ b/libc3/ptag.c
@@ -12,10 +12,15 @@
*/
#include "assert.h"
#include "ptag.h"
+#include "sym.h"
#include "tag_type.h"
-p_tag * ptag_init_cast (p_tag *ptag, const s_tag *tag)
+p_tag * ptag_init_cast (p_tag *ptag, const s_sym *type,
+ const s_tag *tag)
{
+ assert(ptag);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_PTAG:
return ptag_init_copy(ptag, &tag->data.ptag);
@@ -24,7 +29,13 @@ p_tag * ptag_init_cast (p_tag *ptag, const s_tag *tag)
}
err_write_1("ptag_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Ptag");
+ if (type == &g_sym_Ptag)
+ err_puts(" to Ptag");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Ptag");
+ }
assert(! "ptag_init_cast: cannot cast to Ptag");
return NULL;
}
diff --git a/libc3/ptag.h b/libc3/ptag.h
index 865d87c..b35cb74 100644
--- a/libc3/ptag.h
+++ b/libc3/ptag.h
@@ -15,7 +15,8 @@
#include "types.h"
-p_tag * ptag_init_cast (p_tag *dest, const s_tag *tag);
+p_tag * ptag_init_cast (p_tag *dest, const s_sym *type,
+ const s_tag *tag);
p_tag * ptag_init_copy (p_tag *dest, const p_tag *src);
#endif /* LIBC3_PTAG_H */
diff --git a/libc3/ptr.c b/libc3/ptr.c
index 8321198..9bccfdb 100644
--- a/libc3/ptr.c
+++ b/libc3/ptr.c
@@ -14,6 +14,7 @@
#include "assert.h"
#include "integer.h"
#include "ptr.h"
+#include "sym.h"
#include "tag_type.h"
void ptr_delete (u_ptr_w *ptr)
@@ -31,10 +32,12 @@ u_ptr_w * ptr_init (u_ptr_w *ptr, void *p)
return ptr;
}
-u_ptr_w * ptr_init_cast (u_ptr_w *p, const s_tag *tag)
+u_ptr_w * ptr_init_cast (u_ptr_w *p, const s_sym *type,
+ const s_tag *tag)
{
- assert(tag);
assert(p);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_F32: p->p = (void *) ((uw) tag->data.f32); return p;
case TAG_F64: p->p = (void *) ((uw) tag->data.f64); return p;
@@ -57,7 +60,13 @@ u_ptr_w * ptr_init_cast (u_ptr_w *p, const s_tag *tag)
}
err_write_1("ptr_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Ptr");
+ if (type == &g_sym_Ptr)
+ err_puts(" to Ptr");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Ptr");
+ }
assert(! "ptr_cast: cannot cast to Ptr");
return NULL;
}
diff --git a/libc3/ptr.h b/libc3/ptr.h
index 5d97aea..26ff8e0 100644
--- a/libc3/ptr.h
+++ b/libc3/ptr.h
@@ -17,7 +17,8 @@
/* Stack-allocation compatible functions. */
u_ptr_w * ptr_init (u_ptr_w *ptr, void *p);
-u_ptr_w * ptr_init_cast (u_ptr_w *ptr, const s_tag *tag);
+u_ptr_w * ptr_init_cast (u_ptr_w *ptr, const s_sym *type,
+ const s_tag *tag);
u_ptr_w * ptr_init_copy (u_ptr_w *ptr, const u_ptr_w *src);
/* Heap-allocation functions, call ptr_delete after use. */
diff --git a/libc3/ptr_free.c b/libc3/ptr_free.c
index 06f8e0c..19fdabd 100644
--- a/libc3/ptr_free.c
+++ b/libc3/ptr_free.c
@@ -14,6 +14,7 @@
#include "assert.h"
#include "integer.h"
#include "ptr_free.h"
+#include "sym.h"
#include "tag_type.h"
void ptr_free_clean (u_ptr_w *ptr_free)
@@ -38,10 +39,12 @@ u_ptr_w * ptr_free_init (u_ptr_w *ptr_free, void *p)
return ptr_free;
}
-u_ptr_w * ptr_free_init_cast (u_ptr_w *p, const s_tag *tag)
+u_ptr_w * ptr_free_init_cast (u_ptr_w *p, const s_sym *type,
+ const s_tag *tag)
{
- assert(tag);
assert(p);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_F32: p->p = (void *) ((uw) tag->data.f32); return p;
case TAG_F64: p->p = (void *) ((uw) tag->data.f64); return p;
@@ -63,7 +66,13 @@ u_ptr_w * ptr_free_init_cast (u_ptr_w *p, const s_tag *tag)
}
err_write_1("ptr_free_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to PtrFree");
+ if (type == &g_sym_PtrFree)
+ err_puts(" to PtrFree");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka PtrFree");
+ }
assert(! "ptr_free_init_cast: cannot cast to PtrFree");
return NULL;
}
diff --git a/libc3/ptr_free.h b/libc3/ptr_free.h
index 633e417..4123e25 100644
--- a/libc3/ptr_free.h
+++ b/libc3/ptr_free.h
@@ -19,7 +19,8 @@
after use. */
void ptr_free_clean (u_ptr_w *ptr_free);
u_ptr_w * ptr_free_init (u_ptr_w *ptr_free, void *p);
-u_ptr_w * ptr_free_init_cast (u_ptr_w *ptr_free, const s_tag *tag);
+u_ptr_w * ptr_free_init_cast (u_ptr_w *ptr_free, const s_sym *type,
+ const s_tag *tag);
u_ptr_w * ptr_free_init_copy (u_ptr_w *ptr_free, const u_ptr_w *src);
/* Heap-allocation functions, call ptr_free_delete after use. */
diff --git a/libc3/quote.c b/libc3/quote.c
index 7b087fd..053dc43 100644
--- a/libc3/quote.c
+++ b/libc3/quote.c
@@ -12,6 +12,7 @@
*/
#include "assert.h"
#include "quote.h"
+#include "sym.h"
#include "tag.h"
void quote_clean (s_quote *quote)
@@ -26,8 +27,12 @@ s_quote * quote_init (s_quote *quote, const s_tag *tag)
return quote;
}
-s_quote * quote_init_cast (s_quote *quote, const s_tag *tag)
+s_quote * quote_init_cast (s_quote *quote, const s_sym *type,
+ const s_tag *tag)
{
+ assert(quote);
+ assert(type);
+ assert(tag);
switch (tag->type) {
case TAG_QUOTE:
return quote_init_copy(quote, &tag->data.quote);
@@ -36,7 +41,13 @@ s_quote * quote_init_cast (s_quote *quote, const s_tag *tag)
}
err_write_1("quote_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Quote");
+ if (type == &g_sym_Quote)
+ err_puts(" to Quote");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Quote");
+ }
assert(! "quote_init_cast: cannot cast to Quote");
return NULL;
}
diff --git a/libc3/quote.h b/libc3/quote.h
index 51a4127..14806fd 100644
--- a/libc3/quote.h
+++ b/libc3/quote.h
@@ -19,7 +19,8 @@
void quote_clean (s_quote *quote);
s_quote * quote_init (s_quote *quote, const s_tag *tag);
s_quote * quote_init_1 (s_quote *quote, const s8 *p);
-s_quote * quote_init_cast (s_quote *quote, const s_tag *src);
+s_quote * quote_init_cast (s_quote *quote, const s_sym *type,
+ const s_tag *src);
s_quote * quote_init_copy (s_quote *quote, const s_quote *src);
#endif /* LIBC3_QUOTE_H */
diff --git a/libc3/ratio.c b/libc3/ratio.c
index 1a0b8da..61519a9 100644
--- a/libc3/ratio.c
+++ b/libc3/ratio.c
@@ -513,25 +513,36 @@ s_ratio * ratio_sub (const s_ratio *a, const s_ratio *b,
return dest;
}
-f32 ratio_to_f32(const s_ratio *r)
+f32 ratio_to_f32 (const s_ratio *r)
{
+ f32 numerator;
+ f32 denominator;
assert(r);
assert(integer_is_positive(&r->denominator));
-
- f32 numerator = integer_to_f32(&r->numerator);
- f32 denominator = integer_to_f32(&r->denominator);
-
+ numerator = integer_to_f32(&r->numerator);
+ denominator = integer_to_f32(&r->denominator);
return numerator / denominator;
}
-f64 ratio_to_f64(const s_ratio *r)
+f64 ratio_to_f64 (const s_ratio *r)
{
+ f64 numerator;
+ f64 denominator;
assert(r);
assert(integer_is_positive(&r->denominator));
+ numerator = integer_to_f64(&r->numerator);
+ denominator = integer_to_f64(&r->denominator);
+ return numerator / denominator;
+}
- f64 numerator = integer_to_f64(&r->numerator);
- f64 denominator = integer_to_f64(&r->denominator);
-
+f128 ratio_to_f128 (const s_ratio *r)
+{
+ f128 numerator;
+ f128 denominator;
+ assert(r);
+ assert(integer_is_positive(&r->denominator));
+ numerator = integer_to_f128(&r->numerator);
+ denominator = integer_to_f128(&r->denominator);
return numerator / denominator;
}
diff --git a/libc3/ratio.h b/libc3/ratio.h
index 6ca3822..4d9cf54 100644
--- a/libc3/ratio.h
+++ b/libc3/ratio.h
@@ -51,16 +51,17 @@ bool ratio_is_negative (const s_ratio *r);
bool ratio_is_zero (const s_ratio *r);
f32 ratio_to_f32 (const s_ratio *r);
f64 ratio_to_f64 (const s_ratio *r);
-sw ratio_to_sw (const s_ratio *r);
-s64 ratio_to_s64 (const s_ratio *r);
-s32 ratio_to_s32 (const s_ratio *r);
-s16 ratio_to_s16 (const s_ratio *r);
+f128 ratio_to_f128 (const s_ratio *r);
s8 ratio_to_s8 (const s_ratio *r);
-uw ratio_to_uw (const s_ratio *r);
-u64 ratio_to_u64 (const s_ratio *r);
-u32 ratio_to_u32 (const s_ratio *r);
-u16 ratio_to_u16 (const s_ratio *r);
+s16 ratio_to_s16 (const s_ratio *r);
+s32 ratio_to_s32 (const s_ratio *r);
+s64 ratio_to_s64 (const s_ratio *r);
+sw ratio_to_sw (const s_ratio *r);
u8 ratio_to_u8 (const s_ratio *r);
+u16 ratio_to_u16 (const s_ratio *r);
+u32 ratio_to_u32 (const s_ratio *r);
+u64 ratio_to_u64 (const s_ratio *r);
+uw ratio_to_uw (const s_ratio *r);
/* Operators. */
s_ratio * ratio_add (const s_ratio *a, const s_ratio *b,
diff --git a/libc3/s.c.in b/libc3/s.c.in
index 1af4c4a..050c589 100644
--- a/libc3/s.c.in
+++ b/libc3/s.c.in
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "s_bits$.h"
-s_bits$ * s_bits$_init_cast (s_bits$ *s, const s_tag *tag)
+s_bits$ * s_bits$_init_cast
+(s_bits$ *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/s.h.in b/libc3/s.h.in
index 8b99d50..3eddf8d 100644
--- a/libc3/s.h.in
+++ b/libc3/s.h.in
@@ -16,7 +16,8 @@
#include "types.h"
-s_bits$ * s_bits$_init_cast (s_bits$ *s, const s_tag *tag);
+s_bits$ * s_bits$_init_cast
+(s_bits$ *s, const s_sym *type, const s_tag *tag);
s_bits$ * s_bits$_init_copy (s_bits$ *s, const s_bits$ *src);
s_bits$ * s_bits$_random (s_bits$ *s);
u_bits$ * s_bits$_random_uniform (s_bits$ *s, s_bits$ min, s_bits$ max);
diff --git a/libc3/s16.c b/libc3/s16.c
index 82080ea..5f7a099 100644
--- a/libc3/s16.c
+++ b/libc3/s16.c
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "s16.h"
-s16 * s16_init_cast (s16 *s, const s_tag *tag)
+s16 * s16_init_cast
+(s16 *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/s16.h b/libc3/s16.h
index 9ab4e61..b5174bd 100644
--- a/libc3/s16.h
+++ b/libc3/s16.h
@@ -16,7 +16,8 @@
#include "types.h"
-s16 * s16_init_cast (s16 *s, const s_tag *tag);
+s16 * s16_init_cast
+(s16 *s, const s_sym *type, const s_tag *tag);
s16 * s16_init_copy (s16 *s, const s16 *src);
s16 * s16_random (s16 *s);
u16 * s16_random_uniform (s16 *s, s16 min, s16 max);
diff --git a/libc3/s32.c b/libc3/s32.c
index e4e4bcd..213633a 100644
--- a/libc3/s32.c
+++ b/libc3/s32.c
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "s32.h"
-s32 * s32_init_cast (s32 *s, const s_tag *tag)
+s32 * s32_init_cast
+(s32 *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/s32.h b/libc3/s32.h
index 7b64000..b9b119f 100644
--- a/libc3/s32.h
+++ b/libc3/s32.h
@@ -16,7 +16,8 @@
#include "types.h"
-s32 * s32_init_cast (s32 *s, const s_tag *tag);
+s32 * s32_init_cast
+(s32 *s, const s_sym *type, const s_tag *tag);
s32 * s32_init_copy (s32 *s, const s32 *src);
s32 * s32_random (s32 *s);
u32 * s32_random_uniform (s32 *s, s32 min, s32 max);
diff --git a/libc3/s64.c b/libc3/s64.c
index 6dd7df0..644a445 100644
--- a/libc3/s64.c
+++ b/libc3/s64.c
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "s64.h"
-s64 * s64_init_cast (s64 *s, const s_tag *tag)
+s64 * s64_init_cast
+(s64 *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/s64.h b/libc3/s64.h
index c864cf3..cb4c0f2 100644
--- a/libc3/s64.h
+++ b/libc3/s64.h
@@ -16,7 +16,8 @@
#include "types.h"
-s64 * s64_init_cast (s64 *s, const s_tag *tag);
+s64 * s64_init_cast
+(s64 *s, const s_sym *type, const s_tag *tag);
s64 * s64_init_copy (s64 *s, const s64 *src);
s64 * s64_random (s64 *s);
u64 * s64_random_uniform (s64 *s, s64 min, s64 max);
diff --git a/libc3/s8.c b/libc3/s8.c
index abe667b..9fb04c3 100644
--- a/libc3/s8.c
+++ b/libc3/s8.c
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "s8.h"
-s8 * s8_init_cast (s8 *s, const s_tag *tag)
+s8 * s8_init_cast
+(s8 *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/s8.h b/libc3/s8.h
index 5c93749..9f7301e 100644
--- a/libc3/s8.h
+++ b/libc3/s8.h
@@ -16,7 +16,8 @@
#include "types.h"
-s8 * s8_init_cast (s8 *s, const s_tag *tag);
+s8 * s8_init_cast
+(s8 *s, const s_sym *type, const s_tag *tag);
s8 * s8_init_copy (s8 *s, const s8 *src);
s8 * s8_random (s8 *s);
u8 * s8_random_uniform (s8 *s, s8 min, s8 max);
diff --git a/libc3/str.c b/libc3/str.c
index f362688..17b8e5c 100644
--- a/libc3/str.c
+++ b/libc3/str.c
@@ -10,7 +10,7 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
-//#include <stdarg.h>
+#include <stdarg.h>
#include <string.h>
#include "alloc.h"
#include "assert.h"
@@ -148,9 +148,10 @@ s_str * str_init_alloc (s_str *str, uw size, const char *p)
return str;
}
-s_str * str_init_cast (s_str *str, const s_tag *tag)
+s_str * str_init_cast (s_str *str, const s_sym *type, const s_tag *tag)
{
assert(str);
+ assert(type);
assert(tag);
switch (tag->type) {
case TAG_S8:
@@ -182,7 +183,13 @@ s_str * str_init_cast (s_str *str, const s_tag *tag)
}
err_write_1("str_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Str");
+ if (type == &g_sym_Str)
+ err_puts(" to Str");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Str");
+ }
assert(! "str_init_cast: cannot cast to Str");
return NULL;
}
@@ -485,7 +492,7 @@ bool str_parse_eval (const s_str *str, s_tag *dest)
else {
if (! tag_init_call_cast(&tmp, &g_sym_Str))
goto restore;
- tmp.data.call.arguments->tag = list->tag;
+ list_next(tmp.data.call.arguments)->tag = list->tag;
}
list = list_next(list);
while (list) {
@@ -503,7 +510,7 @@ bool str_parse_eval (const s_str *str, s_tag *dest)
else {
if (! tag_init_call_cast(right, &g_sym_Str))
goto restore;
- right->data.call.arguments->tag = list->tag;
+ list_next(right->data.call.arguments)->tag = list->tag;
}
tmp = tmp1;
list = list_next(list);
diff --git a/libc3/str.h b/libc3/str.h
index c07fbb5..e77866e 100644
--- a/libc3/str.h
+++ b/libc3/str.h
@@ -34,7 +34,8 @@ void str_clean (s_str *str);
s_str * str_init (s_str *str, char *free, uw size, const char *p);
s_str * str_init_1 (s_str *str, char *free, const char *p);
s_str * str_init_alloc (s_str *str, uw size, const char *p);
-s_str * str_init_cast (s_str *str, const s_tag *tag);
+s_str * str_init_cast (s_str *str, const s_sym *type,
+ const s_tag *tag);
s_str * str_init_cat (s_str *str, const s_str *a, const s_str *b);
s_str * str_init_copy (s_str *str, const s_str *src);
s_str * str_init_copy_1 (s_str *str, const char *p);
diff --git a/libc3/struct.c b/libc3/struct.c
index 5767c8a..a2e1ac3 100644
--- a/libc3/struct.c
+++ b/libc3/struct.c
@@ -113,19 +113,22 @@ s_struct * struct_init_1 (s_struct *s, const s8 *p)
return s;
}
-s_struct * struct_init_cast (s_struct *s, const s_tag *tag)
+s_struct * struct_init_cast (s_struct *s, const s_sym *type, const s_tag *tag)
{
assert(s);
assert(tag);
switch (tag->type) {
case TAG_STRUCT:
- return struct_init_copy(s, &tag->data.struct_);
+ if (type == tag->data.struct_.type->module)
+ return struct_init_copy(s, &tag->data.struct_);
default:
break;
}
err_write_1("struct_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Struct");
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_write_1("\n");
assert(! "struct_init_cast: cannot cast to Struct");
return NULL;
}
diff --git a/libc3/struct.h b/libc3/struct.h
index 1d139b3..c6f7d9a 100644
--- a/libc3/struct.h
+++ b/libc3/struct.h
@@ -24,7 +24,8 @@
void struct_clean (s_struct *s);
s_struct * struct_init (s_struct *s, const s_sym *module);
s_struct * struct_init_1 (s_struct *s, const s8 *p);
-s_struct * struct_init_cast (s_struct *s, const s_tag *tag);
+s_struct * struct_init_cast (s_struct *s, const s_sym *type,
+ const s_tag *tag);
s_struct * struct_init_copy (s_struct *s, const s_struct *src);
s_struct * struct_init_from_lists (s_struct *s, const s_sym *module,
const s_list *keys,
diff --git a/libc3/sw.c b/libc3/sw.c
index d2fa600..e79de95 100644
--- a/libc3/sw.c
+++ b/libc3/sw.c
@@ -21,8 +21,10 @@
#include "ratio.h"
#include "sw.h"
-sw * sw_init_cast (sw *s, const s_tag *tag)
+sw * sw_init_cast
+(sw *s, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*s = tag->data.bool ? 1 : 0;
diff --git a/libc3/sw.h b/libc3/sw.h
index 14d155b..38cc5a2 100644
--- a/libc3/sw.h
+++ b/libc3/sw.h
@@ -16,7 +16,8 @@
#include "types.h"
-sw * sw_init_cast (sw *s, const s_tag *tag);
+sw * sw_init_cast
+(sw *s, const s_sym *type, const s_tag *tag);
sw * sw_init_copy (sw *s, const sw *src);
sw * sw_random (sw *s);
uw * sw_random_uniform (sw *s, sw min, sw max);
diff --git a/libc3/sym.c b/libc3/sym.c
index f25bbd4..857fb02 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -251,9 +251,11 @@ const s_sym ** sym_init_1 (const s_sym **sym, const char *p)
return sym;
}
-const s_sym ** sym_init_cast (const s_sym **sym, const s_tag *tag)
+const s_sym ** sym_init_cast (const s_sym **sym, const s_sym *type,
+ const s_tag *tag)
{
assert(sym);
+ assert(type);
assert(tag);
switch (tag->type) {
case TAG_STR:
@@ -265,7 +267,13 @@ const s_sym ** sym_init_cast (const s_sym **sym, const s_tag *tag)
}
err_write_1("sym_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Sym");
+ if (type == &g_sym_Sym)
+ err_puts(" to Sym");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Sym");
+ }
assert(! "sym_init_cast: cannot cast to Sym");
return NULL;
}
diff --git a/libc3/sym.h b/libc3/sym.h
index 4f8cf97..8ac5f8e 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -108,7 +108,8 @@ extern const s_sym g_sym_x;
const s_sym * sym_1 (const char *p);
const s_sym ** sym_init_1 (const s_sym **sym, const char *p);
-const s_sym ** sym_init_cast (const s_sym **sym, const s_tag *tag);
+const s_sym ** sym_init_cast (const s_sym **sym, const s_sym *type,
+ const s_tag *tag);
const s_sym ** sym_init_copy (const s_sym **sym,
const s_sym * const *src);
void sym_init_g_sym (void);
diff --git a/libc3/tuple.c b/libc3/tuple.c
index e1fb62d..0f30abe 100644
--- a/libc3/tuple.c
+++ b/libc3/tuple.c
@@ -17,6 +17,7 @@
#include "buf_inspect.h"
#include "buf_parse.h"
#include "io.h"
+#include "sym.h"
#include "tuple.h"
#include "tag.h"
@@ -86,7 +87,8 @@ s_tuple * tuple_init_2 (s_tuple *tuple, const s_tag *a, const s_tag *b)
return tuple;
}
-s_tuple * tuple_init_cast (s_tuple *tuple, const s_tag *tag)
+s_tuple * tuple_init_cast (s_tuple *tuple, const s_sym *type,
+ const s_tag *tag)
{
switch (tag->type) {
case TAG_TUPLE:
@@ -96,7 +98,13 @@ s_tuple * tuple_init_cast (s_tuple *tuple, const s_tag *tag)
}
err_write_1("tuple_init_cast: cannot cast ");
err_write_1(tag_type_to_string(tag->type));
- err_puts(" to Tuple");
+ if (type == &g_sym_Tuple)
+ err_puts(" to Tuple");
+ else {
+ err_write_1(" to ");
+ err_inspect_sym(&type);
+ err_puts(" aka Tuple");
+ }
assert(! "tuple_init_cast: cannot cast to Tuple");
return NULL;
}
diff --git a/libc3/tuple.h b/libc3/tuple.h
index ce576e0..3ca22ab 100644
--- a/libc3/tuple.h
+++ b/libc3/tuple.h
@@ -26,7 +26,8 @@
s_tuple * tuple_init (s_tuple *tuple, uw count);
s_tuple * tuple_init_1 (s_tuple *tuple, const char *p);
s_tuple * tuple_init_2 (s_tuple *tuple, const s_tag *a, const s_tag *b);
-s_tuple * tuple_init_cast (s_tuple *tuple, const s_tag *tag);
+s_tuple * tuple_init_cast (s_tuple *tuple, const s_sym *type,
+ const s_tag *tag);
s_tuple * tuple_init_copy (s_tuple *tuple, const s_tuple *src);
void tuple_clean (s_tuple *tuple);
diff --git a/libc3/u.c.in b/libc3/u.c.in
index 1423f0a..52cfba1 100644
--- a/libc3/u.c.in
+++ b/libc3/u.c.in
@@ -20,8 +20,10 @@
#include "tag.h"
#include "u_bits$.h"
-u_bits$ * u_bits$_init_cast (u_bits$ *u, const s_tag *tag)
+u_bits$ * u_bits$_init_cast
+(u_bits$ *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/u.h.in b/libc3/u.h.in
index 3b3739e..1eca73b 100644
--- a/libc3/u.h.in
+++ b/libc3/u.h.in
@@ -16,7 +16,9 @@
#include "types.h"
-u_bits$ * u_bits$_init_cast (u_bits$ *u, const s_tag *tag);
+u_bits$ * u_bits$_init_cast
+(u_bits$ *u, const s_sym *type, const s_tag *tag);
+
u_bits$ * u_bits$_init_copy (u_bits$ *u, const u_bits$ *src);
u_bits$ * u_bits$_random (u_bits$ *u);
u_bits$ * u_bits$_random_uniform (u_bits$ *u, u_bits$ max);
diff --git a/libc3/u16.c b/libc3/u16.c
index 3df8aa7..66afa49 100644
--- a/libc3/u16.c
+++ b/libc3/u16.c
@@ -20,8 +20,10 @@
#include "tag.h"
#include "u16.h"
-u16 * u16_init_cast (u16 *u, const s_tag *tag)
+u16 * u16_init_cast
+(u16 *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/u16.h b/libc3/u16.h
index 35e2e80..a53a97a 100644
--- a/libc3/u16.h
+++ b/libc3/u16.h
@@ -16,7 +16,9 @@
#include "types.h"
-u16 * u16_init_cast (u16 *u, const s_tag *tag);
+u16 * u16_init_cast
+(u16 *u, const s_sym *type, const s_tag *tag);
+
u16 * u16_init_copy (u16 *u, const u16 *src);
u16 * u16_random (u16 *u);
u16 * u16_random_uniform (u16 *u, u16 max);
diff --git a/libc3/u32.c b/libc3/u32.c
index 04f2656..9c01855 100644
--- a/libc3/u32.c
+++ b/libc3/u32.c
@@ -20,8 +20,10 @@
#include "tag.h"
#include "u32.h"
-u32 * u32_init_cast (u32 *u, const s_tag *tag)
+u32 * u32_init_cast
+(u32 *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/u32.h b/libc3/u32.h
index a58aae1..ece4abe 100644
--- a/libc3/u32.h
+++ b/libc3/u32.h
@@ -16,7 +16,9 @@
#include "types.h"
-u32 * u32_init_cast (u32 *u, const s_tag *tag);
+u32 * u32_init_cast
+(u32 *u, const s_sym *type, const s_tag *tag);
+
u32 * u32_init_copy (u32 *u, const u32 *src);
u32 * u32_random (u32 *u);
u32 * u32_random_uniform (u32 *u, u32 max);
diff --git a/libc3/u64.c b/libc3/u64.c
index 2e93fdb..87c64e8 100644
--- a/libc3/u64.c
+++ b/libc3/u64.c
@@ -20,8 +20,10 @@
#include "tag.h"
#include "u64.h"
-u64 * u64_init_cast (u64 *u, const s_tag *tag)
+u64 * u64_init_cast
+(u64 *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/u64.h b/libc3/u64.h
index 6033877..05802cb 100644
--- a/libc3/u64.h
+++ b/libc3/u64.h
@@ -16,7 +16,9 @@
#include "types.h"
-u64 * u64_init_cast (u64 *u, const s_tag *tag);
+u64 * u64_init_cast
+(u64 *u, const s_sym *type, const s_tag *tag);
+
u64 * u64_init_copy (u64 *u, const u64 *src);
u64 * u64_random (u64 *u);
u64 * u64_random_uniform (u64 *u, u64 max);
diff --git a/libc3/u8.c b/libc3/u8.c
index d226ccd..090aa92 100644
--- a/libc3/u8.c
+++ b/libc3/u8.c
@@ -20,8 +20,10 @@
#include "tag.h"
#include "u8.h"
-u8 * u8_init_cast (u8 *u, const s_tag *tag)
+u8 * u8_init_cast
+(u8 *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/u8.h b/libc3/u8.h
index 91a7d92..0d6622e 100644
--- a/libc3/u8.h
+++ b/libc3/u8.h
@@ -16,7 +16,9 @@
#include "types.h"
-u8 * u8_init_cast (u8 *u, const s_tag *tag);
+u8 * u8_init_cast
+(u8 *u, const s_sym *type, const s_tag *tag);
+
u8 * u8_init_copy (u8 *u, const u8 *src);
u8 * u8_random (u8 *u);
u8 * u8_random_uniform (u8 *u, u8 max);
diff --git a/libc3/uw.c b/libc3/uw.c
index 5b6e825..dfc0974 100644
--- a/libc3/uw.c
+++ b/libc3/uw.c
@@ -20,8 +20,10 @@
#include "tag.h"
#include "uw.h"
-uw * uw_init_cast (uw *u, const s_tag *tag)
+uw * uw_init_cast
+(uw *u, const s_sym *type, const s_tag *tag)
{
+ (void) type;
switch (tag->type) {
case TAG_BOOL:
*u = tag->data.bool ? 1 : 0;
diff --git a/libc3/uw.h b/libc3/uw.h
index 868a43e..06b1fb9 100644
--- a/libc3/uw.h
+++ b/libc3/uw.h
@@ -16,7 +16,9 @@
#include "types.h"
-uw * uw_init_cast (uw *u, const s_tag *tag);
+uw * uw_init_cast
+(uw *u, const s_sym *type, const s_tag *tag);
+
uw * uw_init_copy (uw *u, const uw *src);
uw * uw_random (uw *u);
uw * uw_random_uniform (uw *u, uw max);
diff --git a/libc3/void.c b/libc3/void.c
index ca43b28..3074a63 100644
--- a/libc3/void.c
+++ b/libc3/void.c
@@ -12,8 +12,9 @@
*/
#include "void.h"
-void * void_init_cast (void *v, const s_tag *src)
+void * void_init_cast (void *v, const s_sym *type, const s_tag *src)
{
(void) src;
+ (void) type;
return v;
}
diff --git a/libc3/void.h b/libc3/void.h
index a55318a..28e0c9f 100644
--- a/libc3/void.h
+++ b/libc3/void.h
@@ -22,6 +22,6 @@
#include "types.h"
/* Operators. */
-void * void_init_cast (void *v, const s_tag *src);
+void * void_init_cast (void *v, const s_sym *type, const s_tag *src);
#endif /* LIBC3_VOID_H */