@Override public ATerm make(final String trm) { return parse(trm); }
public void storeNextTerm(final ATerm t, final int size) { if (table == null) return; if (size <= PureFactory.abbrevSize(nr_terms)) return; if (nr_terms == table.length) { final ATerm[] new_table = new ATerm[table.length + TABLE_INCREMENT]; System.arraycopy(table, 0, new_table, 0, table.length); table = new_table; } table[nr_terms++] = t; }
@Override public FunAll all() { return build(new FunAll(this)); }
if (contains(object)) return term; final AFun fun = (AFun) importTerm(appl.getAFun()); newArguments[i] = importTerm(appl.getArgument(i)); result = makeAppl(fun, newArguments); break; case ATerm.LIST: final ATerm first = importTerm(list.getFirst()); final ATermList next = (ATermList) importTerm(list.getNext()); result = makeList(first, next); break; case ATerm.INT: final ATermInt integer = (ATermInt) term; result = makeInt(integer.getInt()); break; case ATerm.LONG: final ATermLong elongatedType = (ATermLong) term; result = makeLong(elongatedType.getLong()); break; case ATerm.REAL: final ATermReal real = (ATermReal) term;
@Before public void setUp() { _factory = new PureFactory(); }
@Override public ATermList getArguments() { ATermList result = getPureFactory().getEmpty(); for (int i = _args.length - 1; i >= 0; i--) result = result.insert(_args[i]); return result; }
@Override public ATerm make(final String pattern, final Object arg1) { final List<Object> args = new LinkedList<>(); args.add(arg1); return make(pattern, args); }
@Override public boolean isEqual(final ATerm term) { if (term instanceof ATermImpl) return this == term; return _factory.isDeepEqual(this, term); }
private static ATerm parseAbbrev(final ATermReader reader) throws IOException { ATerm result; int abbrev; int c = reader.read(); abbrev = 0; while (isBase64(c)) { abbrev *= 64; if (c >= 'A' && c <= 'Z') abbrev += c - 'A'; else if (c >= 'a' && c <= 'z') abbrev += c - 'a' + 26; else if (c >= '0' && c <= '9') abbrev += c - '0' + 52; else if (c == '+') abbrev += 62; else if (c == '/') abbrev += 63; else throw new OpenError("not a base-64 digit: " + c); c = reader.read(); } result = reader.getTerm(abbrev); return result; }
public final static void main(final String[] args) throws IOException { final Test2 pureSuite = new Test2(new PureFactory(), args[0]); pureSuite.testAll(); //Test2 nativeSuite = new Test2(new NativeFactory()); //nativeSuite.testAll(); }
@Override public ATermList getSlice(final int start, final int end) { int i; final int size = end - start; ATermList list = this; for (i = 0; i < start; i++) list = list.getNext(); final List<ATerm> buffer = new ArrayList<>(size); for (i = 0; i < size; i++) { buffer.add(list.getFirst()); list = list.getNext(); } ATermList result = getPureFactory().getEmpty(); for (--i; i >= 0; i--) result = result.insert(buffer.get(i)); return result; }
@Override public ATerm make(final String pattern, final Object arg1, final Object arg2) { final List<Object> args = new LinkedList<>(); args.add(arg1); args.add(arg2); return make(pattern, args); }
@Override public FunValue value() { return build(new FunValue(this)); }
public ATerm parsePattern(final String pattern) throws ParseError { return parse(pattern); }
@Before public void setUp() { _pureFactory = new PureFactory(); }
@Override public ATermList getPrefix() { if (isEmpty()) return this; ATermList cur = this; final List<ATerm> elems = new ArrayList<>(); while (true) { if (cur.getNext().isEmpty()) { cur = getPureFactory().getEmpty(); for (int i = elems.size() - 1; i >= 0; i--) cur = cur.insert(elems.get(i)); return cur; } elems.add(cur.getFirst()); cur = cur.getNext(); } }
@Override public ATerm make(final String pattern, final Object arg1, final Object arg2, final Object arg3) { final List<Object> args = new LinkedList<>(); args.add(arg1); args.add(arg2); args.add(arg3); return make(pattern, args); }
if (length > PureFactory.abbrevSize(next_abbrev))
@Override public FunSubClassOf subClassOf() { return build(new FunSubClassOf(this)); }