01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.logic.op.oclop;
12:
13: import de.uka.ilkd.key.logic.Name;
14: import de.uka.ilkd.key.logic.Term;
15: import de.uka.ilkd.key.logic.op.TermSymbol;
16: import de.uka.ilkd.key.logic.sort.Sort;
17: import de.uka.ilkd.key.logic.sort.oclsort.OclSort;
18:
19: /**
20: * Represents an empty OCL Sequence.
21: * All OCL collections are built using two list-like
22: * constructors, empty<T>() and insert<T>(elem, collection),
23: * where <T> is either Set, Bag, or Sequence.
24: */
25: public class OclEmptySequence extends TermSymbol {
26:
27: public OclEmptySequence() {
28: super (new Name("$empty_sequence"), OclSort.SEQUENCE_OF_OCLANY);
29: }
30:
31: /** @return arity of the Function as int */
32: public int arity() {
33: return 0;
34: }
35:
36: /*
37: * checks if the given term is syntactically valid at its top
38: * level assumed the top level operator were this, i.e. if the
39: * direct subterms can be subterms of a term with this top level
40: * operator, the method returns true. Furthermore, it is checked
41: * that no variables are bound for none of the subterms.
42: * @param the Term to be checked.
43: * @return true iff the given term has
44: * subterms that are suitable for this function.
45: */
46: public boolean validTopLevel(Term term) {
47: if (term.arity() != arity()) {
48: return false;
49: }
50:
51: return true;
52: }
53:
54: public Sort sort(Term[] subTerm) {
55: return OclSort.SEQUENCE_OF_OCLGENERIC;
56: }
57:
58: public String toString() {
59: return (name() + ":" + OclSort.SEQUENCE_OF_OCLANY);
60: }
61:
62: public String proofToString() {
63: String s = OclSort.SEQUENCE_OF_OCLANY + " " + name();
64: s += "(";
65: s += ");\n";
66: return s;
67: }
68: }
|