コード例 #1
0
ファイル: type.c プロジェクト: manasdas17/nvc
const char *type_pp_minify(type_t t, minify_fn_t fn)
{
   assert(t != NULL);

   switch (type_kind(t)) {
   case T_FUNC:
   case T_PROC:
      {
         char *buf = get_fmt_buf(256);
         static_printf_begin(buf, 256);

         const char *fname = (*fn)(istr(type_ident(t)));

         static_printf(buf, "%s(", fname);
         const int nparams = type_params(t);
         for (int i = 0; i < nparams; i++)
            static_printf(buf, "%s%s",
                          (i == 0 ? "" : ", "),
                          (*fn)(istr(type_ident(type_param(t, i)))));
         static_printf(buf, ")");
         if (type_kind(t) == T_FUNC)
            static_printf(buf, " return %s",
                          (*fn)(istr(type_ident(type_result(t)))));

         return buf;
      }

   default:
      return (*fn)(istr(type_ident(t)));
   }
}
コード例 #2
0
ファイル: common.c プロジェクト: gr8linux/nvc
const char *package_signal_path_name(ident_t i)
{
   const char *str = istr(i);
   char *buf = get_fmt_buf(strlen(str) + 3);
   char *p = buf;

   *p++ = ':';
   while (*str != '\0') {
      if (*str == '.') {
         *p++ = ':';
         str++;
      }
      else {
         *p++ = tolower((int)*str);
         str++;
      }
   }
   *p = '\0';

   return buf;
}
コード例 #3
0
ファイル: common.c プロジェクト: gr8linux/nvc
const char *fmt_time(uint64_t t)
{
   static const int BUF_SZ = 64;
   return fmt_time_r(get_fmt_buf(BUF_SZ), BUF_SZ, t);
}