diff --git a/libc3/list_init.h b/libc3/list_init.h
index 5ad281a..61c662c 100644
--- a/libc3/list_init.h
+++ b/libc3/list_init.h
@@ -28,9 +28,9 @@ s_list * list_init_f64 (s_list *list, f64 f, s_list *next);
s_list * list_init_ident (s_list *list, const s_ident *ident,
s_list *next);
s_list * list_init_ident_1 (s_list *list, const s8 *p, s_list *next);
+s_list * list_init_integer_1 (s_list *list, const s8 *p, s_list *next);
s_list * list_init_integer_copy (s_list *list, const s_integer *i,
s_list *next);
-s_list * list_init_integer_1 (s_list *list, const s8 *p, s_list *next);
s_list * list_init_integer_zero (s_list *list, s_list *next);
@@ -46,11 +46,12 @@ s_list * list_init_str_1 (s_list *list, s8 *p_free, const s8 *p,
s_list *next);
s_list * list_init_sw (s_list *list, sw i, s_list *next);
s_list * list_init_sym (s_list *list, const s_sym *sym, s_list *next);
+s_list * list_init_sym_1 (s_list *list, const s8 *p, s_list *next);
s_list * list_init_tuple (s_list *list, uw count, s_list *next);
s_list * list_init_tuple_2 (s_list *list, const s_tag *a,
const s_tag *b, s_list *next);
s_list * list_init_time (s_list *list, s_list *next);
-s_list * list_init_u8 (s_list *list, u8 i, s_list *next);
+s_list * list_init_u8 (s_list *list, u8 i, s_list *next);
s_list * list_init_u16 (s_list *list, u16 i, s_list *next);
s_list * list_init_u32 (s_list *list, u32 i, s_list *next);
s_list * list_init_u64 (s_list *list, u64 i, s_list *next);
@@ -69,8 +70,8 @@ s_list * list_new_f32 (f32 f, s_list *next);
s_list * list_new_f64 (f64 f, s_list *next);
s_list * list_new_ident (const s_ident *ident, s_list *next);
s_list * list_new_ident_1 (const s8 *p, s_list *next);
-s_list * list_new_integer_copy (const s_integer *i, s_list *next);
s_list * list_new_integer_1 (const s8 *p, s_list *next);
+s_list * list_new_integer_copy (const s_integer *i, s_list *next);
s_list * list_new_integer_zero (s_list *next);
@@ -84,11 +85,12 @@ s_list * list_new_str (s8 *p_free, uw size, const s8 *p, s_list *next);
s_list * list_new_str_1 (s8 *p_free, const s8 *p, s_list *next);
s_list * list_new_sw (sw i, s_list *next);
s_list * list_new_sym (const s_sym *sym, s_list *next);
+s_list * list_new_sym_1 (const s8 *p, s_list *next);
s_list * list_new_tuple (uw count, s_list *next);
s_list * list_new_tuple_2 (const s_tag *a, const s_tag *b,
s_list *next);
s_list * list_new_time (s_list *next);
-s_list * list_new_u8 (u8 i, s_list *next);
+s_list * list_new_u8 (u8 i, s_list *next);
s_list * list_new_u16 (u16 i, s_list *next);
s_list * list_new_u32 (u32 i, s_list *next);
s_list * list_new_u64 (u64 i, s_list *next);
@@ -107,8 +109,8 @@ s_list * list_f32 (s_list *list, f32 f);
s_list * list_f64 (s_list *list, f64 f);
s_list * list_ident (s_list *list, const s_ident *ident);
s_list * list_ident_1 (s_list *list, const s8 *p);
-s_list * list_integer_copy (s_list *list, const s_integer *i);
s_list * list_integer_1 (s_list *list, const s8 *p);
+s_list * list_integer_copy (s_list *list, const s_integer *i);
s_list * list_integer_zero (s_list *list);
@@ -122,10 +124,11 @@ s_list * list_str (s_list *list, s8 *p_free, uw size, const s8 *p);
s_list * list_str_1 (s_list *list, s8 *p_free, const s8 *p);
s_list * list_sw (s_list *list, sw i);
s_list * list_sym (s_list *list, const s_sym *sym);
+s_list * list_sym_1 (s_list *list, const s8 *p);
s_list * list_tuple (s_list *list, uw count);
s_list * list_tuple_2 (s_list *list, const s_tag *a, const s_tag *b);
s_list * list_time (s_list *list);
-s_list * list_u8 (s_list *list, u8 i);
+s_list * list_u8 (s_list *list, u8 i);
s_list * list_u16 (s_list *list, u16 i);
s_list * list_u32 (s_list *list, u32 i);
s_list * list_u64 (s_list *list, u64 i);
diff --git a/libc3/sym.c b/libc3/sym.c
index 8d457db..cecdb79 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -94,6 +94,14 @@ bool sym_has_reserved_characters (const s_sym *sym)
return false;
}
+const s_sym ** sym_init_1 (const s_sym **sym, const s8 *p)
+{
+ assert(sym);
+ assert(p);
+ *sym = sym_1(p);
+ return sym;
+}
+
const s_sym ** sym_init_copy (const s_sym **sym,
const s_sym * const *src)
{
diff --git a/libc3/sym.h b/libc3/sym.h
index 47e8e70..189a148 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -27,6 +27,7 @@
#define SYM_MAX 1024
const s_sym * sym_1 (const s8 *p);
+const s_sym ** sym_init_1 (const s_sym **sym, const s8 *p);
const s_sym ** sym_init_copy (const s_sym **sym,
const s_sym * const *src);
diff --git a/libc3/tag.c b/libc3/tag.c
index 15a3129..c601d3f 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -389,6 +389,7 @@ uw tag_hash_uw (const s_tag *tag)
return hash_to_uw(&hash);
}
+/*
s_tag * tag_ident (s_tag *tag, const s_ident *x)
{
assert(tag);
@@ -402,6 +403,7 @@ s_tag * tag_ident_1 (s_tag *tag, const s8 *p)
tag_clean(tag);
return tag_init_ident_1(tag, p);
}
+*/
bool tag_ident_is_bound (const s_tag *tag)
{
@@ -450,6 +452,7 @@ s_tag * tag_init_bool (s_tag *tag, bool b)
return tag;
}
+/*
s_tag * tag_init_character (s_tag *tag, character c)
{
assert(tag);
@@ -494,7 +497,7 @@ s_tag * tag_init_ident_1 (s_tag *tag, const s8 *p)
ident_init_1(&tag->data.ident, p);
return tag;
}
-/*
+
s_tag * tag_init_integer (s_tag *tag, const s_integer *i)
{
assert(tag);
@@ -505,6 +508,7 @@ s_tag * tag_init_integer (s_tag *tag, const s_integer *i)
}
*/
+/*
s_tag * tag_init_integer_1 (s_tag *tag, const s8 *p)
{
s_buf buf;
@@ -521,6 +525,7 @@ s_tag * tag_init_integer_1 (s_tag *tag, const s8 *p)
buf_clean(&buf);
return tag;
}
+*/
s_tag * tag_init_integer_s64 (s_tag *tag, s64 s)
{
@@ -575,7 +580,6 @@ s_tag * tag_init_list_1 (s_tag *tag, const s8 *p)
buf_clean(&buf);
return tag;
}
-*/
s_tag * tag_init_map (s_tag *tag, uw count)
{
@@ -677,6 +681,7 @@ s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p)
tag->data.sym = sym_1(p);
return tag;
}
+*/
s_tag * tag_init_time (s_tag *tag)
{
@@ -704,6 +709,7 @@ s_tag * tag_init_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b)
return tag;
}
+/*
s_tag * tag_init_u8 (s_tag *tag, u8 i)
{
assert(tag);
@@ -764,6 +770,7 @@ s_tag * tag_init_void (s_tag *tag)
tag->type = TAG_VOID;
return tag;
}
+*/
s_str * tag_inspect (const s_tag *tag, s_str *dest)
{
@@ -988,6 +995,7 @@ s_tag * tag_new_1 (const s8 *p)
return tag_init_1(tag, p);
}
+/*
s_tag * tag_new_array (const s_sym *type, uw dimension,
const uw *dimensions)
{
@@ -1002,6 +1010,7 @@ s_tag * tag_new_array (const s_sym *type, uw dimension,
}
return dest;
}
+*/
s_tag * tag_new_copy (const s_tag *src)
{
@@ -1055,6 +1064,7 @@ s_tag * tag_paren (const s_tag *tag, s_tag *dest)
return tag_init_copy(dest, tag);
}
+/*
s_tag * tag_s8 (s_tag *tag, s8 x)
{
assert(tag);
@@ -1103,7 +1113,7 @@ s_tag * tag_str_1 (s_tag *tag, s8 *free, const s8 *p)
tag_clean(tag);
return tag_init_str_1(tag, free, p);
}
-
+*/
s_tag * tag_sym (s_tag *tag, const s_sym *x)
{
assert(tag);
@@ -1381,6 +1391,7 @@ void * tag_to_pointer (s_tag *tag, const s_sym *type)
}
+/*
s_tag * tag_tuple (s_tag *tag, uw count)
{
assert(tag);
@@ -1394,6 +1405,7 @@ s_tag * tag_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b)
tag_clean(tag);
return tag_init_tuple_2(tag, a, b);
}
+*/
const s_sym ** tag_type (const s_tag *tag, const s_sym **dest)
{
@@ -1403,6 +1415,7 @@ const s_sym ** tag_type (const s_tag *tag, const s_sym **dest)
return dest;
}
+/*
s_tag * tag_u8 (s_tag *tag, u8 x)
{
assert(tag);
@@ -1451,6 +1464,7 @@ s_tag * tag_void (s_tag *tag)
tag_clean(tag);
return tag_init_void(tag);
}
+*/
bool tag_xor (const s_tag *a, const s_tag *b)
{
diff --git a/libc3/tag_init.c b/libc3/tag_init.c
index fe5c68c..9d9e7df 100644
--- a/libc3/tag_init.c
+++ b/libc3/tag_init.c
@@ -119,28 +119,38 @@ s_tag * tag_init_ident_1 (s_tag *tag, const s8 *p)
return tag;
}
-s_tag * tag_init_integer_copy (s_tag *tag, const s_integer *i)
+s_tag * tag_init_integer_1 (s_tag *tag, const s8 *p)
{
s_tag tmp = {0};
assert(tag);
tmp.type = TAG_INTEGER;
- if (! integer_init_copy(&tmp.data.integer, i))
+ if (! integer_init_1(&tmp.data.integer, p))
return NULL;
*tag = tmp;
return tag;
}
-s_tag * tag_init_integer_1 (s_tag *tag, const s8 *p)
+s_tag * tag_init_integer_copy (s_tag *tag, const s_integer *i)
{
s_tag tmp = {0};
assert(tag);
tmp.type = TAG_INTEGER;
- if (! integer_init_1(&tmp.data.integer, p))
+ if (! integer_init_copy(&tmp.data.integer, i))
return NULL;
*tag = tmp;
return tag;
}
+s_tag * tag_init_list (s_tag *tag, s_list *list)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_LIST;
+ tmp.data.list = list;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_init_list_1 (s_tag *tag, const s8 *p, s_list *next)
{
s_tag tmp = {0};
@@ -256,6 +266,17 @@ s_tag * tag_init_sym (s_tag *tag, const s_sym *sym)
return tag;
}
+s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_SYM;
+ if (! sym_init_1(&tmp.data.sym, p))
+ return NULL;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_init_tuple (s_tag *tag, uw count)
{
s_tag tmp = {0};
@@ -278,12 +299,12 @@ s_tag * tag_init_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b)
return tag;
}
-s_tag * tag_init_u8 (s_tag *tag, u8 i)
+s_tag * tag_init_u8 (s_tag *tag, u8 i)
{
s_tag tmp = {0};
assert(tag);
tmp.type = TAG_U8;
- tmp.data.u8 = i;
+ tmp.data.u8 = i;
*tag = tmp;
return tag;
}
@@ -328,6 +349,15 @@ s_tag * tag_init_uw (s_tag *tag, uw i)
return tag;
}
+s_tag * tag_init_var (s_tag *tag)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tmp.type = TAG_VAR;
+ *tag = tmp;
+ return tag;
+}
+
s_tag * tag_init_void (s_tag *tag)
{
s_tag tmp = {0};
@@ -345,6 +375,7 @@ s_tag * tag_new_array (const s_sym *type, uw dimension,
warn("tag_new_array: calloc");
return NULL;
}
+ tag->type = TAG_ARRAY;
if (! array_init(&tag->data.array, type, dimension, dimensions)) {
free(tag);
return NULL;
@@ -359,6 +390,7 @@ s_tag * tag_new_bool (bool b)
warn("tag_new_bool: calloc");
return NULL;
}
+ tag->type = TAG_BOOL;
tag->data.bool = b;
return tag;
}
@@ -370,6 +402,7 @@ s_tag * tag_new_call (void)
warn("tag_new_call: calloc");
return NULL;
}
+ tag->type = TAG_CALL;
if (! call_init(&tag->data.call)) {
free(tag);
return NULL;
@@ -384,6 +417,7 @@ s_tag * tag_new_character (character c)
warn("tag_new_character: calloc");
return NULL;
}
+ tag->type = TAG_CHARACTER;
tag->data.character = c;
return tag;
}
@@ -395,6 +429,7 @@ s_tag * tag_new_f32 (f32 f)
warn("tag_new_f32: calloc");
return NULL;
}
+ tag->type = TAG_F32;
tag->data.f32 = f;
return tag;
}
@@ -406,6 +441,7 @@ s_tag * tag_new_f64 (f64 f)
warn("tag_new_f64: calloc");
return NULL;
}
+ tag->type = TAG_F64;
tag->data.f64 = f;
return tag;
}
@@ -417,6 +453,7 @@ s_tag * tag_new_ident (const s_ident *ident)
warn("tag_new_ident: calloc");
return NULL;
}
+ tag->type = TAG_IDENT;
tag->data.ident = *ident;
return tag;
}
@@ -428,6 +465,7 @@ s_tag * tag_new_ident_1 (const s8 *p)
warn("tag_new_ident_1: calloc");
return NULL;
}
+ tag->type = TAG_IDENT;
if (! ident_init_1(&tag->data.ident, p)) {
free(tag);
return NULL;
@@ -435,34 +473,48 @@ s_tag * tag_new_ident_1 (const s8 *p)
return tag;
}
-s_tag * tag_new_integer_copy (const s_integer *i)
+s_tag * tag_new_integer_1 (const s8 *p)
{
s_tag *tag;
if (! (tag = calloc(1, sizeof(s_tag)))) {
- warn("tag_new_integer_copy: calloc");
+ warn("tag_new_integer_1: calloc");
return NULL;
}
- if (! integer_init_copy(&tag->data.integer, i)) {
+ tag->type = TAG_INTEGER;
+ if (! integer_init_1(&tag->data.integer, p)) {
free(tag);
return NULL;
}
return tag;
}
-s_tag * tag_new_integer_1 (const s8 *p)
+s_tag * tag_new_integer_copy (const s_integer *i)
{
s_tag *tag;
if (! (tag = calloc(1, sizeof(s_tag)))) {
- warn("tag_new_integer_1: calloc");
+ warn("tag_new_integer_copy: calloc");
return NULL;
}
- if (! integer_init_1(&tag->data.integer, p)) {
+ tag->type = TAG_INTEGER;
+ if (! integer_init_copy(&tag->data.integer, i)) {
free(tag);
return NULL;
}
return tag;
}
+s_tag * tag_new_list (s_list *list)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_list: calloc");
+ return NULL;
+ }
+ tag->type = TAG_LIST;
+ tag->data.list = list;
+ return tag;
+}
+
s_tag * tag_new_list_1 (const s8 *p, s_list *next)
{
s_tag *tag;
@@ -470,6 +522,7 @@ s_tag * tag_new_list_1 (const s8 *p, s_list *next)
warn("tag_new_list_1: calloc");
return NULL;
}
+ tag->type = TAG_LIST;
if (! list_init_1(tag->data.list, p, next)) {
free(tag);
return NULL;
@@ -484,6 +537,7 @@ s_tag * tag_new_map (uw count)
warn("tag_new_map: calloc");
return NULL;
}
+ tag->type = TAG_MAP;
if (! map_init(&tag->data.map, count)) {
free(tag);
return NULL;
@@ -498,6 +552,7 @@ s_tag * tag_new_map_1 (const s8 *p)
warn("tag_new_map_1: calloc");
return NULL;
}
+ tag->type = TAG_MAP;
if (! map_init_1(&tag->data.map, p)) {
free(tag);
return NULL;
@@ -512,6 +567,7 @@ s_tag * tag_new_s8 (s8 i)
warn("tag_new_s8: calloc");
return NULL;
}
+ tag->type = TAG_S8;
tag->data.s8 = i;
return tag;
}
@@ -523,6 +579,7 @@ s_tag * tag_new_s16 (s16 i)
warn("tag_new_s16: calloc");
return NULL;
}
+ tag->type = TAG_S16;
tag->data.s16 = i;
return tag;
}
@@ -534,6 +591,7 @@ s_tag * tag_new_s32 (s32 i)
warn("tag_new_s32: calloc");
return NULL;
}
+ tag->type = TAG_S32;
tag->data.s32 = i;
return tag;
}
@@ -545,6 +603,7 @@ s_tag * tag_new_s64 (s64 i)
warn("tag_new_s64: calloc");
return NULL;
}
+ tag->type = TAG_S64;
tag->data.s64 = i;
return tag;
}
@@ -556,6 +615,7 @@ s_tag * tag_new_str (s8 *p_free, uw size, const s8 *p)
warn("tag_new_str: calloc");
return NULL;
}
+ tag->type = TAG_STR;
if (! str_init(&tag->data.str, p_free, size, p)) {
free(tag);
return NULL;
@@ -570,6 +630,7 @@ s_tag * tag_new_str_1 (s8 *p_free, const s8 *p)
warn("tag_new_str_1: calloc");
return NULL;
}
+ tag->type = TAG_STR;
if (! str_init_1(&tag->data.str, p_free, p)) {
free(tag);
return NULL;
@@ -584,6 +645,7 @@ s_tag * tag_new_sw (sw i)
warn("tag_new_sw: calloc");
return NULL;
}
+ tag->type = TAG_SW;
tag->data.sw = i;
return tag;
}
@@ -595,10 +657,26 @@ s_tag * tag_new_sym (const s_sym *sym)
warn("tag_new_sym: calloc");
return NULL;
}
+ tag->type = TAG_SYM;
tag->data.sym = sym;
return tag;
}
+s_tag * tag_new_sym_1 (const s8 *p)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_sym_1: calloc");
+ return NULL;
+ }
+ tag->type = TAG_SYM;
+ if (! sym_init_1(&tag->data.sym, p)) {
+ free(tag);
+ return NULL;
+ }
+ return tag;
+}
+
s_tag * tag_new_tuple (uw count)
{
s_tag *tag;
@@ -606,6 +684,7 @@ s_tag * tag_new_tuple (uw count)
warn("tag_new_tuple: calloc");
return NULL;
}
+ tag->type = TAG_TUPLE;
if (! tuple_init(&tag->data.tuple, count)) {
free(tag);
return NULL;
@@ -620,6 +699,7 @@ s_tag * tag_new_tuple_2 (const s_tag *a, const s_tag *b)
warn("tag_new_tuple_2: calloc");
return NULL;
}
+ tag->type = TAG_TUPLE;
if (! tuple_init_2(&tag->data.tuple, a, b)) {
free(tag);
return NULL;
@@ -627,14 +707,15 @@ s_tag * tag_new_tuple_2 (const s_tag *a, const s_tag *b)
return tag;
}
-s_tag * tag_new_u8 (u8 i)
+s_tag * tag_new_u8 (u8 i)
{
s_tag *tag;
if (! (tag = calloc(1, sizeof(s_tag)))) {
- warn("tag_new_u8 : calloc");
+ warn("tag_new_u8: calloc");
return NULL;
}
- tag->data.u8 = i;
+ tag->type = TAG_U8;
+ tag->data.u8 = i;
return tag;
}
@@ -645,6 +726,7 @@ s_tag * tag_new_u16 (u16 i)
warn("tag_new_u16: calloc");
return NULL;
}
+ tag->type = TAG_U16;
tag->data.u16 = i;
return tag;
}
@@ -656,6 +738,7 @@ s_tag * tag_new_u32 (u32 i)
warn("tag_new_u32: calloc");
return NULL;
}
+ tag->type = TAG_U32;
tag->data.u32 = i;
return tag;
}
@@ -667,6 +750,7 @@ s_tag * tag_new_u64 (u64 i)
warn("tag_new_u64: calloc");
return NULL;
}
+ tag->type = TAG_U64;
tag->data.u64 = i;
return tag;
}
@@ -678,10 +762,22 @@ s_tag * tag_new_uw (uw i)
warn("tag_new_uw: calloc");
return NULL;
}
+ tag->type = TAG_UW;
tag->data.uw = i;
return tag;
}
+s_tag * tag_new_var (void)
+{
+ s_tag *tag;
+ if (! (tag = calloc(1, sizeof(s_tag)))) {
+ warn("tag_new_var: calloc");
+ return NULL;
+ }
+ tag->type = TAG_VAR;
+ return tag;
+}
+
s_tag * tag_new_void (void)
{
s_tag *tag;
@@ -689,6 +785,7 @@ s_tag * tag_new_void (void)
warn("tag_new_void: calloc");
return NULL;
}
+ tag->type = TAG_VOID;
return tag;
}
@@ -702,7 +799,6 @@ s_tag * tag_array (s_tag *tag, const s_sym *type, uw dimension,
if (! array_init(&tmp.data.array, type, dimension, dimensions))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -714,7 +810,6 @@ s_tag * tag_bool (s_tag *tag, bool b)
tmp.type = TAG_BOOL;
tmp.data.bool = b;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -727,7 +822,6 @@ s_tag * tag_call (s_tag *tag)
if (! call_init(&tmp.data.call))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -739,7 +833,6 @@ s_tag * tag_character (s_tag *tag, character c)
tmp.type = TAG_CHARACTER;
tmp.data.character = c;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -751,7 +844,6 @@ s_tag * tag_f32 (s_tag *tag, f32 f)
tmp.type = TAG_F32;
tmp.data.f32 = f;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -763,7 +855,6 @@ s_tag * tag_f64 (s_tag *tag, f64 f)
tmp.type = TAG_F64;
tmp.data.f64 = f;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -775,7 +866,6 @@ s_tag * tag_ident (s_tag *tag, const s_ident *ident)
tmp.type = TAG_IDENT;
tmp.data.ident = *ident;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -788,32 +878,40 @@ s_tag * tag_ident_1 (s_tag *tag, const s8 *p)
if (! ident_init_1(&tmp.data.ident, p))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
-s_tag * tag_integer_copy (s_tag *tag, const s_integer *i)
+s_tag * tag_integer_1 (s_tag *tag, const s8 *p)
{
s_tag tmp = {0};
assert(tag);
tag_clean(tag);
tmp.type = TAG_INTEGER;
- if (! integer_init_copy(&tmp.data.integer, i))
+ if (! integer_init_1(&tmp.data.integer, p))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
-s_tag * tag_integer_1 (s_tag *tag, const s8 *p)
+s_tag * tag_integer_copy (s_tag *tag, const s_integer *i)
{
s_tag tmp = {0};
assert(tag);
tag_clean(tag);
tmp.type = TAG_INTEGER;
- if (! integer_init_1(&tmp.data.integer, p))
+ if (! integer_init_copy(&tmp.data.integer, i))
return NULL;
*tag = tmp;
+ return tag;
+}
+
+s_tag * tag_list (s_tag *tag, s_list *list)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_LIST;
+ tmp.data.list = list;
*tag = tmp;
return tag;
}
@@ -827,7 +925,6 @@ s_tag * tag_list_1 (s_tag *tag, const s8 *p, s_list *next)
if (! list_init_1(tmp.data.list, p, next))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -840,7 +937,6 @@ s_tag * tag_map (s_tag *tag, uw count)
if (! map_init(&tmp.data.map, count))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -853,7 +949,6 @@ s_tag * tag_map_1 (s_tag *tag, const s8 *p)
if (! map_init_1(&tmp.data.map, p))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -865,7 +960,6 @@ s_tag * tag_s8 (s_tag *tag, s8 i)
tmp.type = TAG_S8;
tmp.data.s8 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -877,7 +971,6 @@ s_tag * tag_s16 (s_tag *tag, s16 i)
tmp.type = TAG_S16;
tmp.data.s16 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -889,7 +982,6 @@ s_tag * tag_s32 (s_tag *tag, s32 i)
tmp.type = TAG_S32;
tmp.data.s32 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -901,7 +993,6 @@ s_tag * tag_s64 (s_tag *tag, s64 i)
tmp.type = TAG_S64;
tmp.data.s64 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -914,7 +1005,6 @@ s_tag * tag_str (s_tag *tag, s8 *p_free, uw size, const s8 *p)
if (! str_init(&tmp.data.str, p_free, size, p))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -927,7 +1017,6 @@ s_tag * tag_str_1 (s_tag *tag, s8 *p_free, const s8 *p)
if (! str_init_1(&tmp.data.str, p_free, p))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -939,7 +1028,6 @@ s_tag * tag_sw (s_tag *tag, sw i)
tmp.type = TAG_SW;
tmp.data.sw = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -951,6 +1039,17 @@ s_tag * tag_sym (s_tag *tag, const s_sym *sym)
tmp.type = TAG_SYM;
tmp.data.sym = sym;
*tag = tmp;
+ return tag;
+}
+
+s_tag * tag_sym_1 (s_tag *tag, const s8 *p)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_SYM;
+ if (! sym_init_1(&tmp.data.sym, p))
+ return NULL;
*tag = tmp;
return tag;
}
@@ -964,7 +1063,6 @@ s_tag * tag_tuple (s_tag *tag, uw count)
if (! tuple_init(&tmp.data.tuple, count))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -977,18 +1075,16 @@ s_tag * tag_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b)
if (! tuple_init_2(&tmp.data.tuple, a, b))
return NULL;
*tag = tmp;
- *tag = tmp;
return tag;
}
-s_tag * tag_u8 (s_tag *tag, u8 i)
+s_tag * tag_u8 (s_tag *tag, u8 i)
{
s_tag tmp = {0};
assert(tag);
tag_clean(tag);
tmp.type = TAG_U8;
- tmp.data.u8 = i;
- *tag = tmp;
+ tmp.data.u8 = i;
*tag = tmp;
return tag;
}
@@ -1001,7 +1097,6 @@ s_tag * tag_u16 (s_tag *tag, u16 i)
tmp.type = TAG_U16;
tmp.data.u16 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -1013,7 +1108,6 @@ s_tag * tag_u32 (s_tag *tag, u32 i)
tmp.type = TAG_U32;
tmp.data.u32 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -1025,7 +1119,6 @@ s_tag * tag_u64 (s_tag *tag, u64 i)
tmp.type = TAG_U64;
tmp.data.u64 = i;
*tag = tmp;
- *tag = tmp;
return tag;
}
@@ -1037,6 +1130,15 @@ s_tag * tag_uw (s_tag *tag, uw i)
tmp.type = TAG_UW;
tmp.data.uw = i;
*tag = tmp;
+ return tag;
+}
+
+s_tag * tag_var (s_tag *tag)
+{
+ s_tag tmp = {0};
+ assert(tag);
+ tag_clean(tag);
+ tmp.type = TAG_VAR;
*tag = tmp;
return tag;
}
@@ -1048,6 +1150,5 @@ s_tag * tag_void (s_tag *tag)
tag_clean(tag);
tmp.type = TAG_VOID;
*tag = tmp;
- *tag = tmp;
return tag;
}
diff --git a/libc3/tag_init.h b/libc3/tag_init.h
index c0ffec8..4b825eb 100644
--- a/libc3/tag_init.h
+++ b/libc3/tag_init.h
@@ -26,10 +26,10 @@ s_tag * tag_init_f32 (s_tag *tag, f32 f);
s_tag * tag_init_f64 (s_tag *tag, f64 f);
s_tag * tag_init_ident (s_tag *tag, const s_ident *ident);
s_tag * tag_init_ident_1 (s_tag *tag, const s8 *p);
-s_tag * tag_init_integer_copy (s_tag *tag, const s_integer *i);
s_tag * tag_init_integer_1 (s_tag *tag, const s8 *p);
+s_tag * tag_init_integer_copy (s_tag *tag, const s_integer *i);
s_tag * tag_init_integer_zero (s_tag *tag);
-s_tag * tag_init_list (s_tag *tag, s_list *next);
+s_tag * tag_init_list (s_tag *tag, s_list *list);
s_tag * tag_init_list_1 (s_tag *tag, const s8 *p, s_list *next);
s_tag * tag_init_map (s_tag *tag, uw count);
s_tag * tag_init_map_1 (s_tag *tag, const s8 *p);
@@ -41,10 +41,11 @@ s_tag * tag_init_str (s_tag *tag, s8 *p_free, uw size, const s8 *p);
s_tag * tag_init_str_1 (s_tag *tag, s8 *p_free, const s8 *p);
s_tag * tag_init_sw (s_tag *tag, sw i);
s_tag * tag_init_sym (s_tag *tag, const s_sym *sym);
+s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p);
s_tag * tag_init_tuple (s_tag *tag, uw count);
s_tag * tag_init_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b);
s_tag * tag_init_time (s_tag *tag);
-s_tag * tag_init_u8 (s_tag *tag, u8 i);
+s_tag * tag_init_u8 (s_tag *tag, u8 i);
s_tag * tag_init_u16 (s_tag *tag, u16 i);
s_tag * tag_init_u32 (s_tag *tag, u32 i);
s_tag * tag_init_u64 (s_tag *tag, u64 i);
@@ -63,10 +64,10 @@ s_tag * tag_new_f32 (f32 f);
s_tag * tag_new_f64 (f64 f);
s_tag * tag_new_ident (const s_ident *ident);
s_tag * tag_new_ident_1 (const s8 *p);
-s_tag * tag_new_integer_copy (const s_integer *i);
s_tag * tag_new_integer_1 (const s8 *p);
+s_tag * tag_new_integer_copy (const s_integer *i);
s_tag * tag_new_integer_zero (void);
-s_tag * tag_new_list (s_list *next);
+s_tag * tag_new_list (s_list *list);
s_tag * tag_new_list_1 (const s8 *p, s_list *next);
s_tag * tag_new_map (uw count);
s_tag * tag_new_map_1 (const s8 *p);
@@ -78,10 +79,11 @@ s_tag * tag_new_str (s8 *p_free, uw size, const s8 *p);
s_tag * tag_new_str_1 (s8 *p_free, const s8 *p);
s_tag * tag_new_sw (sw i);
s_tag * tag_new_sym (const s_sym *sym);
+s_tag * tag_new_sym_1 (const s8 *p);
s_tag * tag_new_tuple (uw count);
s_tag * tag_new_tuple_2 (const s_tag *a, const s_tag *b);
s_tag * tag_new_time (void);
-s_tag * tag_new_u8 (u8 i);
+s_tag * tag_new_u8 (u8 i);
s_tag * tag_new_u16 (u16 i);
s_tag * tag_new_u32 (u32 i);
s_tag * tag_new_u64 (u64 i);
@@ -100,10 +102,10 @@ s_tag * tag_f32 (s_tag *tag, f32 f);
s_tag * tag_f64 (s_tag *tag, f64 f);
s_tag * tag_ident (s_tag *tag, const s_ident *ident);
s_tag * tag_ident_1 (s_tag *tag, const s8 *p);
-s_tag * tag_integer_copy (s_tag *tag, const s_integer *i);
s_tag * tag_integer_1 (s_tag *tag, const s8 *p);
+s_tag * tag_integer_copy (s_tag *tag, const s_integer *i);
s_tag * tag_integer_zero (s_tag *tag);
-s_tag * tag_list (s_tag *tag, s_list *next);
+s_tag * tag_list (s_tag *tag, s_list *list);
s_tag * tag_list_1 (s_tag *tag, const s8 *p, s_list *next);
s_tag * tag_map (s_tag *tag, uw count);
s_tag * tag_map_1 (s_tag *tag, const s8 *p);
@@ -115,10 +117,11 @@ s_tag * tag_str (s_tag *tag, s8 *p_free, uw size, const s8 *p);
s_tag * tag_str_1 (s_tag *tag, s8 *p_free, const s8 *p);
s_tag * tag_sw (s_tag *tag, sw i);
s_tag * tag_sym (s_tag *tag, const s_sym *sym);
+s_tag * tag_sym_1 (s_tag *tag, const s8 *p);
s_tag * tag_tuple (s_tag *tag, uw count);
s_tag * tag_tuple_2 (s_tag *tag, const s_tag *a, const s_tag *b);
s_tag * tag_time (s_tag *tag);
-s_tag * tag_u8 (s_tag *tag, u8 i);
+s_tag * tag_u8 (s_tag *tag, u8 i);
s_tag * tag_u16 (s_tag *tag, u16 i);
s_tag * tag_u32 (s_tag *tag, u32 i);
s_tag * tag_u64 (s_tag *tag, u64 i);
diff --git a/libc3/tag_init.h.rb b/libc3/tag_init.h.rb
index e2f3908..6271d44 100644
--- a/libc3/tag_init.h.rb
+++ b/libc3/tag_init.h.rb
@@ -43,6 +43,7 @@ class TagInit
@args_list.each do |arg|
@first_arg_deref ||= arg.type != "const s_sym *" &&
+ arg.type != "s_list *" &&
arg.type.match?(/\*$/) ?
"*#{arg.name}" : arg.name
@args = @args == "" ? arg.name : "#{@args}, #{arg.name}"
@@ -110,7 +111,6 @@ end
assert(tag);
tag_clean(tag);
#{tag_type ? "tmp.type = #{tag_type};\n" : ""}#{def_tag_init_init} *tag = tmp;
- *tag = tmp;
return tag;
}
EOF
@@ -169,7 +169,7 @@ EOF
warn("tag_new_#{name_suffix}: calloc");
return NULL;
}
-#{def_tag_new_init} return tag;
+ #{tag_type ? "tag->type = #{tag_type};\n" : ""}#{def_tag_new_init} return tag;
}
EOF
end
@@ -287,13 +287,14 @@ class TagInitList
TagInit.new("ident", "TAG_IDENT", :init_mode_direct,
[Arg.new("const s_ident *", "ident")]),
TagInit1.new("ident", "1", "TAG_IDENT", :init_mode_init),
+# TagInit.new("integer", "TAG_INTEGER", :init_mode_init, []),
+ TagInit1.new("integer", "1", "TAG_INTEGER", :init_mode_init),
TagInit.new("integer", "copy", "TAG_INTEGER", :init_mode_init,
[Arg.new("const s_integer *", "i")]),
- TagInit1.new("integer", "1", "TAG_INTEGER", :init_mode_init),
TagInitProto.new("integer_zero", "TAG_INTEGER", :init_mode_init,
[]),
- TagInitProto.new("list", "TAG_LIST", :init_mode_init,
- [Arg.new("s_list *", "next")]),
+ TagInit.new("list", "TAG_LIST", :init_mode_direct,
+ [Arg.new("s_list *", "list")]),
TagInit1.new("list", "1", "TAG_LIST", :init_mode_init,
[Arg.new("const s8 *", "p"),
Arg.new("s_list *", "next")]),
@@ -319,13 +320,14 @@ class TagInitList
[Arg.new("sw", "i")]),
TagInit.new("sym", "TAG_SYM", :init_mode_direct,
[Arg.new("const s_sym *", "sym")]),
+ TagInit1.new("sym", "1", "TAG_SYM", :init_mode_init),
TagInit.new("tuple", "TAG_TUPLE", :init_mode_init,
[Arg.new("uw", "count")]),
TagInit.new("tuple", "2", "TAG_TUPLE", :init_mode_init,
[Arg.new("const s_tag *", "a"),
Arg.new("const s_tag *", "b")]),
TagInitProto.new("time", "TAG_TIME", :init_mode_none, []),
- TagInit.new("u8 ", "TAG_U8", :init_mode_direct,
+ TagInit.new("u8", "TAG_U8", :init_mode_direct,
[Arg.new("u8", "i")]),
TagInit.new("u16", "TAG_U16", :init_mode_direct,
[Arg.new("u16", "i")]),
@@ -335,7 +337,7 @@ class TagInitList
[Arg.new("u64", "i")]),
TagInit.new("uw", "TAG_UW", :init_mode_direct,
[Arg.new("uw", "i")]),
- TagInitProto.new("var", "TAG_VAR", :init_mode_none, []),
+ TagInit.new("var", "TAG_VAR", :init_mode_none, []),
TagInit.new("void", "TAG_VOID", :init_mode_none, [])])
end