#include "ecpgtype.h"

Go to the source code of this file.
Data Structures | |
| struct | ECPGstruct_member |
| struct | ECPGtype |
| struct | ECPGtemp_type |
| struct | when |
| struct | index |
| struct | su_symbol |
| struct | prep |
| struct | this_type |
| struct | _include_path |
| struct | cursor |
| struct | typedefs |
| struct | _defines |
| struct | variable |
| struct | arguments |
| struct | descriptor |
| struct | assignment |
| struct | fetch_desc |
Enumerations | |
| enum | WHEN_TYPE { W_NOTHING, W_CONTINUE, W_BREAK, W_SQLPRINT, W_GOTO, W_DO, W_STOP } |
| enum | errortype { ET_WARNING, ET_ERROR, ET_FATAL } |
Functions | |
| void | ECPGmake_struct_member (char *, struct ECPGtype *, struct ECPGstruct_member **) |
| struct ECPGtype * | ECPGmake_simple_type (enum ECPGttype, char *, int) |
| struct ECPGtype * | ECPGmake_array_type (struct ECPGtype *, char *) |
| struct ECPGtype * | ECPGmake_struct_type (struct ECPGstruct_member *, enum ECPGttype, char *, char *) |
| struct ECPGstruct_member * | ECPGstruct_member_dup (struct ECPGstruct_member *) |
| void | ECPGfree_struct_member (struct ECPGstruct_member *) |
| void | ECPGfree_type (struct ECPGtype *) |
| void | ECPGdump_a_type (FILE *, const char *, struct ECPGtype *, const int, const char *, struct ECPGtype *, const int, const char *, const char *, char *, const char *, const char *) |
| const char * | ecpg_type_name (enum ECPGttype type) |
| enum errortype |
| enum WHEN_TYPE |
| const char* ecpg_type_name | ( | enum ECPGttype | type | ) |
Definition at line 18 of file typename.c.
References ECPGt_bool, ECPGt_char, ECPGt_char_variable, ECPGt_const, ECPGt_date, ECPGt_decimal, ECPGt_double, ECPGt_float, ECPGt_int, ECPGt_interval, ECPGt_long, ECPGt_long_long, ECPGt_numeric, ECPGt_short, ECPGt_string, ECPGt_timestamp, ECPGt_unsigned_char, ECPGt_unsigned_int, ECPGt_unsigned_long, ECPGt_unsigned_long_long, ECPGt_unsigned_short, and ECPGt_varchar.
{
switch (typ)
{
case ECPGt_char:
case ECPGt_string:
return "char";
case ECPGt_unsigned_char:
return "unsigned char";
case ECPGt_short:
return "short";
case ECPGt_unsigned_short:
return "unsigned short";
case ECPGt_int:
return "int";
case ECPGt_unsigned_int:
return "unsigned int";
case ECPGt_long:
return "long";
case ECPGt_unsigned_long:
return "unsigned long";
case ECPGt_long_long:
return "long long";
case ECPGt_unsigned_long_long:
return "unsigned long long";
case ECPGt_float:
return "float";
case ECPGt_double:
return "double";
case ECPGt_bool:
return "bool";
case ECPGt_varchar:
return "varchar";
case ECPGt_char_variable:
return "char";
case ECPGt_decimal:
return "decimal";
case ECPGt_numeric:
return "numeric";
case ECPGt_date:
return "date";
case ECPGt_timestamp:
return "timestamp";
case ECPGt_interval:
return "interval";
case ECPGt_const:
return "Const";
default:
abort();
}
return ""; /* keep MSC compiler happy */
}
| void ECPGdump_a_type | ( | FILE * | , | |
| const char * | , | |||
| struct ECPGtype * | , | |||
| const | int, | |||
| const char * | , | |||
| struct ECPGtype * | , | |||
| const | int, | |||
| const char * | , | |||
| const char * | , | |||
| char * | , | |||
| const char * | , | |||
| const char * | ||||
| ) |
Definition at line 239 of file type.c.
References base_yyerror(), variable::brace_level, ECPGtype::counter, ECPGdump_a_simple(), ECPGdump_a_struct(), ECPGt_array, ECPGt_char_variable, ECPGt_const, ECPGt_descriptor, ECPGt_NO_INDICATOR, ECPGt_sqlda, ECPGt_struct, ECPGt_union, ECPGtype::element, ET_ERROR, ET_FATAL, ET_WARNING, find_variable(), free, INDICATOR_NOT_ARRAY, INDICATOR_NOT_SIMPLE, INDICATOR_NOT_STRUCT, indicator_set, IS_SIMPLE_TYPE, mm_strdup(), mmerror(), NULL, PARSE_ERROR, ECPGtype::size, variable::type, ECPGtype::type, ECPGtype::type_name, and ECPGtype::u.
Referenced by dump_variables(), ECPGdump_a_struct(), output_get_descr(), and output_set_descr().
{
struct variable *var;
if (type->type != ECPGt_descriptor && type->type != ECPGt_sqlda &&
type->type != ECPGt_char_variable && type->type != ECPGt_const &&
brace_level >= 0)
{
char *str;
str = mm_strdup(name);
var = find_variable(str);
free(str);
if ((var->type->type != type->type) ||
(var->type->type_name && !type->type_name) ||
(!var->type->type_name && type->type_name) ||
(var->type->type_name && type->type_name && strcmp(var->type->type_name, type->type_name) != 0))
mmerror(PARSE_ERROR, ET_ERROR, "variable \"%s\" is hidden by a local variable of a different type", name);
else if (var->brace_level != brace_level)
mmerror(PARSE_ERROR, ET_WARNING, "variable \"%s\" is hidden by a local variable", name);
if (ind_name && ind_type && ind_type->type != ECPGt_NO_INDICATOR && ind_brace_level >= 0)
{
str = mm_strdup(ind_name);
var = find_variable(str);
free(str);
if ((var->type->type != ind_type->type) ||
(var->type->type_name && !ind_type->type_name) ||
(!var->type->type_name && ind_type->type_name) ||
(var->type->type_name && ind_type->type_name && strcmp(var->type->type_name, ind_type->type_name) != 0))
mmerror(PARSE_ERROR, ET_ERROR, "indicator variable \"%s\" is hidden by a local variable of a different type", ind_name);
else if (var->brace_level != ind_brace_level)
mmerror(PARSE_ERROR, ET_WARNING, "indicator variable \"%s\" is hidden by a local variable", ind_name);
}
}
switch (type->type)
{
case ECPGt_array:
if (indicator_set && ind_type->type != ECPGt_array)
mmerror(INDICATOR_NOT_ARRAY, ET_FATAL, "indicator for array/pointer has to be array/pointer");
switch (type->u.element->type)
{
case ECPGt_array:
mmerror(PARSE_ERROR, ET_ERROR, "nested arrays are not supported (except strings)"); /* array of array */
break;
case ECPGt_struct:
case ECPGt_union:
ECPGdump_a_struct(o, name,
ind_name,
type->size,
type->u.element,
(ind_type == NULL) ? NULL : ((ind_type->type == ECPGt_NO_INDICATOR) ? ind_type : ind_type->u.element),
prefix, ind_prefix);
break;
default:
if (!IS_SIMPLE_TYPE(type->u.element->type))
base_yyerror("internal error: unknown datatype, please report this to <[email protected]>");
ECPGdump_a_simple(o, name,
type->u.element->type,
type->u.element->size, type->size, NULL, prefix, type->u.element->counter);
if (ind_type != NULL)
{
if (ind_type->type == ECPGt_NO_INDICATOR)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, mm_strdup("-1"), NULL, ind_prefix, 0);
else
{
ECPGdump_a_simple(o, ind_name, ind_type->u.element->type,
ind_type->u.element->size, ind_type->size, NULL, ind_prefix, 0);
}
}
}
break;
case ECPGt_struct:
if (indicator_set && ind_type->type != ECPGt_struct)
mmerror(INDICATOR_NOT_STRUCT, ET_FATAL, "indicator for struct has to be a struct");
ECPGdump_a_struct(o, name, ind_name, mm_strdup("1"), type, ind_type, prefix, ind_prefix);
break;
case ECPGt_union: /* cannot dump a complete union */
base_yyerror("type of union has to be specified");
break;
case ECPGt_char_variable:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, mm_strdup("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("1"), struct_sizeof, prefix, 0);
if (ind_type != NULL)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), ind_struct_sizeof, ind_prefix, 0);
break;
case ECPGt_descriptor:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, NULL, mm_strdup("-1"), NULL, prefix, 0);
if (ind_type != NULL)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, mm_strdup("-1"), NULL, ind_prefix, 0);
break;
default:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), struct_sizeof, prefix, type->counter);
if (ind_type != NULL)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), ind_struct_sizeof, ind_prefix, 0);
break;
}
}
| void ECPGfree_struct_member | ( | struct ECPGstruct_member * | ) |
Definition at line 549 of file type.c.
References free, ECPGstruct_member::name, ECPGstruct_member::next, and ECPGstruct_member::type.
Referenced by ECPGfree_type(), and main().
| void ECPGfree_type | ( | struct ECPGtype * | ) |
Definition at line 563 of file type.c.
References base_yyerror(), ECPGfree_struct_member(), ECPGt_array, ECPGt_struct, ECPGt_union, ECPGtype::element, ET_ERROR, free, IS_SIMPLE_TYPE, ECPGtype::members, mmerror(), PARSE_ERROR, ECPGtype::type, and ECPGtype::u.
Referenced by remove_variables().
{
if (!IS_SIMPLE_TYPE(type->type))
{
switch (type->type)
{
case ECPGt_array:
switch (type->u.element->type)
{
case ECPGt_array:
base_yyerror("internal error: found multidimensional array\n");
break;
case ECPGt_struct:
case ECPGt_union:
/* Array of structs. */
ECPGfree_struct_member(type->u.element->u.members);
free(type->u.element);
break;
default:
if (!IS_SIMPLE_TYPE(type->u.element->type))
base_yyerror("internal error: unknown datatype, please report this to <[email protected]>");
free(type->u.element);
}
break;
case ECPGt_struct:
case ECPGt_union:
ECPGfree_struct_member(type->u.members);
break;
default:
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized variable type code %d", type->type);
break;
}
}
free(type);
}
Definition at line 111 of file type.c.
References ECPGmake_simple_type(), ECPGt_array, ECPGtype::element, and ECPGtype::u.
Referenced by ECPGstruct_member_dup(), find_struct_member(), and find_variable().
{
struct ECPGtype *ne = ECPGmake_simple_type(ECPGt_array, size, 0);
ne->u.element = type;
return ne;
}
| struct ECPGtype* ECPGmake_simple_type | ( | enum | ECPGttype, | |
| char * | , | |||
| int | ||||
| ) | [read] |
Definition at line 96 of file type.c.
References ECPGtype::counter, ECPGtype::element, mm_alloc(), ECPGtype::size, ECPGtype::struct_sizeof, ECPGtype::type, ECPGtype::type_name, and ECPGtype::u.
Referenced by ECPGmake_array_type(), ECPGmake_struct_type(), ECPGstruct_member_dup(), find_struct_member(), and find_variable().
| void ECPGmake_struct_member | ( | char * | , | |
| struct ECPGtype * | , | |||
| struct ECPGstruct_member ** | ||||
| ) |
Definition at line 77 of file type.c.
References mm_alloc(), mm_strdup(), ECPGstruct_member::name, ECPGstruct_member::next, and ECPGstruct_member::type.
Referenced by ECPGstruct_member_dup().
{
struct ECPGstruct_member *ptr,
*ne =
(struct ECPGstruct_member *) mm_alloc(sizeof(struct ECPGstruct_member));
ne->name = mm_strdup(name);
ne->type = type;
ne->next = NULL;
for (ptr = *start; ptr && ptr->next; ptr = ptr->next);
if (ptr)
ptr->next = ne;
else
*start = ne;
}
| struct ECPGtype* ECPGmake_struct_type | ( | struct ECPGstruct_member * | , | |
| enum | ECPGttype, | |||
| char * | , | |||
| char * | ||||
| ) | [read] |
Definition at line 121 of file type.c.
References ECPGmake_simple_type(), ECPGstruct_member_dup(), ECPGtype::members, mm_strdup(), ECPGtype::struct_sizeof, ECPGtype::type_name, and ECPGtype::u.
Referenced by ECPGstruct_member_dup(), find_struct_member(), and find_variable().
{
struct ECPGtype *ne = ECPGmake_simple_type(type, mm_strdup("1"), 0);
ne->type_name = mm_strdup(type_name);
ne->u.members = ECPGstruct_member_dup(rm);
ne->struct_sizeof = struct_sizeof;
return ne;
}
| struct ECPGstruct_member* ECPGstruct_member_dup | ( | struct ECPGstruct_member * | ) | [read] |
Definition at line 37 of file type.c.
References ECPGtype::counter, ECPGmake_array_type(), ECPGmake_simple_type(), ECPGmake_struct_member(), ECPGmake_struct_type(), ECPGt_array, ECPGt_struct, ECPGt_union, ECPGtype::element, ECPGtype::members, ECPGstruct_member::name, ECPGstruct_member::next, ECPGtype::size, ECPGtype::struct_sizeof, ECPGstruct_member::type, ECPGtype::type, ECPGtype::type_name, and ECPGtype::u.
Referenced by ECPGmake_struct_type().
{
struct ECPGstruct_member *new = NULL;
while (rm)
{
struct ECPGtype *type;
switch (rm->type->type)
{
case ECPGt_struct:
case ECPGt_union:
type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
break;
case ECPGt_array:
/*
* if this array does contain a struct again, we have to
* create the struct too
*/
if (rm->type->u.element->type == ECPGt_struct || rm->type->u.element->type == ECPGt_union)
type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
else
type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->counter), rm->type->size);
break;
default:
type = ECPGmake_simple_type(rm->type->type, rm->type->size, rm->type->counter);
break;
}
ECPGmake_struct_member(rm->name, type, &new);
rm = rm->next;
}
return (new);
}
1.7.1