edu.mit.csail.sdg.alloy4compiler.ast
Class Sig.PrimSig

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4compiler.ast.Browsable
      extended by edu.mit.csail.sdg.alloy4compiler.ast.Expr
          extended by edu.mit.csail.sdg.alloy4compiler.ast.Sig
              extended by edu.mit.csail.sdg.alloy4compiler.ast.Sig.PrimSig
Enclosing class:
Sig

public static final class Sig.PrimSig
extends Sig

Mutable; reresents a non-subset signature.

Note: except for "children()", the return value of every method is always valid for all time; for example, given sigs A and B, and you call C=A.intersect(B), then the result C will always be the intersection of A and B even if the caller later constructs more sigs or subsigs or subsetsigs...


Nested Class Summary
 
Nested classes/interfaces inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Sig
Sig.Field, Sig.PrimSig, Sig.SubsetSig
 
Field Summary
 Sig.PrimSig parent
          If this is UNIV or NONE, then this field is null, else this field is the parent sig.
 
Fields inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Sig
attributes, builtin, decl, GHOST, isAbstract, isEnum, isLone, isMeta, isOne, isPrivate, isSome, isSubset, isSubsig, label, NONE, SEQIDX, SIGINT, STRING, UNIV
 
Fields inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Expr
ambiguous, closingBracket, errors, mult, pos, weight
 
Constructor Summary
Sig.PrimSig(java.lang.String label, Attr... attributes)
          Constructs a toplevel non-builtin sig.
Sig.PrimSig(java.lang.String label, Sig.PrimSig parent, Attr... attributes)
          Constructs a non-builtin sig.
 
Method Summary
 SafeList<Sig.PrimSig> children()
          Returns its immediate children sigs (not including NONE)
 java.lang.Iterable<Sig.PrimSig> descendents()
          Returns its subsigs and their subsigs and their subsigs, etc.
 Sig.PrimSig intersect(Sig.PrimSig that)
          Returns the intersection between this and that (and returns "none" if they do not intersect).
 boolean intersects(Sig.PrimSig that)
          Returns true iff the intersection between this and that is not "none".
 boolean isSameOrDescendentOf(Sig that)
          Returns true iff "this is equal or subtype of that"
 Sig.PrimSig leastParent(Sig.PrimSig that)
          Returns the most-specific-sig that contains this and that.
 
Methods inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Sig
addDefinedField, addFact, addField, addTrickyField, getDepth, getFacts, getFieldDecls, getFields, getHTML, getSubnodes, isSame, isTopLevel, resolve, span, toString, toString
 
Methods inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Expr
and, any_arrow_lone, any_arrow_one, any_arrow_some, cardinality, cast2int, cast2sigint, closure, comprehensionOver, deNOP, div, domain, equal, equals, findAllFunctions, forAll, forLone, forNo, forOne, forSome, gt, gte, hashCode, hasVar, iff, iminus, implies, in, intersect, iplus, isSeq_arrow_lone, ite, join, lone_arrow_any, lone_arrow_lone, lone_arrow_one, lone_arrow_some, lone, loneOf, loneOf, lt, lte, minus, mul, mult, no, not, one_arrow_any, one_arrow_lone, one_arrow_one, one_arrow_some, one, oneOf, oneOf, or, override, plus, pos, product, range, reflexiveClosure, rem, resolve_as_formula, resolve_as_int, resolve_as_set, setOf, setOf, sha, shl, shr, some_arrow_any, some_arrow_lone, some_arrow_one, some_arrow_some, some, someOf, someOf, sumOver, transpose, type, typecheck_as_formula, typecheck_as_int, typecheck_as_set
 
Methods inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Browsable
make, make, make, make, showAsTree
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

public final Sig.PrimSig parent
If this is UNIV or NONE, then this field is null, else this field is the parent sig.

Constructor Detail

Sig.PrimSig

public Sig.PrimSig(java.lang.String label,
                   Sig.PrimSig parent,
                   Attr... attributes)
            throws Err
Constructs a non-builtin sig.

Parameters:
label - - the name of this sig (it does not need to be unique)
parent - - the parent (must not be null, and must not be NONE)
attributes - - the list of optional attributes such as ABSTRACT, LONE, ONE, SOME, SUBSIG, PRIVATE, META, or ENUM
Throws:
ErrorSyntax - if the signature has two or more multiplicities
ErrorType - if you attempt to extend the builtin sigs NONE, SIGINT, SEQIDX, or STRING
Err

Sig.PrimSig

public Sig.PrimSig(java.lang.String label,
                   Attr... attributes)
            throws Err
Constructs a toplevel non-builtin sig.

Parameters:
label - - the name of this sig (it does not need to be unique)
attributes - - the list of optional attributes such as ABSTRACT, LONE, ONE, SOME, SUBSIG, PRIVATE, META, or ENUM
Throws:
ErrorSyntax - if the signature has two or more multiplicities
Err
Method Detail

children

public SafeList<Sig.PrimSig> children()
                               throws Err
Returns its immediate children sigs (not including NONE)

Note: if this==UNIV, then this method will throw an exception, since we don't keep track of UNIV's children

Throws:
Err

descendents

public java.lang.Iterable<Sig.PrimSig> descendents()
                                            throws Err
Returns its subsigs and their subsigs and their subsigs, etc.

Note: if this==UNIV, then this method will throw an exception, since we don't keep track of UNIV's children

Throws:
Err

isSameOrDescendentOf

public boolean isSameOrDescendentOf(Sig that)
Returns true iff "this is equal or subtype of that"

Specified by:
isSameOrDescendentOf in class Sig

intersect

public Sig.PrimSig intersect(Sig.PrimSig that)
Returns the intersection between this and that (and returns "none" if they do not intersect).


intersects

public boolean intersects(Sig.PrimSig that)
Returns true iff the intersection between this and that is not "none".


leastParent

public Sig.PrimSig leastParent(Sig.PrimSig that)
Returns the most-specific-sig that contains this and that. In particular, if this extends that, then return that.