Exemple #1
0
        public virtual void visitChild(ATerm child)         // throws  VisitFailure
        {
            if (table != null)
            {
                int abbrev;
                if (table.Contains(child))
                {
                    abbrev = (int)table[child];
                    emitAbbrev(abbrev);
                    return;
                }
            }

            int start = position;

            if (child.getType() == ATermType.LIST)
            {
                stream.Write('[');
                position++;
            }
            visit(child);
            if (child.getType() == ATermType.LIST)
            {
                stream.Write(']');
                position++;
            }

            ATermList annos = child.getAnnotations();

            if (!annos.isEmpty())
            {
                stream.Write('{');
                position++;
                visit(annos);
                stream.Write('}');
                position++;
            }

            if (table != null)
            {
                int length = position - start;
                if (length > PureFactory.abbrevSize(next_abbrev))
                {
                    int key = next_abbrev++;                     // Or should this be ++next_abbrev?? (merijn)
                    table.Add(key, child);
                }
            }
        }
Exemple #2
0
        public virtual void storeNextTerm(ATerm t, int size)
        {
            if (table == null)
            {
                return;
            }

            if (size <= PureFactory.abbrevSize(nr_terms))
            {
                return;
            }

            if (nr_terms == table.Length)
            {
                ATerm[] new_table = new ATerm[table.Length + TABLE_INCREMENT];
                Array.Copy(table, 0, new_table, 0, table.Length);
                table = new_table;
            }

            table[nr_terms++] = t;
        }