Package apigen.gen

Examples of apigen.gen.TypeConverter


  private String buildPlaceholderSubstitution(ATerm pattern) {
    ATermAppl hole = (ATermAppl) ((ATermPlaceholder) pattern)
        .getPlaceholder();
    String name = StringConversions.makeIdentifier(hole.getName());
    String type = hole.getArgument(0).toString();
    TypeConverter converter = new TypeConverter(
        new CTypeConversions(prefix));

    return "(ATerm) " + converter.makeBuiltinToATermConversion(type, name);
  }
View Full Code Here


  private StringBuffer genPlaceholderComparison(ATerm type,
      StringBuffer termName, int i, boolean genDeclaration) {
    StringBuffer result = new StringBuffer();
    StringBuffer argName = new StringBuffer(termName);
    TypeConverter converter = new TypeConverter(
        new CTypeConversions(prefix));

    if (type.getType() == ATerm.APPL) {
      ATermAppl arg0 = (ATermAppl) ((ATermAppl) type).getArgument(0);
      /* Check for use of predefined types... */

      if (genDeclaration && converter.isReserved(arg0.getName())) {
        argName = new StringBuffer(termName + "_arg" + i);
        result.append(genIndentation() + "ATerm " + argName
            + " = ATgetArgument(" + termName + ", " + i + ");"
            + newLine);
      }
View Full Code Here

    result.append(genCompareFunctCloseBracket(type, alt));
    println(result.toString());
  }

  private String genATermToBuiltin(String type, String arg) {
    TypeConverter converter = new TypeConverter(
        new CTypeConversions(prefix));

    return converter.makeATermToBuiltinConversion(type, arg);
  }
View Full Code Here

    return converter.makeATermToBuiltinConversion(type, arg);
  }

  private String genBuiltinToATerm(String type, String id) {
    TypeConverter converter = new TypeConverter(
        new CTypeConversions(prefix));

    return "((ATerm) " + converter.makeBuiltinToATermConversion(type, id)
        + ")";
  }
View Full Code Here

  private String buildTypeName(Type type) {
    return buildTypeName(type.getId());
  }

  private String buildTypeName(String typeId) {
    TypeConverter conv = new TypeConverter(new CTypeConversions(prefix));

    String name = conv.getType(typeId);

    if (conv.isReserved(typeId)) {
      return name;
    }
    return prefix + StringConversions.makeCapitalizedIdentifier(name);
  }
View Full Code Here

    }
  }

  private static void generateTypeClasses(ADT adt,
      JavaGenerationParameters params, GenerationObserver observer) {
    TypeConverter typeConverter = new TypeConverter(
        new JavaTypeConversions("factory"));
    Iterator<Type> typeIterator = adt.typeIterator();
    while (typeIterator.hasNext()) {
      Type type = typeIterator.next();

      if (type instanceof ListType) {
        if (type instanceof SeparatedListType) {
          run(new SeparatedListTypeGenerator(params,
              (SeparatedListType) type), observer);

        } else {
          run(new ListTypeGenerator(adt, params, (ListType) type),
              observer);
        }
      } else if (!typeConverter.isReserved(type.getId())) {
        run(new TypeGenerator(params, type), observer);
        generateAlternativeClasses(adt, params, type, observer);
      }
    }
  }
View Full Code Here

    genVisits(adt);
    println("}");
  }

  protected void genVisits(ADT adt) {
    TypeConverter typeConverter = new TypeConverter(
        new JavaTypeConversions("factory"));
    Iterator<Type> types = adt.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();

      if (type instanceof ListType) {
        genListVisit(type);
      } else if (!typeConverter.isReserved(type.getId())) {
        /* builtin childs are not visitable */
        Iterator<Alternative> alts = type.alternativeIterator();
        while (alts.hasNext()) {
          Alternative alt = alts.next();
          genVisit(type, alt);
View Full Code Here

  public String getVisitorName() {
    return module.getModulename().getName() + VisitorGenerator.CLASS_NAME;
  }

  protected void genVisits(ADT adt) {
    TypeConverter typeConverter = new TypeConverter(
        new JavaTypeConversions("factory"));
    Iterator<Type> types = adt.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();
      Iterator<Alternative> alts = type.alternativeIterator();

      if (type instanceof ListType) {
        genListVisit(type);
      } else if (!typeConverter.isReserved(type.getId())) {
        /* builtin childs are not visitable */
        genTypeVisit(type);
        while (alts.hasNext()) {
          Alternative alt = alts.next();
          genVisit(type, alt);
View Full Code Here

  public String getVisitorName() {
    return module.getModulename().getName() + VisitorGenerator.CLASS_NAME;
  }

  protected void genVisits(ADT adt) {
    TypeConverter typeConverter = new TypeConverter(
        new JavaTypeConversions("factory"));
    Iterator<Type> types = adt.typeIterator();
    while (types.hasNext()) {
      Type type = types.next();
      Iterator<Alternative> alts = type.alternativeIterator();

      if (type instanceof ListType) {
        genListVisit(type);
      } else if (!typeConverter.isReserved(type.getId())) {
        /* builtin childs are not visitable */
        while (alts.hasNext()) {
          Alternative alt = alts.next();
          genVisit(type, alt);
        }
View Full Code Here

TOP

Related Classes of apigen.gen.TypeConverter

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.