compiler/passes/normalize.cpp
// If the AST node defines a symbol, then return that symbol.
// Otherwise return NULL. Also check for self-defs.
If the AST node defines a symbol, then return that symbol.
Otherwise return NULL. Also check for self-defs.
If the AST node defines a symbol then return that symbol . Otherwise return NULL . Also check for self - defs .
static Symbol* theDefinedSymbol(BaseAST* ast) {
  Symbol* retval = NULL;
   The caller performs a post-order traversal and so we find the
   symExpr before we see the callExpr.
   In particular, given a move(symexpr1,symexpr2), if we consider
   the move itself as defining the symbol, symexpr1 will raise
   the "use before defined" error.
  if (SymExpr* se = toSymExpr(ast)) {
    if (CallExpr* call = toCallExpr(se->parentExpr)) {
      if (call->isPrimitive(PRIM_MOVE)      ||
          call->isPrimitive(PRIM_ASSIGN)    ||
          call->isPrimitive(PRIM_INIT_VAR) ) {
        if (call->get(1) == se) {
          retval = se->symbol();
          checkSelfDef(call, se->symbol());
        }
      }
       Allow for init() for a task-private variable, which occurs in
       ShadowVarSymbol::initBlock(), which does not include its DefExpr.
      else if (ShadowVarSymbol* svar = toShadowVarSymbol(se->symbol())) {
        if (svar->isTaskPrivate()  &&
            call->isNamed("init")  &&
             the first argument is gMethodToken
            call->get(2) == se)
          retval = svar;
      }
    }
  } else if (DefExpr* def = toDefExpr(ast)) {
    Symbol* sym = def->sym;
     All arg symbols and loop induction variables are defined.
     All shadow variables are defined.
    if (isArgSymbol(sym) ||
        isShadowVarSymbol(sym) ||
        sym->hasFlag(FLAG_INDEX_VAR)
    ) {
      retval = sym;
    } else if (VarSymbol* var = toVarSymbol(sym)) {
       All type aliases are taken as defined.
      if (var->isType() == true) {
        retval = var;
      } else {
        Type* type = var->typeInfo();
         All variables of type 'void' are treated as defined.
        if (type == dtVoid) {
          retval = var;
         records with initializers are defined
        } else if (AggregateType* at = toAggregateType(type)) {
          if (isRecordWithInitializers(at) == true) {
            retval = var;
          }
        }
      }
    }
  }
  return retval;
}
static Symbol * theDefinedSymbol ( BaseAST * ast ) { Symbol * retval = NULL ; if ( SymExpr * se = toSymExpr ( ast ) ) { if ( CallExpr * call = toCallExpr ( se -> parentExpr ) ) { if ( call -> isPrimitive ( PRIM_MOVE ) || call -> isPrimitive ( PRIM_ASSIGN ) || call -> isPrimitive ( PRIM_INIT_VAR ) ) { if ( call -> get ( 1 ) == se ) { retval = se -> symbol ( ) ; checkSelfDef ( call , se -> symbol ( ) ) ; } } else if ( ShadowVarSymbol * svar = toShadowVarSymbol ( se -> symbol ( ) ) ) { if ( svar -> isTaskPrivate ( ) && call -> isNamed ( " " ) && call -> get ( 2 ) == se ) retval = svar ; } } } else if ( DefExpr * def = toDefExpr ( ast ) ) { Symbol * sym = def -> sym ; if ( isArgSymbol ( sym ) || isShadowVarSymbol ( sym ) || sym -> hasFlag ( FLAG_INDEX_VAR ) ) { retval = sym ; } else if ( VarSymbol * var = toVarSymbol ( sym ) ) { if ( var -> isType ( ) == true ) { retval = var ; } else { Type * type = var -> typeInfo ( ) ; if ( type == dtVoid ) { retval = var ; } else if ( AggregateType * at = toAggregateType ( type ) ) { if ( isRecordWithInitializers ( at ) == true ) { retval = var ; } } } } } return retval ; }
If the AST node defines a symbol, then return that symbol.
If the AST node defines a symbol then return that symbol .
// A symbol is "defined" if it is the LHS of a move, an assign, // or a variable initialization. // // The caller performs a post-order traversal and so we find the // symExpr before we see the callExpr. // In particular, given a move(symexpr1,symexpr2), if we consider // the move itself as defining the symbol, symexpr1 will raise // the "use before defined" error. // Allow for init() for a task-private variable, which occurs in // ShadowVarSymbol::initBlock(), which does not include its DefExpr. // the first argument is gMethodToken // All arg symbols and loop induction variables are defined. // All shadow variables are defined. // All type aliases are taken as defined. // All variables of type 'void' are treated as defined. // records with initializers are defined