Package apigen.adt

Examples of apigen.adt.Type


  private void genProtectFunctions(ADT adt) {
    bothPrintFoldOpen("(un)protect functions");
    Iterator<Type> types = adt.typeIterator();

    while (types.hasNext()) {
      Type type = types.next();
      String id = StringConversions.makeIdentifier(type.getId());
      String typeName = buildTypeName(type.getId());

      genProtect(id, typeName);
      genUnprotect(id, typeName);
    }
View Full Code Here


  private void genListsApi(ADT adt) {
    Iterator<Type> types = adt.typeIterator();

    bothPrintFoldOpen("list functions");
    while (types.hasNext()) {
      Type type = types.next();

      if (type instanceof ListType) {
        if (type instanceof SeparatedListType) {
          genSeparatedListApi((SeparatedListType) type);
        } else {
View Full Code Here

  private void genTypes(ADT api) {
    Iterator<Type> types = api.typeIterator();
    bothPrintFoldOpen("typedefs");
    while (types.hasNext()) {
      Type type = types.next();
      String id = buildTypeName(type);
      hprintln("typedef struct _" + id + " *" + id + ";");
      println("typedef struct ATerm _" + id + ";");
    }
    bothPrintFoldClose();
View Full Code Here

  private void genTermConversions(ADT api) {
    Iterator<Type> types = api.typeIterator();
    bothPrintFoldOpen("term conversion functions");
    while (types.hasNext()) {
      Type type = types.next();
      String type_id = StringConversions.makeIdentifier(type.getId());
      String type_name = buildTypeName(type);

      genFromTerm(type_id, type_name);
      genToTerm(type_id, type_name);
    }
View Full Code Here

  private void genIsEquals(ADT api) {
    Iterator<Type> types = api.typeIterator();
    bothPrintFoldOpen("equality functions");

    while (types.hasNext()) {
      Type type = types.next();
      String type_id = StringConversions.makeIdentifier(type.getId());
      String type_name = buildTypeName(type);

      String returnType = "ATbool";
      String funName = prefix + "isEqual" + type_id;
      String funArgs = "(" + type_name + " arg0, " + type_name + " arg1)";
View Full Code Here

  private void genConstructors(ADT api) throws GenerationException {
    Iterator<Type> types = api.typeIterator();
    bothPrintFoldOpen("constructors");

    while (types.hasNext()) {
      Type type = types.next();
      String type_name = buildTypeName(type);

      Iterator<Alternative> alts = type.alternativeIterator();
      while (alts.hasNext()) {
        Alternative alt = alts.next();
        String decl = buildConstructorDecl(type, alt);
        hprintln(decl + ";");

        printDocHead("Constructs a " + alt.getId() + " of type "
            + type_name, "Like all ATerm types, " + type_name
            + "s are maximally shared.");
        printDocArgs("arg", "a child of the new " + alt.getId(), type,
            alt);
        printDocReturn("A pointer to a " + alt.getId()
            + ", either newly constructed or shared");
        printDocTail();
        printFoldOpen(decl.toString());
        println(decl + " {");

        genDealWithSeparatedListException(type, StringConversions
            .makeCapitalizedIdentifier(type.getId()), alt);
        genAlternativeConstructorBody(type_name, alt);

        println("}");
        printFoldClose();
      }
View Full Code Here

  }

  private void genAccessors(ADT api) throws GenerationException {
    Iterator<Type> types = api.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();
      String type_name = buildTypeName(type);
      bothPrintFoldOpen(type_name + " accessors");

      genTypeIsValid(type);
      genIsAlts(type);
View Full Code Here

  private void genSortVisitors(ADT api) {
    Iterator<Type> types = api.typeIterator();
    bothPrintFoldOpen("sort visitors");

    while (types.hasNext()) {
      Type type = types.next();
      String type_id = StringConversions.makeIdentifier(type.getId());
      String type_name = buildTypeName(type);

      StringBuffer decl_buf = new StringBuffer();
      String visitor_name = prefix + "visit" + type_id;
      decl_buf.append(type_name);
      decl_buf.append(" ");
      decl_buf.append(visitor_name);
      decl_buf.append("(");
      decl_buf.append(type_name);
      decl_buf.append(" arg");
      Iterator<Field> fields = type.fieldIterator();
      while (fields.hasNext()) {
        Field field = fields.next();
        if (!field.getType().equals(type.getId())) {
          decl_buf.append(", ");
          decl_buf.append(genAcceptor(field));
        }
      }
      decl_buf.append(")");
      String decl = decl_buf.toString();

      hprintln(decl + ";");

      printDocHead("Apply functions to the children of a " + type_name,
          "");
      printDocReturn("A new "
          + type_name
          + " with new children where the argument functions might have applied");
      printDocTail();
      printFoldOpen(decl);
      println(decl + " {");

      Iterator<Alternative> alts = type.alternativeIterator();
      while (alts.hasNext()) {
        Alternative alt = alts.next();
        genSortVisitorAltImpl(type, alt);
      }
View Full Code Here

  }

  private void genDefaultTypePredicates() {
    Iterator<Type> types = adt.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();
      genDefaultTypePredicate(type);
    }
  }
View Full Code Here

  }

  private void genDefaultTypePredicates() {
    Iterator<Type> types = adt.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();
      genDefaultTypePredicate(type);
    }
  }
View Full Code Here

TOP

Related Classes of apigen.adt.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.