当前位置: 首页>>代码示例>>C++>>正文


C++ VariableSymbol类代码示例

本文整理汇总了C++中VariableSymbol的典型用法代码示例。如果您正苦于以下问题:C++ VariableSymbol类的具体用法?C++ VariableSymbol怎么用?C++ VariableSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VariableSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

// 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) ;
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:34,代码来源:reference_cleanup_pass.cpp

示例2: handle_static_variable_symbol

static String handle_static_variable_symbol(CPrintStyleModule *map,
					    const SuifObject *obj) {
  VariableSymbol *var = to<VariableSymbol>(obj);
  // I'd like to figure out what procedure and BLOCK scope this
  // is in...
  return(String(var->get_name()));
}
开发者ID:jrk,项目名称:suif2,代码行数:7,代码来源:cprint_style.cpp

示例3: assert

void ConstantArrayPropagationPass::CollectInitializations()
{
  if (!initializations.empty())
  {
    initializations.clear() ;
  }

  DefinitionBlock* procDefBlock = procDef->get_definition_block() ;
  assert(procDefBlock != NULL) ;
  Iter<VariableDefinition*> varDefIter = 
    procDefBlock->get_variable_definition_iterator() ;
  while (varDefIter.is_valid())
  {    
    VariableDefinition* varDef = varDefIter.current() ;
    assert(varDef != NULL) ;

    VariableSymbol* varSym = varDef->get_variable_symbol() ;
    ValueBlock* valBlock = varDef->get_initialization() ;
    assert(varSym != NULL) ;
    assert(valBlock != NULL) ;

    if (ValidSymbol(varSym)) 
    {
      initializations[varSym] = valBlock ;
      varSym->append_annote(create_brick_annote(theEnv, "ConstPropArray")) ;
    }

    varDefIter.next() ;
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:30,代码来源:constantArrayPropagationPass.cpp

示例4: assert

void LUTDetectionPass::do_procedure_definition(ProcedureDefinition* p)
{
  procDef = p ;
  assert(procDef != NULL) ;
  OutputInformation("LUT Detection Pass begins") ;

  // LUTs can only exist in New Style Systems or Modules
  if (isLegacy(procDef))
  {    
    OutputInformation("Legacy code - No LUTs supported") ;
    return ;
  }    
  
  // LUTs are defined to be arrays that are not parameter symbols
  SymbolTable* symTab = procDef->get_symbol_table() ;
  for (int i = 0 ; i < symTab->get_symbol_table_object_count() ; ++i)
  {
    SymbolTableObject* currentObject = symTab->get_symbol_table_object(i) ;
    VariableSymbol* currentVar = 
      dynamic_cast<VariableSymbol*>(currentObject) ;
    ParameterSymbol* currentParam =
      dynamic_cast<ParameterSymbol*>(currentObject) ;
    if (currentVar != NULL &&
	dynamic_cast<ArrayType*>(currentVar->get_type()->get_base_type()) != NULL &&
	currentParam == NULL &&
	currentVar->lookup_annote_by_name("ConstPropArray") == NULL)
    {
      // Found one!  Let's mark it!
      currentObject->append_annote(create_brick_annote(theEnv, "LUT")) ;
    }
  }

  OutputInformation("LUT Detection Pass ends") ;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:34,代码来源:lutDetectionPass.cpp

示例5: while

void CopyPropagationPass2::Initialize()
{
  // I don't want to delete any of the statements, but I must clear
  //  out the list I was using to contain the statements
  if (!toBeRemoved.empty())
  {
    while (toBeRemoved.begin() != toBeRemoved.end())
    {
      toBeRemoved.pop_front() ;
    }
  }

  assert(procDef != NULL) ;

  InitializeMap() ;

  // Also, collect all of the feedback variables for later
  
  SymbolTable* procSymTable = procDef->get_symbol_table() ;
  assert(procSymTable != NULL) ;

  for (int i = 0 ; i < procSymTable->get_symbol_table_object_count() ; ++i)
  {
    if(dynamic_cast<VariableSymbol*>(procSymTable->get_symbol_table_object(i)) != NULL)
    {
      VariableSymbol* nextSymbol = 
	dynamic_cast<VariableSymbol*>(procSymTable->get_symbol_table_object(i));
      if (nextSymbol->lookup_annote_by_name("FeedbackVariable") != NULL)
      {
	feedbackVariables.push_back(nextSymbol) ;
      }
    }
  }

}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:35,代码来源:copy_propagation_pass2.cpp

示例6: shared_from_this

std::shared_ptr<ExpressionNode> VariableNode::evaluate(Environment* e)
{
    VariableSymbol* vs = 0;
    if ((vs = e->getVariable(name))) {      // double parantheses because
        return vs->getValue()->evaluate(e); // compiler is a smartass otherwise
    }
    else
        return shared_from_this();
}
开发者ID:QlowB,项目名称:Mathy,代码行数:9,代码来源:Node.cpp

示例7: assert

void ExportPass::ConstructModuleSymbols()
{
  CProcedureType* originalType = dynamic_cast<CProcedureType*>(originalProcedure->get_procedure_symbol()->get_type()) ;
  assert(originalType != NULL) ;

  // The original type takes and returns a struct.  We need to change this
  //  to a list of arguments.

  VoidType* newReturnType = create_void_type(theEnv, IInteger(0), 0) ;
  constructedType = create_c_procedure_type(theEnv,
					    newReturnType,
					    false, // has varargs
					    true, // arguments_known
					    0, // bit alignment
					    LString("ConstructedType")) ;

  StructType* returnType = 
    dynamic_cast<StructType*>(originalType->get_result_type()) ;
  assert(returnType != NULL) ;

  SymbolTable* structSymTab = returnType->get_group_symbol_table() ;
  assert(structSymTab != NULL) ;

  for (int i = 0 ; i < structSymTab->get_symbol_table_object_count() ; ++i)
  {
    VariableSymbol* nextVariable = 
      dynamic_cast<VariableSymbol*>(structSymTab->get_symbol_table_object(i));
    if (nextVariable != NULL)
    {
      // Check to see if this is an output or not
      QualifiedType* cloneType ;
      DataType* cloneBase = 
	dynamic_cast<DataType*>(nextVariable->get_type()->get_base_type()->deep_clone()) ;
      assert(cloneBase != NULL) ;
      cloneType = create_qualified_type(theEnv, cloneBase) ;
 
      if (nextVariable->lookup_annote_by_name("Output") != NULL)
      {
	cloneType->append_annote(create_brick_annote(theEnv, "Output")) ;
	// Why doesn't this stick around?
      }
      constructedType->append_argument(cloneType) ;
    }
  }

  constructedSymbol = create_procedure_symbol(theEnv,
					      constructedType,
					      originalProcedure->get_procedure_symbol()->get_name()) ;
  constructedSymbol->set_definition(NULL) ;

}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:51,代码来源:exportPass.cpp

示例8: assert

// This is a vastly simpler way to setup annotations that doesn't worry
//  or assume that all feedbacks come from a single store variable statement
void SolveFeedbackVariablesPass3::SetupAnnotations()
{
  assert(theEnv != NULL) ;
  // Go through the list of all feedback instances we have discovered.
  list<PossibleFeedbackPair>::iterator feedbackIter = actualFeedbacks.begin();
  while (feedbackIter != actualFeedbacks.end())
  {
    // For every feedback, we need to create a two variables
    //  The first one is a replacement for the original use.
    //  The second one is the variable used for feedback.

    LString replacementName = (*feedbackIter).varSym->get_name() ;
    replacementName = replacementName + "_replacementTmp" ;

    VariableSymbol* replacementVariable = 
      create_variable_symbol(theEnv,
			     (*feedbackIter).varSym->get_type(),
			     TempName(replacementName)) ;
    procDef->get_symbol_table()->append_symbol_table_object(replacementVariable);

    VariableSymbol* feedbackVariable =
	create_variable_symbol(theEnv,
			       (*feedbackIter).varSym->get_type(),
			       TempName(LString("feedbackTmp"))) ;
    procDef->get_symbol_table()->append_symbol_table_object(feedbackVariable) ;
    
    // Replace the use with this new feedback variable
    (*feedbackIter).use->set_source(replacementVariable) ;

    // I am looking for the variable that originally defined me and 
    //  the variable that will replace me.
    Statement* definition = (*feedbackIter).definition ;
    VariableSymbol* definitionVariable = 
      GetDefinedVariable(definition, (*feedbackIter).definitionLocation) ;
    assert(definitionVariable != NULL) ;

    // Finally, annotate the feedback variable
    SetupAnnotations(feedbackVariable,		     
		     definitionVariable,
		     replacementVariable) ;
    
    replacementVariable->append_annote(create_brick_annote(theEnv,
							   "NonInputScalar"));

    ++feedbackIter ;
  }  
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:49,代码来源:solve_feedback_variables_pass_2.0_new.cpp

示例9: getOrCreateScope

VarDecl *
NameResolver::HandleVarDecl(NameToken name, TypeSpecifier &spec, Expression *init)
{
  Scope *scope = getOrCreateScope();

  // :TODO: set variadic info
  VarDecl *var = new (pool_) VarDecl(name, init);

  // Note: the parser has already bound |var->init()| at this point, meaning
  // that aside from globals it should be impossible to self-initialize like:
  //    int x = x;
  //
  // :TODO: do check this for globals.
  VariableSymbol *sym = new (pool_) VariableSymbol(var, scope, var->name());
  registerSymbol(sym);
  var->setSymbol(sym);

  // Set this before we evaluate the type, since it determines whether or not
  // a const on a parameter is meaningless.
  if (spec.isByRef()) {
    assert(scope->kind() == Scope::Argument && sym->isArgument());
    sym->storage_flags() |= StorageFlags::byref;
  }

  // See the comment in TypeResolver::visitVarDecl for why we do not want to
  // infer sizes from literals for arguments.
  if (init &&
      !scope->isArgument() &&
      ((init->isArrayLiteral() && init->asArrayLiteral()->isFixedArrayLiteral()) ||
       (init->isStringLiteral())))
  {
    // Wait until the type resolution pass to figure this out. We still have
    // to precompute the base though.
    if (Type *type = resolveBase(spec))
      spec.setResolvedBaseType(type);
    var->te() = TypeExpr(new (pool_) TypeSpecifier(spec));
  } else {
    VarDeclSpecHelper helper(var, nullptr);
    var->te() = resolve(spec, &helper);
  }

  if (var->te().resolved()) {
    sym->setType(var->te().resolved());

    // We need to check this both here and in lazy resolution, which is gross,
    // but I don't see any obvious way to simplify it yet.
    if (spec.isByRef() && sym->type()->passesByReference()) {
      cc_.report(spec.byRefLoc(), rmsg::type_cannot_be_ref)
        << sym->type();
    }
  }

  // Even if we were able to resolve the type, if we have to resolve a constant
  // value, we'll have to add it to the resolver queue.
  if (!var->te().resolved() || sym->canUseInConstExpr())
    tr_.addPending(var);

  return var;
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:59,代码来源:name-resolver.cpp

示例10: assert

void
SemanticAnalysis::visitNameProxy(NameProxy *proxy)
{
  Symbol *sym = proxy->sym();
  VariableSymbol *var = sym->asVariable();

  // If we see that a symbol is a function literal, then we bypass the scope
  // chain operations entirely and hardcode the function literal.
  if (sym->isFunction()) {
    assert(sym->scope()->kind() == Scope::Global);
    hir_ = new (pool_) HFunction(proxy, sym->asFunction());
    return;
  }

  if (value_context_ == kLValue) {
    // Egads! We're being asked to construct an l-value instead of an r-value.
    *outp_ = LValue(var);
    return;
  }

  Scope *in = sym->scope();
  switch (in->kind()) {
    case Scope::Global:
      hir_ = new (pool_) HGlobal(proxy, var);
      return;

    case Scope::Function:
    {
      assert(var->storage() == VariableSymbol::Arg);
      // Since we're in an r-value context, we need to strip the reference type.
      Type *type = var->type();
      if (type->isReference())
        type = type->toReference()->contained();
      hir_ = new (pool_) HLocal(proxy, type, var);
      return;
    }

    default:
      assert(in->kind() == Scope::Block);
      assert(var->storage() == VariableSymbol::Local);
      hir_ = new (pool_) HLocal(proxy, var->type(), var);
      return;
  }
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:44,代码来源:old-sema.cpp

示例11: if

bool
VarDeclSpecHelper::receiveConstQualifier(CompileContext &cc, const SourceLocation &constLoc, Type *type)
{
  VariableSymbol *sym = decl_->sym();
  if (sym->isArgument()) {
    if (!!(sym->storage_flags() & StorageFlags::byref)) {
      cc.report(constLoc, rmsg::const_ref_has_no_meaning) << type;
      return true;
    }
    if (!type->passesByReference()) {
      cc.report(constLoc, rmsg::const_has_no_meaning) << type;
      return true;
    }
  } else if (TypeSupportsCompileTimeInterning(type)) {
    sym->storage_flags() |= StorageFlags::constval;
  }

  sym->storage_flags() |= StorageFlags::readonly;
  return true;
}
开发者ID:collinsmith,项目名称:sourcepawn,代码行数:20,代码来源:type-resolver.cpp

示例12: assert

void CleanupRedundantVotes::ProcessCall(CallStatement* c)
{
  assert(c != NULL) ;
  
  SymbolAddressExpression* symAddress = 
    dynamic_cast<SymbolAddressExpression*>(c->get_callee_address()) ;
  assert(symAddress != NULL) ;
  
  Symbol* sym = symAddress->get_addressed_symbol() ;
  assert(sym != NULL) ;

  if (sym->get_name() == LString("ROCCCTripleVote") || 
      sym->get_name() == LString("ROCCCDoubleVote") )
  {
    LoadVariableExpression* errorVariableExpression = 
      dynamic_cast<LoadVariableExpression*>(c->get_argument(0)) ;
    assert(errorVariableExpression != NULL) ;
    VariableSymbol* currentError = errorVariableExpression->get_source() ;
    assert(currentError != NULL) ;
    if (InList(currentError))
    {
      // Create a new variable
      VariableSymbol* errorDupe = 
	create_variable_symbol(theEnv,
			       currentError->get_type(),
			       TempName(LString("UnrolledRedundantError"))) ;
      errorDupe->append_annote(create_brick_annote(theEnv, "DebugRegister")) ;
      procDef->get_symbol_table()->append_symbol_table_object(errorDupe) ;
      usedVariables.push_back(errorDupe) ;
      errorVariableExpression->set_source(errorDupe) ;
    }
    else
    {
      usedVariables.push_back(currentError) ;
    }
  }

}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:38,代码来源:redundant_cleanup.cpp

示例13: assert

void ScalarReplacementPass2::ProcessLoad(LoadExpression* e) 
{
  assert(e != NULL) ;
  Expression* innerExp = e->get_source_address() ;
  ArrayReferenceExpression* innerRef = 
    dynamic_cast<ArrayReferenceExpression*>(innerExp) ;
  if (innerRef == NULL)
  {
    return ;
  }

  // Again, don't process lookup tables
  if (IsLookupTable(GetArrayVariable(innerRef)))
  {
    return ;
  }

  VariableSymbol* replacement = NULL ;
  list<std::pair<Expression*, VariableSymbol*> >::iterator identIter = 
    Identified.begin() ;
  while (identIter != Identified.end())
  {
    if (EquivalentExpressions((*identIter).first, innerRef))
    {
      replacement = (*identIter).second ;
      break ;
    }
    ++identIter ;
  }
  assert(replacement != NULL) ;

  LoadVariableExpression* loadVar = 
    create_load_variable_expression(theEnv, 
				    replacement->get_type()->get_base_type(),
				    replacement) ;
  e->get_parent()->replace(e, loadVar) ;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:37,代码来源:scalar_replacement_pass2.cpp

示例14: CollectArrays

void TransformUnrolledArraysPass::TransformNDIntoNMinusOneD(int N)
{
  // Get all unique N-dimensional arrays
  CollectArrays(N) ;

  // For every array access that has a constant as one of its offsets,
  //  we have to create a new array

  list<VariableSymbol*> arraysToRemove ;
  list<EquivalentReferences*>::iterator refIter = currentReferences.begin() ;
  while (refIter != currentReferences.end())
  {
    VariableSymbol* originalSymbol = GetArrayVariable((*refIter)->original) ;
    // Lookup tables should not be transformed
    if (originalSymbol->lookup_annote_by_name("LUT") == NULL)
    {
      bool replaced = ReplaceNDReference(*refIter) ;
      if (replaced)
      {
	if (!InList(arraysToRemove, originalSymbol))
	{
	  arraysToRemove.push_back(originalSymbol) ;
	}
      }
    }
    ++refIter ;
  }

  // Remove all of the arrays that need to be removed
  list<VariableSymbol*>::iterator arrayIter = arraysToRemove.begin() ;
  while (arrayIter != arraysToRemove.end())
  {
    procDef->get_symbol_table()->remove_symbol_table_object(*arrayIter) ;
    ++arrayIter ;
  }

}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:37,代码来源:transform_unrolled_arrays.cpp

示例15: get_object_factory

void One2MultiArrayExpressionPass::do_procedure_definition(ProcedureDefinition* proc_def)
{
    bool kill_all = !(_preserve_one_dim->is_set());
    // access all array type declarations and create corresponding multi array types
    SuifEnv* suif_env = proc_def->get_suif_env();
    TypeBuilder* tb = (TypeBuilder*)suif_env->
        get_object_factory(TypeBuilder::get_class_name());
    (void) tb; // avoid warning
#ifdef CONVERT_TYPES
    for (Iter<ArrayType> at_iter = object_iterator<ArrayType>(proc_def);
        at_iter.is_valid();at_iter.next())
    {
        MultiDimArrayType* multi_type = 
            converter->array_type2multi_array_type(&at_iter.current());
	}
#endif //CONVERT_TYPES

    // collect tops of array access chains into this list
    list<ArrayReferenceExpression*> ref_exprs;
    for (Iter<ArrayReferenceExpression> are_iter =
		object_iterator<ArrayReferenceExpression>(proc_def);
         are_iter.is_valid(); are_iter.next())
    {
        // itself an array and parent is *not* an array
        ArrayReferenceExpression* are = &are_iter.current();
        if((kill_all || is_kind_of<ArrayReferenceExpression>(are->get_base_array_address())) &&
           !is_kind_of<ArrayReferenceExpression>(are->get_parent()))
        {
            //printf("%p \t", are);are->print_to_default();
            ref_exprs.push_back(are);
	    }
    }

    // for top all expressions, convert them to multi-exprs
    for(list<ArrayReferenceExpression*>::iterator ref_iter = ref_exprs.begin();
        ref_iter != ref_exprs.end(); ref_iter++)
    {
        ArrayReferenceExpression* top_array = *ref_iter;
        converter->convert_array_expr2multi_array_expr(top_array);
    }
#ifdef CONVERT_TYPES    
    // replace the types of all array variables
    for (Iter<VariableSymbol> iter = object_iterator<VariableSymbol>(proc_def);
            iter.is_valid();iter.next())
    {
        VariableSymbol* vd = &iter.current();
        DataType *vtype = tb->unqualify_data_type(vd->get_type());
        if (is_kind_of<ArrayType>(vtype)) {
            MultiDimArrayType* multi_type =
                    converter->array_type2multi_array_type(to<ArrayType>(vtype));
            vd->replace(vd->get_type(), tb->get_qualified_type(multi_type));
        }
    }

    // remove the remaining one-dim array types
    converter->remove_all_one_dim_array_types();
#endif //CONVERT_TYPES
    // make sure no traces of single-dim arrays are left
    if(kill_all){
        {for(Iter<ArrayReferenceExpression> iter =
            object_iterator<ArrayReferenceExpression>(proc_def);
            iter.is_valid(); iter.next())
            {
                // ArrayReferenceExpression* are = &iter.current();
                //are->print_to_default(); printf("at %p \t", are);
                suif_assert_message(false, ("ARE not eliminated"));
            }
        }
#ifdef CONVERT_TYPES
        {for(Iter<ArrayType> iter =
            object_iterator<ArrayType>(proc_def);
            iter.is_valid(); iter.next())
        {suif_assert_message(false, ("ArrayType not eliminated"));}}
#endif
    }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:76,代码来源:array_dismantlers.cpp


注:本文中的VariableSymbol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。