+++ /dev/null
-#ifndef __AST_DATA
-#define __AST_DATA
-
-typedef struct DataTable_* DataTable;
-ANN DataTable new_datatable(MemPool p, size_t sz);
-ANN void datatable_reset(DataTable);
-ANN void free_datatable(DataTable);
-
-ANN struct Type_* dataget_type (DataTable, void*);
-//ANN Type dataget_cast (Data, void*);
-//ANN Value dataget_val (Data, void*);
-//ANN Func dataget_func (Data, void*);
-//ANN Nspc dataget_nspc (Data, void*);
-//ANN Vector dataget_vec (Data, void*);
-//ANN Instr dataget_instr (Data, void*);
-
-ANN void dataset_type (DataTable, void*, struct Type_*);
-//ANN void dataset_cast (Data, void*);
-//ANN void dataset_val (Data, void*);
-//ANN void dataset_func (Data, void*);
-//ANN void dataset_nspc (Data, void*);
-//ANN void dataset_vec (Data, void*);
-//ANN void dataset_instr (Data, void*);
-#endif
ANN2(1,2) ANEW Type new_type(MemPool, const m_str name, const Type);
ANEW ANN Type type_copy(MemPool, const Type type);
-ANN m_str get_type_name(const Env, const Type t, const m_uint);
ANN Value find_value(const Type, const Symbol);
ANN m_bool isa(const Type, const Type) __attribute__((pure));
ANN m_bool isres(const Env, const Symbol, const loc_t pos);
}
-ANN m_str get_type_name(const Env env, const Type t, const m_uint index) {
- if(!index)
- return NULL;
- m_str name = strchr(t->name, ':');
- if(!name)
- return NULL;
- name += 2;
- const size_t slen = strlen(name);
- m_uint lvl = 0;
- m_uint n = 1;
- char c, buf[slen + 1], *tmp = buf;
- while((c = *name)) {
- if(c == ':')
- ++lvl;
- else if(c == ']') {
- if(!lvl-- && n == index)
- break;
- } else if(c == ',') {
- if(!lvl && n++ == index)
- break;
- if(!lvl)
- ++name;
- }
- if(n == index)
- *tmp++ = *name;
- ++name;
- }
- *tmp = '\0';
- return tmp - buf ? s_name(insert_symbol(buf)) : NULL;
-}
-
ANN m_uint get_depth(const Type type) {
m_uint depth = 0;
Type t = type;