本文整理汇总了C++中QualifiedType::get_base_type方法的典型用法代码示例。如果您正苦于以下问题:C++ QualifiedType::get_base_type方法的具体用法?C++ QualifiedType::get_base_type怎么用?C++ QualifiedType::get_base_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QualifiedType
的用法示例。
在下文中一共展示了QualifiedType::get_base_type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CleanupArrayStore
// Turn an reference pointer into an array reference expression
void ReferenceCleanupPass::CleanupArrayStore(StoreStatement* s)
{
assert(s != NULL) ;
// Check to see if the destination is a reference variable
Expression* destination = s->get_destination_address() ;
VariableSymbol* storedVariable = FindVariable(destination) ;
if (storedVariable == NULL)
{
return ;
}
if (dynamic_cast<ReferenceType*>(storedVariable->get_type()->get_base_type()))
{
// Can I just change the type? Pointer conversion should take care of it
// then, but I'll have to annotate it
ReferenceType* refType =
dynamic_cast<ReferenceType*>(storedVariable->get_type()->get_base_type()) ;
QualifiedType* internalType =
dynamic_cast<QualifiedType*>(refType->get_reference_type()) ;
assert(internalType != NULL) ;
DataType* internalType2 = internalType->get_base_type() ;
QualifiedType* qualType = storedVariable->get_type() ;
qualType->set_base_type(NULL) ;
refType->set_parent(NULL) ;
internalType->set_parent(NULL) ;
refType->set_reference_type(NULL) ;
qualType->set_base_type(internalType2) ;
}
}
示例2: AddSymbols
void ExportPass::AddSymbols()
{
assert(repository != NULL) ;
assert(constructedType != NULL) ;
assert(constructedSymbol != NULL) ;
// By this point, the repository has been read in and the symbol table
// has been completely overwritten.
SymbolTable* symTab = repository->get_external_symbol_table() ;
assert(symTab != NULL) ;
DataType* resultType = constructedType->get_result_type() ;
bool resultReplaced = false ;
for (int j = 0 ; j < symTab->get_symbol_table_object_count() ; ++j)
{
DataType* existingType =
dynamic_cast<DataType*>(symTab->get_symbol_table_object(j)) ;
if (existingType != NULL && EquivalentTypes(resultType, existingType))
{
constructedType->set_result_type(existingType) ;
resultReplaced = true ;
delete resultType ;
break ;
}
}
if (!resultReplaced)
{
symTab->append_symbol_table_object(resultType) ;
}
// Go through all of the arguments and replace them with appropriate types
// if they already exist in the symbol table.
for (int i = 0 ; i < constructedType->get_argument_count() ; ++i)
{
QualifiedType* currentArg = constructedType->get_argument(i) ;
assert(currentArg != NULL) ;
bool replaced = false ;
for (int j = 0 ; j < symTab->get_symbol_table_object_count() ; ++j)
{
QualifiedType* existingType =
dynamic_cast<QualifiedType*>(symTab->get_symbol_table_object(j)) ;
if (existingType != NULL && EquivalentTypes(currentArg, existingType) &&
existingType->get_annote_count() == currentArg->get_annote_count())
{
constructedType->replace_argument(i, existingType) ;
replaced = true ;
break ;
}
}
if (replaced == false)
{
symTab->append_symbol_table_object(currentArg) ;
symTab->append_symbol_table_object(currentArg->get_base_type()) ;
}
}
symTab->append_symbol_table_object(constructedType) ;
symTab->append_symbol_table_object(constructedSymbol) ;
}
示例3: CloneDataType
DataType* ExportPass::CloneDataType(DataType* t)
{
assert(t != NULL) ;
PointerType* pointerClone = dynamic_cast<PointerType*>(t) ;
ReferenceType* referenceClone = dynamic_cast<ReferenceType*>(t) ;
ArrayType* arrayClone = dynamic_cast<ArrayType*>(t) ;
if (pointerClone != NULL)
{
QualifiedType* refType =
dynamic_cast<QualifiedType*>(pointerClone->get_reference_type()) ;
assert(refType != NULL) ;
DataType* cloneType = CloneDataType(refType->get_base_type()) ;
assert(cloneType != NULL) ;
return create_pointer_type(theEnv,
IInteger(32),
0,
create_qualified_type(theEnv, cloneType)) ;
}
if (referenceClone != NULL)
{
QualifiedType* refType =
dynamic_cast<QualifiedType*>(referenceClone->get_reference_type()) ;
assert(refType != NULL) ;
DataType* clonedType = CloneDataType(refType->get_base_type()) ;
return create_reference_type(theEnv,
IInteger(32),
0,
create_qualified_type(theEnv, clonedType)) ;
}
if (arrayClone != NULL)
{
QualifiedType* elementType = arrayClone->get_element_type() ;
DataType* internalType = CloneDataType(elementType->get_base_type()) ;
QualifiedType* finalQual = create_qualified_type(theEnv, internalType) ;
return create_pointer_type(theEnv,
IInteger(32),
0,
finalQual) ;
}
return dynamic_cast<DataType*>(t->deep_clone()) ;
}
示例4: ValidSymbol
bool ConstantArrayPropagationPass::ValidSymbol(VariableSymbol* var)
{
assert(var != NULL) ;
// The variable should be an array type and have the const qualifier.
if (dynamic_cast<ArrayType*>(var->get_type()->get_base_type()) == NULL)
{
return false ;
}
QualifiedType* qualType = var->get_type() ;
while (dynamic_cast<ArrayType*>(qualType->get_base_type()) != NULL)
{
ArrayType* array = dynamic_cast<ArrayType*>(qualType->get_base_type()) ;
qualType = array->get_element_type() ;
}
assert(qualType != NULL) ;
for (int i = 0 ; i < qualType->get_qualification_count(); ++i)
{
if (qualType->get_qualification(i) == LString("const"))
{
return true ;
}
}
return false ;
}
示例5: CleanupCall
void ReferenceCleanupPass::CleanupCall(CallStatement* c)
{
assert(procDef != NULL) ;
assert(c != NULL) ;
// We only need to clean up module calls. If they are built in
// functions, like boolsel, we don't want to do this.
if (IsBuiltIn(c))
{
return ;
}
// Go through the arguments and see if any of them are load variable
// expressions to a reference typed variable, and replace those with
// symbol address expressions
for (unsigned int i = 0 ; i < c->get_argument_count() ; ++i)
{
Expression* currentArg = c->get_argument(i) ;
LoadVariableExpression* currentLoadVar =
dynamic_cast<LoadVariableExpression*>(currentArg) ;
if (currentLoadVar != NULL)
{
VariableSymbol* currentVar = currentLoadVar->get_source() ;
DataType* varType = currentVar->get_type()->get_base_type() ;
ReferenceType* refType = dynamic_cast<ReferenceType*>(varType) ;
if (refType != NULL)
{
QualifiedType* internalType =
dynamic_cast<QualifiedType*>(refType->get_reference_type()) ;
assert(internalType != NULL) ;
// currentVar->set_type(internalType) ;
SymbolAddressExpression* symAddrExp =
create_symbol_address_expression(theEnv,
internalType->get_base_type(),
currentVar) ;
if (currentLoadVar->lookup_annote_by_name("UndefinedPath") != NULL)
{
symAddrExp->append_annote(create_brick_annote(theEnv, "UndefinedPath")) ;
}
currentLoadVar->get_parent()->replace(currentLoadVar, symAddrExp) ;
}
}
}
}
示例6: ConstructSystemSymbols
void ExportPass::ConstructSystemSymbols()
{
ProcedureSymbol* originalSymbol = originalProcedure->get_procedure_symbol() ;
assert(originalSymbol != NULL) ;
CProcedureType* originalType =
dynamic_cast<CProcedureType*>(originalSymbol->get_type()) ;
assert(originalType != NULL) ;
constructedType = create_c_procedure_type(theEnv,
dynamic_cast<DataType*>(originalType->get_result_type()->deep_clone()),
false, // has variable arguments
false, // arguments known
0) ; // bit alignment
// The system has been written in one of two ways, either the old
// way where there are no arguments, or the new way where everything
// is put into the arguments.
if (originalType->get_argument_count() > 0)
{
for (int i = 0 ; i < originalType->get_argument_count() ; ++i)
{
QualifiedType* originalArgument = originalType->get_argument(i) ;
DataType* originalBase = originalArgument->get_base_type() ;
DataType* constructedBase = CloneDataType(originalBase) ;
QualifiedType* constructedArgument =
create_qualified_type(theEnv, constructedBase) ;
constructedType->append_argument(constructedArgument) ;
// Go through the symbol table and find the parameter symbol
// that matches the parameter number, and check to see if it
// is an output or not...
SymbolTable* symTab = originalProcedure->get_symbol_table() ;
ParameterSymbol* correspondingSymbol = NULL ;
for (int j = 0 ; j < symTab->get_symbol_table_object_count() ; ++j)
{
ParameterSymbol* currentSym =
dynamic_cast<ParameterSymbol*>(symTab->get_symbol_table_object(j)) ;
if (currentSym != NULL)
{
BrickAnnote* orderAnnote = dynamic_cast<BrickAnnote*>(currentSym->lookup_annote_by_name("ParameterOrder")) ;
assert(orderAnnote != NULL) ;
IntegerBrick* orderBrick =
dynamic_cast<IntegerBrick*>(orderAnnote->get_brick(0)) ;
assert(orderBrick != NULL) ;
if (orderBrick->get_value().c_int() == i)
{
correspondingSymbol = currentSym ;
break ;
}
}
}
if (correspondingSymbol != NULL)
{
if (correspondingSymbol->lookup_annote_by_name("OutputScalar") != NULL ||
correspondingSymbol->lookup_annote_by_name("OutputVariable") != NULL ||
correspondingSymbol->lookup_annote_by_name("OutputFifo") != NULL)
{
constructedArgument->append_annote(create_brick_annote(theEnv,
"Output")) ;
}
}
// if (dynamic_cast<ReferenceType*>(originalBase) != NULL)
//{
// constructedArgument->append_annote(create_brick_annote(theEnv,
// "Output")) ;
// }
}
}
else
{
SymbolTable* symTab = originalProcedure->get_symbol_table() ;
assert(symTab != NULL) ;
list<VariableSymbol*> inputScalars ;
list<VariableSymbol*> inputFifos ;
list<VariableSymbol*> outputScalars ;
list<VariableSymbol*> outputFifos ;
for (int i = 0 ; i < symTab->get_symbol_table_object_count() ; ++i)
{
VariableSymbol* currentVar =
dynamic_cast<VariableSymbol*>(symTab->get_symbol_table_object(i)) ;
if (currentVar != NULL &&
currentVar->lookup_annote_by_name("InputScalar") != NULL &&
currentVar->lookup_annote_by_name("TemporalFeedback") == NULL &&
currentVar->lookup_annote_by_name("NormalFeedback") == NULL &&
currentVar->lookup_annote_by_name("DebugRegister") == NULL)
{
inputScalars.push_back(currentVar) ;
}
if (currentVar != NULL &&
currentVar->lookup_annote_by_name("InputFifo") != NULL)
{
inputFifos.push_back(currentVar) ;
}
if (currentVar != NULL &&
currentVar->lookup_annote_by_name("OutputVariable") != NULL &&
currentVar->lookup_annote_by_name("Dummy") == NULL &&
currentVar->lookup_annote_by_name("FeedbackSource") == NULL)
{
//.........这里部分代码省略.........
示例7: RemoveProcedure
// Do a sort of garbage collection. Take all of the types that we want to
// delete and collect them. If there are no uses of them after this function
// has finished, then remove them.
void RemoveModulePass::RemoveProcedure(ProcedureSymbol* p)
{
assert(repository != NULL) ;
list<Type*> usedTypes ;
if (p == NULL)
{
return ;
}
// There should be no definition, but just in case remove it
ProcedureDefinition* defToRemove = p->get_definition() ;
p->set_definition(NULL) ;
if (defToRemove != NULL)
{
delete defToRemove ;
}
// Clear out all of the values associated with the procedure type
CProcedureType* procType =
dynamic_cast<CProcedureType*>(p->get_type()) ;
assert(procType != NULL) ;
DataType* returnTypeToRemove = procType->get_result_type() ;
procType->set_result_type(NULL) ;
if (returnTypeToRemove != NULL)
{
usedTypes.push_back(returnTypeToRemove) ;
}
while (procType->get_argument_count() > 0)
{
QualifiedType* currentArg = procType->get_argument(0) ;
procType->remove_argument(0) ;
if (!InList(usedTypes, currentArg))
{
usedTypes.push_back(currentArg) ;
}
}
SymbolTable* symTab = repository->get_external_symbol_table() ;
p->set_type(NULL) ;
symTab->remove_symbol_table_object(procType) ;
delete procType ;
symTab->remove_symbol_table_object(p) ;
delete p ;
// Now, go through each used type and see if it is used anywhere
list<Type*>::iterator typeIter = usedTypes.begin() ;
while (typeIter != usedTypes.end())
{
bool removeMe = true ;
for (int i = 0 ; i < symTab->get_symbol_table_object_count() ; ++i)
{
CProcedureType* currentType =
dynamic_cast<CProcedureType*>(symTab->get_symbol_table_object(i)) ;
if (currentType != NULL)
{
if (IsUsed(*typeIter, currentType))
{
removeMe = false ;
break ;
}
}
}
if (removeMe)
{
if ((*typeIter)->lookup_annote_by_name("Output") != NULL)
{
delete (*typeIter)->remove_annote_by_name("Output") ;
}
QualifiedType* q = dynamic_cast<QualifiedType*>(*typeIter) ;
DataType* d = dynamic_cast<DataType*>(*typeIter) ;
if (q != NULL)
{
DataType* internalD = q->get_base_type() ;
q->set_base_type(NULL) ;
symTab->remove_symbol_table_object(internalD) ;
symTab->remove_symbol_table_object(q) ;
delete internalD ;
delete q ;
}
else if (d != NULL)
{
symTab->remove_symbol_table_object(d) ;
delete d ;
}
else
{
assert(0 && "Trying to remove something weird...") ;
}
}
++typeIter ;
}
}
示例8: ReplaceNDReference
// All of the array references expressions in the passed in the struct are
// equivalent, so we can determine types of the original and use that
// to create a new expression with which to replace everything.
bool TransformUnrolledArraysPass::ReplaceNDReference(EquivalentReferences* a)
{
assert(a != NULL) ;
assert(a->original != NULL) ;
// Check to see if the reference at this stage is a constant or not
IntConstant* constantIndex =
dynamic_cast<IntConstant*>(a->original->get_index()) ;
if (constantIndex == NULL)
{
// There was no replacement made
return false ;
}
Expression* baseAddress = a->original->get_base_array_address() ;
assert(baseAddress != NULL) ;
assert(constantIndex != NULL) ;
// Create a replacement expression for this value. This will either
// be another array reference expression or a single variable.
Expression* replacementExp = NULL ;
// QualifiedType* elementType = GetQualifiedTypeOfElement(a->original) ;
VariableSymbol* originalSymbol = GetArrayVariable(a->original) ;
assert(originalSymbol != NULL) ;
LString replacementName =
GetReplacementName(originalSymbol->get_name(),
constantIndex->get_value().c_int()) ;
int dimensionality = GetDimensionality(a->original) ;
QualifiedType* elementType = originalSymbol->get_type() ;
while (dynamic_cast<ArrayType*>(elementType->get_base_type()) != NULL)
{
elementType = dynamic_cast<ArrayType*>(elementType->get_base_type())->get_element_type() ;
}
// There is a special case for one dimensional arrays as opposed to all
// other dimensional arrays. It only should happen if we are truly
// replacing an array with a one dimensional array.
if (dimensionality == 1 &&
dynamic_cast<ArrayReferenceExpression*>(a->original->get_parent())==NULL)
{
VariableSymbol* replacementVar =
create_variable_symbol(theEnv,
GetQualifiedTypeOfElement(a->original),
TempName(replacementName)) ;
procDef->get_symbol_table()->append_symbol_table_object(replacementVar) ;
replacementExp =
create_load_variable_expression(theEnv,
elementType->get_base_type(),
replacementVar) ;
}
else
{
// Create a new array with one less dimension. This requires a new
// array type.
ArrayType* varType =
dynamic_cast<ArrayType*>(originalSymbol->get_type()->get_base_type()) ;
assert(varType != NULL) ;
ArrayType* replacementArrayType =
create_array_type(theEnv,
varType->get_element_type()->get_base_type()->get_bit_size(),
0, // bit alignment
OneLessDimension(originalSymbol->get_type(), dimensionality),
dynamic_cast<Expression*>(varType->get_lower_bound()->deep_clone()),
dynamic_cast<Expression*>(varType->get_upper_bound()->deep_clone()),
TempName(varType->get_name())) ;
procDef->get_symbol_table()->append_symbol_table_object(replacementArrayType) ;
VariableSymbol* replacementArraySymbol =
create_variable_symbol(theEnv,
create_qualified_type(theEnv,
replacementArrayType,
TempName(LString("qualType"))),
TempName(replacementName)) ;
procDef->get_symbol_table()->append_symbol_table_object(replacementArraySymbol) ;
// Create a new symbol address expression for this variable symbol
SymbolAddressExpression* replacementAddrExp =
create_symbol_address_expression(theEnv,
replacementArrayType,
replacementArraySymbol) ;
// Now, replace the symbol address expression in the base
// array address with this symbol.
ReplaceSymbol(a->original, replacementAddrExp) ;
// And replace this reference with the base array address.
replacementExp = a->original->get_base_array_address() ;
a->original->set_base_array_address(NULL) ;
replacementExp->set_parent(NULL) ;
}
//.........这里部分代码省略.........
示例9: Transform
//.........这里部分代码省略.........
{
BrickAnnote* orderAnnote =
dynamic_cast<BrickAnnote*>((*portIter)->
lookup_annote_by_name("ParameterOrder")) ;
if (orderAnnote == NULL)
{
++portIter ;
continue ;
}
IntegerBrick* orderBrick =
dynamic_cast<IntegerBrick*>(orderAnnote->get_brick(0)) ;
assert(orderBrick != NULL) ;
if (orderBrick->get_value().c_int() == i)
{
sortedPorts.push_back(*portIter) ;
break ;
}
++portIter ;
}
}
if (sortedPorts.size() != ports.size())
{
OutputWarning("Warning! Analysis detected some input scalars not in"
" the parameter list") ;
}
// Replace ports with sortedPorts
ports = sortedPorts ;
}
list<VariableSymbol*>::iterator portIter = ports.begin() ;
while (portIter != ports.end())
{
bitSize +=
(*portIter)->get_type()->get_base_type()->get_bit_size().c_int() ;
LString dupeName = (*portIter)->get_name() ;
// Create offset expression:
IntConstant* offset =
create_int_constant(theEnv,
create_data_type(theEnv,
IInteger(32),
0),
IInteger(bitSize)) ;
QualifiedType* dupeType = (*portIter)->get_type() ;
// Deal with the case where reference types were passed in
ReferenceType* refType =
dynamic_cast<ReferenceType*>(dupeType->get_base_type()) ;
while (refType != NULL)
{
dupeType = dynamic_cast<QualifiedType*>(refType->get_reference_type()) ;
assert(dupeType != NULL) ;
refType = dynamic_cast<ReferenceType*>(dupeType->get_base_type()) ;
}
// Create a new variable symbol clone
FieldSymbol* dupe =
create_field_symbol(theEnv,
dupeType,
offset,
dupeName) ;
structTable->append_symbol_table_object(dupe) ;
示例10: do_file_set_block
void DismantleStructuredReturns::do_file_set_block( FileSetBlock* file_set_block ) {
suif_map<CProcedureType *,QualifiedType *> type_map;
list<ArrayReferenceExpression*> ref_exprs;
SuifEnv *env = 0;
TypeBuilder *tb = 0;
VoidType *vt = 0;
for (Iter<ProcedureSymbol> iter =
object_iterator<ProcedureSymbol>(file_set_block);
iter.is_valid();
iter.next()) {
ProcedureSymbol *sym = &iter.current();
Type *type = sym->get_type();
if (!is_kind_of<CProcedureType>(type))
continue;
CProcedureType *cp_type = to<CProcedureType>(type);
type = cp_type->get_result_type();
if (!env) {
env = type->get_suif_env();
tb = (TypeBuilder*)
env->get_object_factory(TypeBuilder::get_class_name());
vt = tb->get_void_type();
}
suif_map<CProcedureType *,QualifiedType *>::iterator t_iter = type_map.find(cp_type);
QualifiedType *qtype;
if (t_iter == type_map.end()) {
if (!is_kind_of<GroupType>(type) && !is_kind_of<ArrayType>(type))
continue;
qtype = tb->get_qualified_type(
tb->get_pointer_type(to<DataType>(type)));
cp_type->set_result_type(vt);
cp_type->insert_argument(0,qtype);
type_map.enter_value(cp_type,qtype);
}
else {
qtype = (*t_iter).second;
}
ProcedureDefinition *def = sym->get_definition();
if (!def)
continue;
ParameterSymbol *par = create_parameter_symbol(env,qtype);
def->get_symbol_table()->append_symbol_table_object(par);
def->insert_formal_parameter(0,par);
// Convert all returns into assigned and returns
for (Iter<ReturnStatement> ret_iter = object_iterator<ReturnStatement>(def->get_body());
ret_iter.is_valid();
ret_iter.next()) {
ReturnStatement *ret = &ret_iter.current();
Expression *retval = ret->get_return_value();
ret->set_return_value(0);
retval->set_parent(0);
insert_statement_before(ret,
create_store_statement(env,retval,create_var_use(par)));
}
}
// Change all calls to the new form
for (Iter<CallStatement> cs_iter =
object_iterator<CallStatement>(file_set_block);
cs_iter.is_valid();
cs_iter.next()) {
CallStatement *call = &cs_iter.current();
Type *type = call->get_callee_address()->get_result_type();
Type *p_type = tb->unqualify_type(to<PointerType>(type)->get_reference_type());
if (!is_kind_of<PointerType>(p_type))
continue;
p_type = tb->unqualify_type(to<PointerType>(p_type)->get_reference_type());
if (!is_kind_of<CProcedureType>(p_type))
continue;
CProcedureType *cp_type = to<CProcedureType>(p_type);
suif_map<CProcedureType *,QualifiedType *>::iterator t_iter = type_map.find(cp_type);
if (t_iter == type_map.end())
continue;
QualifiedType *qtype = (*t_iter).second;
DataType *var_type = to<DataType>(tb->unqualify_type(to<PointerType>(qtype->get_base_type())
->get_reference_type()));
VariableSymbol *var =
new_anonymous_variable(env,call,tb->get_qualified_type(var_type));
Expression *exp = create_symbol_address_expression(
env,
tb->get_pointer_type(var_type),
var);
call->insert_argument(0,exp);
call->set_destination(0);
}
for (Iter<CallExpression> ce_iter =
object_iterator<CallExpression>(file_set_block);
ce_iter.is_valid();
ce_iter.next()) {
CallExpression *call = &ce_iter.current();
Type *type = call->get_callee_address()->get_result_type();
Type *p_type = tb->unqualify_type(to<PointerType>(type)->get_reference_type());
if (!is_kind_of<PointerType>(p_type))
continue;
p_type = tb->unqualify_type(to<PointerType>(p_type)->get_reference_type());
//.........这里部分代码省略.........