Do a little bit of const correctness for type.[ch]

It's only the beginning :/
This commit is contained in:
Bill Currie 2012-12-05 22:15:19 +09:00
parent fea806c155
commit a099847026
3 changed files with 34 additions and 34 deletions

View file

@ -143,21 +143,21 @@ type_t *field_type (type_t *aux);
type_t *pointer_type (type_t *aux);
type_t *array_type (type_t *aux, int size);
type_t *based_array_type (type_t *aux, int base, int top);
void print_type_str (struct dstring_s *str, type_t *type);
void print_type (type_t *type);
const char *encode_params (type_t *type);
void encode_type (struct dstring_s *encoding, type_t *type);
const char *type_get_encoding (type_t *type);
int is_enum (type_t *type);
int is_integral (type_t *type);
int is_float (type_t *type);
int is_scalar (type_t *type);
int is_math (type_t *type);
int is_struct (type_t *type);
int is_class (type_t *type);
int is_array (type_t *type);
int type_assignable (type_t *dst, type_t *src);
int type_size (type_t *type);
void print_type_str (struct dstring_s *str, const type_t *type);
void print_type (const type_t *type);
const char *encode_params (const type_t *type);
void encode_type (struct dstring_s *encoding, const type_t *type);
const char *type_get_encoding (const type_t *type);
int is_enum (const type_t *type);
int is_integral (const type_t *type);
int is_float (const type_t *type);
int is_scalar (const type_t *type);
int is_math (const type_t *type);
int is_struct (const type_t *type);
int is_class (const type_t *type);
int is_array (const type_t *type);
int type_assignable (const type_t *dst, const type_t *src);
int type_size (const type_t *type);
void init_types (void);
void chain_initial_types (void);

View file

@ -24,7 +24,7 @@ int num_linenos;
pr_lineno_t *linenos;
pr_info_t pr;
string_t ReuseString (const char *str) {return 0;}
void encode_type (struct dstring_s *str, type_t *type) {}
void encode_type (struct dstring_s *str, const type_t *type) {}
codespace_t *codespace_new (void) {return 0;}
void codespace_addcode (codespace_t *codespace, struct dstatement_s *code, int size) {}
int function_parms (function_t *f, byte *parm_size) {return 0;}

View file

@ -113,7 +113,7 @@ low_level_type (type_t *type)
}
const char *
type_get_encoding (type_t *type)
type_get_encoding (const type_t *type)
{
static dstring_t *encoding;
@ -410,7 +410,7 @@ based_array_type (type_t *aux, int base, int top)
}
void
print_type_str (dstring_t *str, type_t *type)
print_type_str (dstring_t *str, const type_t *type)
{
if (!type) {
dasprintf (str, " (null)");
@ -488,7 +488,7 @@ print_type_str (dstring_t *str, type_t *type)
}
void
print_type (type_t *type)
print_type (const type_t *type)
{
dstring_t *str = dstring_newstr ();
print_type_str (str, type);
@ -497,7 +497,7 @@ print_type (type_t *type)
}
const char *
encode_params (type_t *type)
encode_params (const type_t *type)
{
const char *ret;
dstring_t *encoding = dstring_newstr ();
@ -518,7 +518,7 @@ encode_params (type_t *type)
}
static void
encode_class (dstring_t *encoding, type_t *type)
encode_class (dstring_t *encoding, const type_t *type)
{
class_t *class = type->t.class;
const char *name ="?";
@ -529,7 +529,7 @@ encode_class (dstring_t *encoding, type_t *type)
}
static void
encode_struct (dstring_t *encoding, type_t *type)
encode_struct (dstring_t *encoding, const type_t *type)
{
const char *name ="?";
char su = ' ';
@ -544,7 +544,7 @@ encode_struct (dstring_t *encoding, type_t *type)
}
static void
encode_enum (dstring_t *encoding, type_t *type)
encode_enum (dstring_t *encoding, const type_t *type)
{
const char *name ="?";
@ -554,7 +554,7 @@ encode_enum (dstring_t *encoding, type_t *type)
}
void
encode_type (dstring_t *encoding, type_t *type)
encode_type (dstring_t *encoding, const type_t *type)
{
if (!type)
return;
@ -645,7 +645,7 @@ encode_type (dstring_t *encoding, type_t *type)
}
int
is_enum (type_t *type)
is_enum (const type_t *type)
{
if (type->type == ev_invalid && type->meta == ty_enum)
return 1;
@ -653,7 +653,7 @@ is_enum (type_t *type)
}
int
is_integral (type_t *type)
is_integral (const type_t *type)
{
etype_t t = type->type;
@ -663,19 +663,19 @@ is_integral (type_t *type)
}
int
is_float (type_t *type)
is_float (const type_t *type)
{
return type->type == ev_float;
}
int
is_scalar (type_t *type)
is_scalar (const type_t *type)
{
return is_float (type) || is_integral (type);
}
int
is_math (type_t *type)
is_math (const type_t *type)
{
etype_t t = type->type;
@ -683,7 +683,7 @@ is_math (type_t *type)
}
int
is_struct (type_t *type)
is_struct (const type_t *type)
{
if (type->type == ev_invalid
&& (type->meta == ty_struct || type->meta == ty_union))
@ -692,7 +692,7 @@ is_struct (type_t *type)
}
int
is_class (type_t *type)
is_class (const type_t *type)
{
if (type->type == ev_invalid && type->meta == ty_class)
return 1;
@ -700,7 +700,7 @@ is_class (type_t *type)
}
int
is_array (type_t *type)
is_array (const type_t *type)
{
if (type->type == ev_invalid && type->meta == ty_array)
return 1;
@ -708,7 +708,7 @@ is_array (type_t *type)
}
int
type_assignable (type_t *dst, type_t *src)
type_assignable (const type_t *dst, const type_t *src)
{
class_t *dst_class, *src_class;
@ -759,7 +759,7 @@ type_assignable (type_t *dst, type_t *src)
}
int
type_size (type_t *type)
type_size (const type_t *type)
{
if (!type)
return 0;