#include "removeNamedParameters.h"
#include "expr.h"
#include "stmt.h"

void RemoveNamedParameters::postProcessExpr(Expr* expr) {
  if (NamedExpr* named_expr = dynamic_cast<NamedExpr*>(expr)) {
    named_expr->replace(named_expr->actual->copy());
  }

  if (VarInitExpr* var_init = dynamic_cast<VarInitExpr*>(expr)) {
    if (dynamic_cast<ArrayType*>(var_init->symbol->type) ||
        dynamic_cast<DomainType*>(var_init->symbol->type)) {
      // No Default Initialization for Arrays/Domains
      var_init->parentStmt->replace(new NoOpStmt());
    } else {
      if (var_init->symbol->type->defaultVal) {
        var_init->replace(var_init->symbol->type->defaultVal->copy());
      } else {
        var_init->replace(new FnCall(new Variable(var_init->symbol->type->defaultConstructor), NULL));
      }
    }
  }
}

#include "removeNamedParameters.h"
#include "expr.h"
#include "stmt.h"

void RemoveNamedParameters::postProcessExpr(Expr* expr) {
  if (NamedExpr* named_expr = dynamic_cast<NamedExpr*>(expr)) {
    named_expr->replace(named_expr->actual->copy());
  }

  if (VarInitExpr* var_init = dynamic_cast<VarInitExpr*>(expr)) {
    if (dynamic_cast<ArrayType*>(var_init->symbol->type) ||
        dynamic_cast<DomainType*>(var_init->symbol->type)) {
      // No Default Initialization for Arrays/Domains
      var_init->parentStmt->replace(new NoOpStmt());
    } else {
      if (var_init->symbol->type->defaultVal) {
        var_init->replace(var_init->symbol->type->defaultVal->copy());
      } else {
        assert(var_init->symbol->type->defaultConstructor);
        var_init->replace(new FnCall(new Variable(var_init->symbol->type->defaultConstructor), NULL));
      }
    }
  }
}

Insert an assert to catch a bad VarInit variable type.
Insert an assert to catch a bad VarInit variable type.


git-svn-id: 88467cb1fb04b8a755be7e1ee1026be4190196ef@2638 3a8e244f-b0f2-452b-bcba-4c88e055c3ca
