Package aterm

Examples of aterm.ATermAppl


    } else {
      ATerm last = list.elementAt(length - 1);
      if (last.getType() == ATerm.PLACEHOLDER) {
        ATerm ph = ((ATermPlaceholder) last).getPlaceholder();
        if (ph.getType() == ATerm.LIST) {
          ATermAppl field = (ATermAppl) (((ATermList) ph).getFirst());
          result = "(ATermList)"
              + StringConversions.makeIdentifier(field.getName());
        }
      }
      if (result == null || result.length() == 0) {
        result = "ATmakeList1(" + genConstructorImpl(last) + ")";
      }
View Full Code Here


          + newLine);
      termName = argName;
    }

    if (pattern.getType() == ATerm.APPL) {
      ATermAppl appl = (ATermAppl) pattern;

      result.append(genIndentation() + "/* checking for: "
          + appl.getName() + " */" + newLine);
      result.append(genIndentation() + "if (ATgetType((ATerm)" + termName
          + ") == AT_APPL && ATgetAFun((ATermAppl)" + termName
          + ") == " + prefix + afunRegister.lookup(appl.getAFun())
          + ") " + genCompareFunctOpenBracket());
      for (int j = 0; j < appl.getArity(); j++) {
        result.append(genNestedComparison(appl.getArgument(j),
            termName, j, true));
      }
    } else if (pattern.getType() == ATerm.LIST) {
      ATermList list = (ATermList) pattern;

View Full Code Here

    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);
      }

      if (arg0.getName().equals("list")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_LIST" + ") "
            + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("int")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_INT" + ") "
            + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("real")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_REAL" + ") "
            + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("str")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_APPL "
            + "&& ATgetArity(ATgetAFun((ATermAppl)" + argName
            + ")) == 0 && ATisQuoted(ATgetAFun((ATermAppl)"
            + argName + ")) == ATtrue) "
            + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("term")) {
        result.append(genIndentation() + "if (" + argName
            + " != NULL) " + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("chars")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_LIST" + ") "
            + genCompareFunctOpenBracket());
      } else if (arg0.getName().equals("char")) {
        result.append(genIndentation() + "if (ATgetType((ATerm)"
            + argName + ") == " + "AT_INT" + ") "
            + genCompareFunctOpenBracket());
      }
    }
View Full Code Here

      }
      return containsPlaceholder(list.getFirst())
          || containsPlaceholder(list.getNext());
    }
    case ATerm.APPL: {
      ATermAppl appl = (ATermAppl) term;
      int arity = appl.getArity();
      for (int i = 0; i < arity; i++) {
        if (containsPlaceholder(appl.getArgument(i))) {
          return true;
        }
      }
      return false;
    }
View Full Code Here

  }

  protected ATerm buildMatchPattern(ATerm t) {
    switch (t.getType()) {
    case ATerm.APPL:
      ATermAppl appl = (ATermAppl) t;
      AFun fun = appl.getAFun();
      ATerm[] newargs = new ATerm[fun.getArity()];
      for (int i = 0; i < fun.getArity(); i++) {
        newargs[i] = buildMatchPattern(appl.getArgument(i));
      }
      return pattern.getFactory().makeAppl(fun, newargs);
    case ATerm.LIST:
      ATermList list = (ATermList) t;
      ATerm[] elems = new ATerm[list.getLength()];
View Full Code Here

        extractFields(alt.getPattern(), new Location(alt.getId()));
    }

    private void extractFields(ATerm t, Location loc) {
        AFun fun;
        ATermAppl appl;
        ATermList list;

        switch (t.getType()) {
            case ATerm.APPL :
                //{{{ Call 'extractFields' for every argument

                appl = (ATermAppl) t;
                fun = appl.getAFun();
                for (int i = 0; i < fun.getArity(); i++) {
                    Location newloc = (Location) loc.clone();
                    newloc.addStep(new Step(Step.ARG, i));
                    extractFields(appl.getArgument(i), newloc);
                }

                //}}}
                break;

            case ATerm.LIST :
                //{{{ Call 'extractFields' for every element

                list = (ATermList) t;
                for (int i = 0; !list.isEmpty(); i++) {
                    Location newloc = (Location) loc.clone();
                    newloc.addStep(new Step(Step.ELEM, i));
                    extractFields(list.getFirst(), newloc);
                    list = list.getNext();
                }

                //}}}
                break;

            case ATerm.PLACEHOLDER :
                //{{{ Add a new field based on this placeholder

                ATerm ph = ((ATermPlaceholder) t).getPlaceholder();

                if (ph.getType() == ATerm.LIST) {
                    list = (ATermList) ph;
                    appl = (ATermAppl) list.elementAt(0);
                    String fieldId = appl.getAFun().getName();
                    appl = (ATermAppl) appl.getArgument(0);
                    String fieldType = appl.getAFun().getName();
                    loc.makeTail();
                    addField(fieldId, fieldType, loc);
                } else if (ph.getType() == ATerm.APPL) {
                    appl = (ATermAppl) ph;
                    String fieldId = appl.getAFun().getName();
                    appl = (ATermAppl) appl.getArgument(0);
                    String fieldType = appl.getAFun().getName();
                    addField(fieldId, fieldType, loc);
                } else {
                    throw new RuntimeException("illegal field spec: " + t);
                }
View Full Code Here

      return;

    List<ATermAppl> types = x.getTypes( Node.MAX );
    int size = types.size();
    for( int j = 0; j < size; j++ ) {
      ATermAppl mc = types.get( j );

      applyGuessingRule( x, mc );

      if( strategy.getABox().isClosed() )
        return;
View Full Code Here

    }
    }

    private void applyGuessingRule(Individual x, ATermAppl mc) {
    // max(r, n) is in normalized form not(min(p, n + 1))
    ATermAppl max = (ATermAppl) mc.getArgument(0);

    Role r = strategy.getABox().getRole(max.getArgument(0));
    int n = ((ATermInt) max.getArgument(1)).getInt() - 1;
    ATermAppl c = (ATermAppl) max.getArgument(2);

    // obviously if r is a datatype role then there can be no r-predecessor
    // and we cannot apply the rule
    if (r.isDatatypeRole())
      return;
View Full Code Here

    public final void apply( Individual node ) {
        List<ATermAppl> types = node.getTypes( Node.ATOM );
        int size = types.size();
        for( int j = 0; j < size; j++ ) {
            ATermAppl c = types.get( j );

            if(!PelletOptions.MAINTAIN_COMPLETION_QUEUE && node.getDepends(c) == null)
        continue;

           
            if( ATermUtils.isSelf( c ) ) {
                ATermAppl pred = (ATermAppl) c.getArgument( 0 );
                Role role = strategy.getABox().getRole( pred );
                if( log.isLoggable( Level.FINE ) && !node.hasRSuccessor( role, node ) )
                    log.fine( "SELF: " + node + " " + role + " " + node.getDepends( c ) );
                strategy.addEdge( node, role, node, node.getDepends( c ) );
View Full Code Here

          return;
       
        List<ATermAppl> types = node.getTypes( Node.ATOM );
        int size = types.size();
        for( int j = node.applyNext[Node.ATOM]; j < size; j++ ) {
            ATermAppl c = types.get( j );

            if(!PelletOptions.MAINTAIN_COMPLETION_QUEUE && node.getDepends(c) == null)
        continue;
           
            applyUnfoldingRule( node, c );
View Full Code Here

TOP

Related Classes of aterm.ATermAppl

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.