예제 #1
0
파일: main.cpp 프로젝트: CCJY/coliru
void pretty_print(const type_declaration_class klass)
    {
        // Get the info struct
        class_declaration info = klass.type;
        // Print final, if we are
        if(info.is_final)
        {
            std::cout << "final ";
        }
        // Print abstract, if we are
        if(info.is_abstract)
        {
            std::cout << "abstract ";
        }
        // Print the 'class' keyword, the class name, and the class we extend
        // (in non inheriting classes this will be java.lang.Object).
        std::cout << "class " << info.name.identifier_string << " extends " << name_to_string(info.extends);
        // If we're implementing anything
        if(info.implements.empty() == false)
        {
            // Then write out the 'implements' keyword, and a comma seperated
            // list of implements 
            std::cout << " implements ";
            std::cout << concat(info.implements, name_to_string, ", ");
        }
        // Newline because we like allman style
        std::cout << std::endl;
        // Start brace, and newline
        std::cout << "{" << std::endl;
        // Print all members
        unpack_list(info.members, pretty_print);
        // End brace, and newline
        std::cout << "}" << std::endl;
    }
예제 #2
0
Type* create_typed_unsized_list_type(Type* elementType)
{
    Type* type = create_type();
    list_t::setup_type(type);
    set_type(&type->parameter, elementType);
    std::string name = std::string("List<") + name_to_string(elementType->name) + ">";
    type->name = name_from_string(name.c_str());
    return type;
}
예제 #3
0
void write_type_name(CppWriter& writer, Type* type)
{
    std::string typeName = name_to_string(type->name);

    if (typeName == "number")
        writer.write("float");
    else if (typeName == "string")
        writer.write("std::string");
    else
        writer.write(typeName);
}
예제 #4
0
/** \todo Fix memory leak @ node_to_string:186 */
char *
node_to_string(Wht *W)
{
  char *buf, *tmp;
  size_t nn, i, j, len;
  
  buf = name_to_string(W);

  if (W->children == NULL)
    return buf;

  len = strlen(buf) + 3; /* [ .. ] \0 */
  buf = realloc(buf, sizeof(char) * len);

  strncat(buf,"[",1);

  nn = W->children->nn;

  /* Iterate over children WHTs, stored anti lexigraphically  */
  for (i = 0; i < nn; i++) {
    j    = nn - i - 1;
    tmp  = node_to_string(W->children->Ws[j]);
    len += strlen(tmp) + 2; /* , \0*/
    buf  = realloc(buf, sizeof(char) * len);

    strncat(buf, tmp, strlen(tmp) + 1);

    /* Don't add comma for last child */
    if (i < nn - 1)
      strncat(buf, ",", 1);

    i_free(tmp);
  }

  strncat(buf,"]",1);

  return buf;
}
예제 #5
0
void perf_stats_dump()
{
    printf("perf_stats_dump:\n");
    for (int i=c_firstStatIndex; i < name_LastStatIndex-1; i++)
        printf("  %s = %llu\n", name_to_string(i), PERF_STATS[i - c_firstStatIndex]);
}
예제 #6
0
std::string get_cpp_type_name(Type* type)
{
    return name_to_string(type->name);
}