#ifndef TYPE_BUILDER__TYPE_BUILDER_H
#define TYPE_BUILDER__TYPE_BUILDER_H
#include "suifkernel/real_object_factory.h"
#include "basicnodes/basic_forwarders.h"
#include "basicnodes/basic.h"
#include "suifnodes/suif_forwarders.h"
#include "suifkernel/suifkernel_forwarders.h"
#include "common/i_integer.h"
#include "common/suif_vector.h"
GlobalInformationBlock* get_global_information_block( SuifEnv* suif_env, const LString& name );
TargetInformationBlock *find_target_information_block(SuifEnv *env);
extern "C" void EXPORT init_typebuilder( SuifEnv *suif );
class TypeBuilder : public RealObjectFactory {
public:
virtual void init(SuifEnv* suif);
static const LString &get_class_name();
virtual const LString &getName();
DataType *unqualify_data_type(Type *t);
Type* unqualify_type( Type* t );
// ---------- unnamed types -----------
//
virtual VoidType* get_void_type();
virtual BooleanType* get_boolean_type(
IInteger size_in_bits,
int alignment_in_bits );
virtual BooleanType * get_boolean_type();
virtual IntegerType* get_integer_type(
IInteger size_in_bits,
int alignment_in_bits,
bool is_signed = true );
virtual IntegerType* get_smallest_integer_type();
virtual IntegerType *get_integer_type(bool is_signed = true);
virtual FloatingPointType* get_floating_point_type(
IInteger size_in_bits,
int alignment_in_bits );
virtual FloatingPointType *get_floating_point_type();
virtual FloatingPointType *get_double_floating_point_type();
virtual PointerType* get_pointer_type(
IInteger size_in_bits,
int alignment_in_bits,
Type* reference_type);
virtual PointerType* get_pointer_type(Type* reference_type);
virtual ReferenceType* get_reference_type(
IInteger size_in_bits,
int alignment_in_bits,
Type* reference_type);
virtual ReferenceType* get_reference_type(Type* reference_type);
virtual ArrayType* get_array_type(
IInteger size_in_bits,
int alignment_in_bits,
QualifiedType* element_type,
Expression *lower_bound,
Expression *upper_bound);
virtual ArrayType* get_array_type(
QualifiedType* element_type,
const IInteger &lower_bound,
const IInteger &upper_bound);
virtual ArrayType* get_array_type(
QualifiedType* element_type,
Expression *lower_bound,
Expression *upper_bound);
virtual MultiDimArrayType* get_multi_dim_array_type(
IInteger size_in_bits,
int alignment_in_bits,
QualifiedType* element_type,
suif_vector<Expression *> &lower_bounds,
suif_vector<Expression *> &upper_bounds);
virtual MultiDimArrayType* get_multi_dim_array_type(
QualifiedType* element_type,
suif_vector<Expression *> &lower_bounds,
suif_vector<Expression *> &upper_bounds);
virtual QualifiedType* get_qualified_type(DataType *base_type,
list<LString> qualifiers
);
virtual QualifiedType* get_qualified_type(DataType *base_type,
const LString &qualifier
);
virtual QualifiedType* get_qualified_type(QualifiedType *base_type,
list<LString> qualifiers
);
virtual QualifiedType* get_qualified_type(QualifiedType *base_type,
const LString &qualifier
);
virtual QualifiedType* get_qualified_type(DataType *base_type);
virtual LabelType* get_label_type();
virtual CProcedureType* get_c_procedure_type(
DataType * result_type,
list<QualifiedType *> argument_list,
bool has_varags = false,
bool arguments_known = true,
int bit_alignment = 0);
virtual GroupType *get_group_type(
list<SymbolTable*>symbol_tables,
list<LString>&names,
list<QualifiedType *> &type_list);
virtual UnionType *get_union_type(
list<SymbolTable*>symbol_tables,
list<LString>&names,
list<QualifiedType *> &type_list);
virtual FieldSymbol * add_symbol_to_group(
GroupType *group,
const LString &symbol_name,
const QualifiedType *symbol_type);
virtual FieldSymbol * add_union_symbol_to_group(
GroupType *group,
const LString &symbol_name,
const QualifiedType *symbol_type,
int pos = -1);
virtual FieldSymbol * find_field_of_type(
GroupType *group,
const Type *field_type);
virtual FieldSymbol * find_symbol_containing_offset(
GroupType *group,
IInteger offset);
virtual FieldSymbol * find_non_group_symbol_containing_offset(
GroupType *group,
IInteger offset);
virtual DataType * find_type_of_field_containing_offset(
GroupType *group,
IInteger offset);
static bool is_argument_types_match(list<QualifiedType *>&argument_list,
CProcedureType *typ);
static SymbolTable * most_nested_common_scope(SymbolTable *newtable,
SymbolTable *table);
static SymbolTable * most_nested_common_scope(list<QualifiedType *> &tlist,
SymbolTable *table);
/*
* Return true iff ancestor is (the parent of)* child.
*/
static bool is_ancestor_of(SuifObject *ancestor, SuifObject *child);
void get_array_bounds(Type *type,int bound,IInteger &low,IInteger &high);
};
TypeBuilder* get_type_builder( SuifEnv* suif_env );
//#ifdef COMPATIBILITY
// Don't call these!
VoidType * get_void_type(SuifEnv *);
BooleanType* get_boolean_type( SuifEnv *,
IInteger size_in_bits,
int alignment_in_bits );
IntegerType* get_integer_type( SuifEnv *,
IInteger size_in_bits,
int alignment_in_bits,
bool is_signed = true );
IntegerType* get_integer_type( SuifEnv *,
bool is_signed = true);
FloatingPointType* get_floating_point_type( SuifEnv *,
IInteger size_in_bits,
int alignment_in_bits );
FloatingPointType* get_floating_point_type( SuifEnv * );
FloatingPointType* get_double_floating_point_type( SuifEnv * );
PointerType* get_pointer_type( SuifEnv *,
IInteger size_in_bits,
int alignment_in_bits,
Type* reference_type);
PointerType* get_pointer_type( SuifEnv *,
Type* reference_type);
ArrayType* get_array_type( SuifEnv *,
IInteger size_in_bits,
int alignment_in_bits,
QualifiedType* element_type,
Expression *lower_bound,
Expression *upper_bound);
ArrayType* get_array_type( SuifEnv*,
QualifiedType* element_type,
const IInteger &lower_bound,
const IInteger &upper_bound );
ArrayType *get_array_type(
SuifEnv *_suif,
QualifiedType *reference_type,
Expression *lower_bound,
Expression *upper_bound);
QualifiedType* get_qualified_type( SuifEnv *,
DataType *base_type,
list<LString> qualifiers);
QualifiedType* get_qualified_type(
SuifEnv *_suif,
DataType *base_type,
LString qualifier);
CProcedureType* get_c_procedure_type( SuifEnv *,
DataType* result,
list<QualifiedType *>& argument_list,
bool has_varags = false,
bool arguments_known = true ,
int bit_alignment = 0);
MultiDimArrayType* get_multi_dim_array_type( SuifEnv*,
QualifiedType* element_type,
suif_vector<Expression *> &lower_bounds,
suif_vector<Expression *> &upper_bounds);
//#endif
//extern bool equalExpression(Expression *a, Expression *b);
#endif