Use dynamic allocation for VHDL global built-in types
Instead of using automatic variables for global types, I allocate them dynamically. Thanks to it, all type objects can be treated in the same way, as all of them are pointers allocated with `new'. Now we will be able to remove all scopes in the same manner, no matter if it is a global or local scope, by deleting all carried pointers.
This commit is contained in:
parent
fd30d6c921
commit
46684bb28e
|
|
@ -140,7 +140,7 @@ static void import_ieee_use_std_logic_1164(ActiveScope*res, perm_string name)
|
|||
if (all_flag || name == "std_logic_vector") {
|
||||
vector<VTypeArray::range_t> dims (1);
|
||||
res->bind_name(perm_string::literal("std_logic_vector"),
|
||||
new VTypeArray(&primitive_STDLOGIC, dims, false));
|
||||
new VTypeArray(primitive_STDLOGIC, dims, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,12 +151,12 @@ static void import_ieee_use_numeric_bit(ActiveScope*res, perm_string name)
|
|||
if (all_flag || name == "signed") {
|
||||
vector<VTypeArray::range_t> dims (1);
|
||||
res->bind_name(perm_string::literal("signed"),
|
||||
new VTypeArray(&primitive_STDLOGIC, dims, true));
|
||||
new VTypeArray(primitive_STDLOGIC, dims, true));
|
||||
}
|
||||
if (all_flag || name == "unsigned") {
|
||||
vector<VTypeArray::range_t> dims (1);
|
||||
res->bind_name(perm_string::literal("unsigned"),
|
||||
new VTypeArray(&primitive_BIT, dims, false));
|
||||
new VTypeArray(primitive_BIT, dims, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,12 +167,12 @@ static void import_ieee_use_numeric_std(ActiveScope*res, perm_string name)
|
|||
if (all_flag || name == "signed") {
|
||||
vector<VTypeArray::range_t> dims (1);
|
||||
res->bind_name(perm_string::literal("signed"),
|
||||
new VTypeArray(&primitive_STDLOGIC, dims, true));
|
||||
new VTypeArray(primitive_STDLOGIC, dims, true));
|
||||
}
|
||||
if (all_flag || name == "unsigned") {
|
||||
vector<VTypeArray::range_t> dims (1);
|
||||
res->bind_name(perm_string::literal("unsigned"),
|
||||
new VTypeArray(&primitive_STDLOGIC, dims, false));
|
||||
new VTypeArray(primitive_STDLOGIC, dims, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,20 +194,19 @@ static void import_ieee_use(ActiveScope*res, perm_string package, perm_string na
|
|||
}
|
||||
}
|
||||
|
||||
const VTypePrimitive* primitive_BOOLEAN = new VTypePrimitive(VTypePrimitive::BOOLEAN);
|
||||
const VTypePrimitive* primitive_BIT = new VTypePrimitive(VTypePrimitive::BIT);
|
||||
const VTypePrimitive* primitive_INTEGER = new VTypePrimitive(VTypePrimitive::INTEGER);
|
||||
const VTypePrimitive* primitive_STDLOGIC = new VTypePrimitive(VTypePrimitive::STDLOGIC);
|
||||
|
||||
const VTypePrimitive primitive_BOOLEAN (VTypePrimitive::BOOLEAN);
|
||||
const VTypePrimitive primitive_BIT (VTypePrimitive::BIT);
|
||||
const VTypePrimitive primitive_INTEGER (VTypePrimitive::INTEGER);
|
||||
const VTypePrimitive primitive_STDLOGIC(VTypePrimitive::STDLOGIC);
|
||||
|
||||
const VTypeArray primitive_BIT_VECTOR(&primitive_BIT, vector<VTypeArray::range_t> (1));
|
||||
const VTypeArray primitive_BOOL_VECTOR(&primitive_BOOLEAN, vector<VTypeArray::range_t> (1));
|
||||
const VTypeArray* primitive_BIT_VECTOR = new VTypeArray(primitive_BIT, vector<VTypeArray::range_t> (1));
|
||||
const VTypeArray* primitive_BOOL_VECTOR = new VTypeArray(primitive_BOOLEAN, vector<VTypeArray::range_t> (1));
|
||||
|
||||
void generate_global_types(ActiveScope*res)
|
||||
{
|
||||
res->bind_name(perm_string::literal("boolean"), &primitive_BOOLEAN);
|
||||
res->bind_name(perm_string::literal("bit"), &primitive_BIT);
|
||||
res->bind_name(perm_string::literal("integer"), &primitive_INTEGER);
|
||||
res->bind_name(perm_string::literal("std_logic"), &primitive_STDLOGIC);
|
||||
res->bind_name(perm_string::literal("bit_vector"),&primitive_BOOL_VECTOR);
|
||||
res->bind_name(perm_string::literal("boolean"), primitive_BOOLEAN);
|
||||
res->bind_name(perm_string::literal("bit"), primitive_BIT);
|
||||
res->bind_name(perm_string::literal("integer"), primitive_INTEGER);
|
||||
res->bind_name(perm_string::literal("std_logic"), primitive_STDLOGIC);
|
||||
res->bind_name(perm_string::literal("bit_vector"),primitive_BOOL_VECTOR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ class VTypePrimitive : public VType {
|
|||
type_t type_;
|
||||
};
|
||||
|
||||
extern const VTypePrimitive primitive_BOOLEAN;
|
||||
extern const VTypePrimitive primitive_BIT;
|
||||
extern const VTypePrimitive primitive_INTEGER;
|
||||
extern const VTypePrimitive primitive_STDLOGIC;
|
||||
extern const VTypePrimitive* primitive_BOOLEAN;
|
||||
extern const VTypePrimitive* primitive_BIT;
|
||||
extern const VTypePrimitive* primitive_INTEGER;
|
||||
extern const VTypePrimitive* primitive_STDLOGIC;
|
||||
|
||||
/*
|
||||
* An array is a compound N-dimensional array of element type. The
|
||||
|
|
|
|||
Loading…
Reference in New Issue