Пример #1
0
void
viewFlags(BaseAST* ast) {
  if (!viewFlagsShort && !viewFlagsName && !viewFlagsComment)
    viewFlagsName = true;
  if (Symbol* sym = toSymbol(ast)) {
    for (int flagNum = FLAG_FIRST; flagNum <= FLAG_LAST; flagNum++) {
      if (sym->flags[flagNum]) {
        if (viewFlagsName)
          printf("%s ", flagNames[flagNum]);
        if (viewFlagsPragma)
          printf("%s", flagPragma[flagNum] ? "ypr " : "npr ");
        if (viewFlagsShort)
          printf("\"%s\" ", flagShortNames[flagNum]);
        if (viewFlagsComment)
          printf("// %s",
                 *flagComments[flagNum] ? flagComments[flagNum] : "ncm");
        printf("\n");
      }
    }
    if (viewFlagsExtras) {
      if (VarSymbol* vs = toVarSymbol(sym)) {
        if (vs->immediate) {
          printf("immediate ");
          fprint_imm(stdout, *toVarSymbol(sym)->immediate, true);
          printf("\n");
        }
      } else if (ArgSymbol* as = toArgSymbol(sym)) {
        printf("%s arg\n", as->intentDescrString());
      } else if (toTypeSymbol(sym)) {
        printf("a TypeSymbol\n");
      } else if (FnSymbol* fs = toFnSymbol(sym)) {
        printf("fn %s(%d args) %s\n",
               fs->_this ? intentDescrString(fs->thisTag) : "",
               fs->numFormals(), retTagDescrString(fs->retTag));
      } else if (toEnumSymbol(sym)) {
        printf("an EnumSymbol\n");
      } else if (ModuleSymbol* ms = toModuleSymbol(sym)) {
        printf("module %s\n", modTagDescrString(ms->modTag));
      } else if (toLabelSymbol(sym)) {
        printf("a LabelSymbol\n");
      } else {
        printf("unknown symbol kind\n");
      }
    }
  } else {
    printf("[%d]: not a Symbol, has no flags\n", ast->id);
  }
}
Пример #2
0
static TFITag it2tfi(Expr* ref, IntentTag intent) {
  switch (intent) {
  case INTENT_IN:        return TFI_IN;
  case INTENT_CONST:     return TFI_CONST;
  case INTENT_CONST_IN:  return TFI_CONST_IN;
  case INTENT_REF:       return TFI_REF;
  case INTENT_CONST_REF: return TFI_CONST_REF;
  case INTENT_BLANK:     return TFI_DEFAULT;

  case INTENT_OUT:
  case INTENT_INOUT:
  case INTENT_PARAM:
  case INTENT_TYPE:
    USR_FATAL_CONT(ref, "%s is not supported in a 'with' clause",
                        intentDescrString(intent));
    return TFI_DEFAULT;
  }
  INT_ASSERT(false); // unexpected IntentTag; 'intent' contains garbage?
  return TFI_DEFAULT; // dummy
}