2008-12-29 12:05:27 +00:00
|
|
|
/*
|
|
|
|
* IDL Type Tree
|
|
|
|
*
|
|
|
|
* Copyright 2008 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-02-23 13:48:15 +00:00
|
|
|
#include <string.h>
|
2008-12-29 12:05:27 +00:00
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
|
|
|
#include "typetree.h"
|
|
|
|
#include "header.h"
|
|
|
|
|
2009-01-05 23:33:52 +00:00
|
|
|
type_t *duptype(type_t *t, int dupname)
|
|
|
|
{
|
|
|
|
type_t *d = alloc_type();
|
|
|
|
|
|
|
|
*d = *t;
|
|
|
|
if (dupname && t->name)
|
|
|
|
d->name = xstrdup(t->name);
|
|
|
|
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2009-03-05 08:22:32 +00:00
|
|
|
type_t *make_type(enum type_type type)
|
|
|
|
{
|
|
|
|
type_t *t = alloc_type();
|
|
|
|
t->name = NULL;
|
2015-07-31 11:37:50 +00:00
|
|
|
t->namespace = NULL;
|
2009-03-05 08:22:32 +00:00
|
|
|
t->type_type = type;
|
|
|
|
t->attrs = NULL;
|
2015-07-31 11:37:50 +00:00
|
|
|
t->c_name = NULL;
|
2009-03-05 08:22:32 +00:00
|
|
|
t->orig = NULL;
|
|
|
|
memset(&t->details, 0, sizeof(t->details));
|
|
|
|
t->typestring_offset = 0;
|
|
|
|
t->ptrdesc = 0;
|
|
|
|
t->ignore = (parse_only != 0);
|
|
|
|
t->defined = FALSE;
|
|
|
|
t->written = FALSE;
|
|
|
|
t->user_types_registered = FALSE;
|
|
|
|
t->tfswrite = FALSE;
|
|
|
|
t->checked = FALSE;
|
|
|
|
t->is_alias = FALSE;
|
|
|
|
t->typelib_idx = -1;
|
|
|
|
init_loc_info(&t->loc_info);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-11-07 14:54:24 +00:00
|
|
|
static const var_t *find_arg(const var_list_t *args, const char *name)
|
|
|
|
{
|
|
|
|
const var_t *arg;
|
|
|
|
|
|
|
|
if (args) LIST_FOR_EACH_ENTRY(arg, args, const var_t, entry)
|
|
|
|
{
|
|
|
|
if (arg->name && !strcmp(name, arg->name))
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-31 11:37:50 +00:00
|
|
|
static char *append_namespace(char *ptr, struct namespace *namespace, const char *separator)
|
|
|
|
{
|
|
|
|
if(is_global_namespace(namespace))
|
|
|
|
return ptr;
|
|
|
|
|
|
|
|
ptr = append_namespace(ptr, namespace->parent, separator);
|
|
|
|
strcpy(ptr, namespace->name);
|
|
|
|
strcat(ptr, separator);
|
|
|
|
return ptr + strlen(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix)
|
|
|
|
{
|
|
|
|
unsigned len = strlen(prefix) + strlen(suffix);
|
|
|
|
unsigned sep_len = strlen(separator);
|
|
|
|
struct namespace *iter;
|
|
|
|
char *ret, *ptr;
|
|
|
|
|
|
|
|
for(iter = namespace; !is_global_namespace(iter); iter = iter->parent)
|
|
|
|
len += strlen(iter->name) + sep_len;
|
|
|
|
|
|
|
|
ret = xmalloc(len+1);
|
|
|
|
strcpy(ret, prefix);
|
|
|
|
ptr = append_namespace(ret + strlen(ret), namespace, separator);
|
|
|
|
strcpy(ptr, suffix);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-12-29 12:05:27 +00:00
|
|
|
type_t *type_new_function(var_list_t *args)
|
|
|
|
{
|
2009-11-07 14:54:24 +00:00
|
|
|
var_t *arg;
|
|
|
|
type_t *t;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
if (args)
|
|
|
|
{
|
|
|
|
arg = LIST_ENTRY(list_head(args), var_t, entry);
|
|
|
|
if (list_count(args) == 1 && !arg->name && arg->type && type_get_type(arg->type) == TYPE_VOID)
|
|
|
|
{
|
|
|
|
list_remove(&arg->entry);
|
|
|
|
free(arg);
|
|
|
|
free(args);
|
|
|
|
args = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
|
|
|
|
{
|
|
|
|
if (arg->type && type_get_type(arg->type) == TYPE_VOID)
|
|
|
|
error_loc("argument '%s' has void type\n", arg->name);
|
|
|
|
if (!arg->name)
|
|
|
|
{
|
|
|
|
if (i > 26 * 26)
|
|
|
|
error_loc("too many unnamed arguments\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int unique;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
char name[3];
|
|
|
|
name[0] = i > 26 ? 'a' + i / 26 : 'a' + i;
|
|
|
|
name[1] = i > 26 ? 'a' + i % 26 : 0;
|
|
|
|
name[2] = 0;
|
|
|
|
unique = !find_arg(args, name);
|
|
|
|
if (unique)
|
|
|
|
arg->name = xstrdup(name);
|
|
|
|
i++;
|
|
|
|
} while (!unique);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t = make_type(TYPE_FUNCTION);
|
2008-12-29 12:05:35 +00:00
|
|
|
t->details.function = xmalloc(sizeof(*t->details.function));
|
|
|
|
t->details.function->args = args;
|
2009-01-05 23:33:27 +00:00
|
|
|
t->details.function->idx = -1;
|
2008-12-29 12:05:27 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-03-07 23:23:44 +00:00
|
|
|
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs)
|
2008-12-29 12:05:27 +00:00
|
|
|
{
|
2009-03-05 08:22:32 +00:00
|
|
|
type_t *t = make_type(TYPE_POINTER);
|
2009-03-07 23:23:44 +00:00
|
|
|
t->details.pointer.def_fc = pointer_default;
|
2009-03-05 08:22:32 +00:00
|
|
|
t->details.pointer.ref = ref;
|
2008-12-29 12:05:27 +00:00
|
|
|
t->attrs = attrs;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-01-05 23:33:52 +00:00
|
|
|
type_t *type_new_alias(type_t *t, const char *name)
|
|
|
|
{
|
2009-01-05 23:34:23 +00:00
|
|
|
type_t *a = duptype(t, 0);
|
2009-01-05 23:33:52 +00:00
|
|
|
|
2009-01-05 23:34:23 +00:00
|
|
|
a->name = xstrdup(name);
|
|
|
|
a->attrs = NULL;
|
|
|
|
a->orig = t;
|
|
|
|
a->is_alias = TRUE;
|
2009-03-05 08:22:19 +00:00
|
|
|
/* for pointer types */
|
|
|
|
a->details = t->details;
|
2009-01-05 23:34:23 +00:00
|
|
|
init_loc_info(&a->loc_info);
|
2009-01-05 23:33:52 +00:00
|
|
|
|
2009-01-05 23:34:23 +00:00
|
|
|
return a;
|
2009-01-05 23:33:52 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 08:23:07 +00:00
|
|
|
type_t *type_new_module(char *name)
|
2009-01-05 23:34:08 +00:00
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *type = get_type(TYPE_MODULE, name, NULL, 0);
|
2009-03-05 08:23:07 +00:00
|
|
|
if (type->type_type != TYPE_MODULE || type->defined)
|
|
|
|
error_loc("%s: redefinition error; original definition was at %s:%d\n",
|
|
|
|
type->name, type->loc_info.input_name, type->loc_info.line_number);
|
2009-01-05 23:34:08 +00:00
|
|
|
type->name = name;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2009-03-05 08:23:07 +00:00
|
|
|
type_t *type_new_coclass(char *name)
|
2009-03-05 08:22:19 +00:00
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *type = get_type(TYPE_COCLASS, name, NULL, 0);
|
2009-03-05 08:23:07 +00:00
|
|
|
if (type->type_type != TYPE_COCLASS || type->defined)
|
|
|
|
error_loc("%s: redefinition error; original definition was at %s:%d\n",
|
|
|
|
type->name, type->loc_info.input_name, type->loc_info.line_number);
|
|
|
|
type->name = name;
|
|
|
|
return type;
|
2009-03-05 08:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-05 08:21:35 +00:00
|
|
|
type_t *type_new_array(const char *name, type_t *element, int declptr,
|
2009-03-07 23:23:44 +00:00
|
|
|
unsigned int dim, expr_t *size_is, expr_t *length_is,
|
|
|
|
unsigned char ptr_default_fc)
|
2009-01-06 23:20:59 +00:00
|
|
|
{
|
2009-03-05 08:22:32 +00:00
|
|
|
type_t *t = make_type(TYPE_ARRAY);
|
2009-01-06 23:20:59 +00:00
|
|
|
if (name) t->name = xstrdup(name);
|
2009-03-05 08:21:35 +00:00
|
|
|
t->details.array.declptr = declptr;
|
2009-01-06 23:20:59 +00:00
|
|
|
t->details.array.length_is = length_is;
|
|
|
|
if (size_is)
|
|
|
|
t->details.array.size_is = size_is;
|
|
|
|
else
|
|
|
|
t->details.array.dim = dim;
|
2009-03-05 08:22:32 +00:00
|
|
|
t->details.array.elem = element;
|
2009-03-07 23:23:44 +00:00
|
|
|
t->details.array.ptr_def_fc = ptr_default_fc;
|
2009-01-06 23:20:59 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-03-05 08:21:51 +00:00
|
|
|
type_t *type_new_basic(enum type_basic_type basic_type)
|
|
|
|
{
|
2009-03-05 08:22:32 +00:00
|
|
|
type_t *t = make_type(TYPE_BASIC);
|
2009-03-05 08:21:51 +00:00
|
|
|
t->details.basic.type = basic_type;
|
|
|
|
t->details.basic.sign = 0;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_int(enum type_basic_type basic_type, int sign)
|
|
|
|
{
|
|
|
|
static type_t *int_types[TYPE_BASIC_INT_MAX+1][3];
|
|
|
|
|
|
|
|
assert(basic_type <= TYPE_BASIC_INT_MAX);
|
|
|
|
|
|
|
|
/* map sign { -1, 0, 1 } -> { 0, 1, 2 } */
|
|
|
|
if (!int_types[basic_type][sign + 1])
|
|
|
|
{
|
|
|
|
int_types[basic_type][sign + 1] = type_new_basic(basic_type);
|
|
|
|
int_types[basic_type][sign + 1]->details.basic.sign = sign;
|
|
|
|
}
|
|
|
|
return int_types[basic_type][sign + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_void(void)
|
|
|
|
{
|
|
|
|
static type_t *void_type = NULL;
|
|
|
|
if (!void_type)
|
2009-03-05 08:22:32 +00:00
|
|
|
void_type = make_type(TYPE_VOID);
|
2009-03-05 08:21:51 +00:00
|
|
|
return void_type;
|
|
|
|
}
|
|
|
|
|
2009-03-05 08:23:00 +00:00
|
|
|
type_t *type_new_enum(const char *name, int defined, var_list_t *enums)
|
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *tag_type = name ? find_type(name, NULL, tsENUM) : NULL;
|
2009-03-05 08:23:00 +00:00
|
|
|
type_t *t = make_type(TYPE_ENUM);
|
|
|
|
t->name = name;
|
|
|
|
|
|
|
|
if (tag_type && tag_type->details.enumeration)
|
|
|
|
t->details.enumeration = tag_type->details.enumeration;
|
|
|
|
else if (defined)
|
|
|
|
{
|
|
|
|
t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
|
|
|
|
t->details.enumeration->enums = enums;
|
|
|
|
t->defined = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
if (defined)
|
2015-07-31 11:37:40 +00:00
|
|
|
reg_type(t, name, NULL, tsENUM);
|
2009-03-05 08:23:00 +00:00
|
|
|
else
|
|
|
|
add_incomplete(t);
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_struct(char *name, int defined, var_list_t *fields)
|
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *tag_type = name ? find_type(name, NULL, tsSTRUCT) : NULL;
|
2009-03-05 08:23:00 +00:00
|
|
|
type_t *t = make_type(TYPE_STRUCT);
|
|
|
|
t->name = name;
|
|
|
|
if (tag_type && tag_type->details.structure)
|
|
|
|
t->details.structure = tag_type->details.structure;
|
|
|
|
else if (defined)
|
|
|
|
{
|
|
|
|
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
|
|
|
t->details.structure->fields = fields;
|
|
|
|
t->defined = TRUE;
|
|
|
|
}
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
if (defined)
|
2015-07-31 11:37:40 +00:00
|
|
|
reg_type(t, name, NULL, tsSTRUCT);
|
2009-03-05 08:23:00 +00:00
|
|
|
else
|
|
|
|
add_incomplete(t);
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields)
|
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *tag_type = name ? find_type(name, NULL, tsUNION) : NULL;
|
2009-03-05 08:23:00 +00:00
|
|
|
type_t *t = make_type(TYPE_UNION);
|
|
|
|
t->name = name;
|
|
|
|
if (tag_type && tag_type->details.structure)
|
|
|
|
t->details.structure = tag_type->details.structure;
|
|
|
|
else if (defined)
|
|
|
|
{
|
|
|
|
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
|
|
|
t->details.structure->fields = fields;
|
|
|
|
t->defined = TRUE;
|
|
|
|
}
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
if (defined)
|
2015-07-31 11:37:40 +00:00
|
|
|
reg_type(t, name, NULL, tsUNION);
|
2009-03-05 08:23:00 +00:00
|
|
|
else
|
|
|
|
add_incomplete(t);
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases)
|
|
|
|
{
|
2015-07-31 11:37:40 +00:00
|
|
|
type_t *t = get_type(TYPE_ENCAPSULATED_UNION, name, NULL, tsUNION);
|
2009-03-05 08:23:00 +00:00
|
|
|
if (!union_field) union_field = make_var( xstrdup("tagged_union") );
|
|
|
|
union_field->type = type_new_nonencapsulated_union(NULL, TRUE, cases);
|
|
|
|
t->details.structure = xmalloc(sizeof(*t->details.structure));
|
|
|
|
t->details.structure->fields = append_var( NULL, switch_field );
|
|
|
|
t->details.structure->fields = append_var( t->details.structure->fields, union_field );
|
|
|
|
t->defined = TRUE;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2009-11-07 14:55:09 +00:00
|
|
|
static int is_valid_bitfield_type(const type_t *type)
|
|
|
|
{
|
|
|
|
switch (type_get_type(type))
|
|
|
|
{
|
|
|
|
case TYPE_ENUM:
|
|
|
|
return TRUE;
|
|
|
|
case TYPE_BASIC:
|
|
|
|
switch (type_basic_get_type(type))
|
|
|
|
{
|
|
|
|
case TYPE_BASIC_INT8:
|
|
|
|
case TYPE_BASIC_INT16:
|
|
|
|
case TYPE_BASIC_INT32:
|
|
|
|
case TYPE_BASIC_INT64:
|
|
|
|
case TYPE_BASIC_INT:
|
|
|
|
case TYPE_BASIC_INT3264:
|
|
|
|
case TYPE_BASIC_CHAR:
|
|
|
|
case TYPE_BASIC_HYPER:
|
|
|
|
case TYPE_BASIC_BYTE:
|
|
|
|
case TYPE_BASIC_WCHAR:
|
|
|
|
case TYPE_BASIC_ERROR_STATUS_T:
|
|
|
|
return TRUE;
|
|
|
|
case TYPE_BASIC_FLOAT:
|
|
|
|
case TYPE_BASIC_DOUBLE:
|
|
|
|
case TYPE_BASIC_HANDLE:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type_t *type_new_bitfield(type_t *field, const expr_t *bits)
|
|
|
|
{
|
|
|
|
type_t *t;
|
|
|
|
|
|
|
|
if (!is_valid_bitfield_type(field))
|
|
|
|
error_loc("bit-field has invalid type\n");
|
|
|
|
|
|
|
|
if (bits->cval < 0)
|
|
|
|
error_loc("negative width for bit-field\n");
|
|
|
|
|
|
|
|
/* FIXME: validate bits->cval <= memsize(field) * 8 */
|
|
|
|
|
|
|
|
t = make_type(TYPE_BITFIELD);
|
|
|
|
t->details.bitfield.field = field;
|
|
|
|
t->details.bitfield.bits = bits;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2008-12-29 12:05:27 +00:00
|
|
|
static int compute_method_indexes(type_t *iface)
|
|
|
|
{
|
|
|
|
int idx;
|
2009-01-05 23:33:27 +00:00
|
|
|
statement_t *stmt;
|
|
|
|
|
|
|
|
if (!iface->details.iface)
|
|
|
|
return 0;
|
2008-12-29 12:05:27 +00:00
|
|
|
|
2009-01-05 23:35:06 +00:00
|
|
|
if (type_iface_get_inherit(iface))
|
|
|
|
idx = compute_method_indexes(type_iface_get_inherit(iface));
|
2008-12-29 12:05:27 +00:00
|
|
|
else
|
|
|
|
idx = 0;
|
|
|
|
|
2009-01-05 23:35:13 +00:00
|
|
|
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
2009-01-05 23:33:27 +00:00
|
|
|
{
|
|
|
|
var_t *func = stmt->u.var;
|
|
|
|
if (!is_callas(func->attrs))
|
|
|
|
func->type->details.function->idx = idx++;
|
|
|
|
}
|
2008-12-29 12:05:27 +00:00
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2008-12-29 12:06:35 +00:00
|
|
|
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
|
2008-12-29 12:05:27 +00:00
|
|
|
{
|
2008-12-29 12:05:35 +00:00
|
|
|
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
|
|
|
iface->details.iface->disp_props = NULL;
|
|
|
|
iface->details.iface->disp_methods = NULL;
|
2009-01-05 23:33:27 +00:00
|
|
|
iface->details.iface->stmts = stmts;
|
2009-03-05 08:22:32 +00:00
|
|
|
iface->details.iface->inherit = inherit;
|
2008-12-29 12:05:27 +00:00
|
|
|
iface->defined = TRUE;
|
|
|
|
compute_method_indexes(iface);
|
|
|
|
}
|
|
|
|
|
2010-03-23 13:33:36 +00:00
|
|
|
void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods)
|
2008-12-29 12:05:27 +00:00
|
|
|
{
|
2008-12-29 12:05:35 +00:00
|
|
|
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
|
|
|
|
iface->details.iface->disp_props = props;
|
|
|
|
iface->details.iface->disp_methods = methods;
|
2009-01-05 23:33:27 +00:00
|
|
|
iface->details.iface->stmts = NULL;
|
2015-07-31 11:37:40 +00:00
|
|
|
iface->details.iface->inherit = find_type("IDispatch", NULL, 0);
|
2009-03-05 08:22:32 +00:00
|
|
|
if (!iface->details.iface->inherit) error_loc("IDispatch is undefined\n");
|
2008-12-29 12:05:27 +00:00
|
|
|
iface->defined = TRUE;
|
|
|
|
compute_method_indexes(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface)
|
|
|
|
{
|
2008-12-29 12:05:35 +00:00
|
|
|
type_dispinterface_define(dispiface, iface->details.iface->disp_props,
|
|
|
|
iface->details.iface->disp_methods);
|
2008-12-29 12:05:27 +00:00
|
|
|
}
|
2009-01-05 23:33:27 +00:00
|
|
|
|
|
|
|
void type_module_define(type_t *module, statement_list_t *stmts)
|
|
|
|
{
|
|
|
|
if (module->details.module) error_loc("multiple definition error\n");
|
|
|
|
module->details.module = xmalloc(sizeof(*module->details.module));
|
|
|
|
module->details.module->stmts = stmts;
|
|
|
|
module->defined = TRUE;
|
|
|
|
}
|
2009-01-05 23:34:38 +00:00
|
|
|
|
|
|
|
type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces)
|
|
|
|
{
|
2009-01-05 23:34:44 +00:00
|
|
|
coclass->details.coclass.ifaces = ifaces;
|
2009-01-05 23:34:38 +00:00
|
|
|
coclass->defined = TRUE;
|
|
|
|
return coclass;
|
|
|
|
}
|
2009-02-23 13:48:15 +00:00
|
|
|
|
|
|
|
int type_is_equal(const type_t *type1, const type_t *type2)
|
|
|
|
{
|
|
|
|
if (type_get_type_detect_alias(type1) != type_get_type_detect_alias(type2))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (type1->name && type2->name)
|
|
|
|
return !strcmp(type1->name, type2->name);
|
|
|
|
else if ((!type1->name && type2->name) || (type1->name && !type2->name))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* FIXME: do deep inspection of types to determine if they are equal */
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|