edu.mit.csail.sdg.alloy4compiler.ast
Class ExprConstant

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.ExprConstant

public final class ExprConstant
extends Expr

Immutable; represents a constant in the AST.


Nested Class Summary
static class ExprConstant.Op
          This class contains all possible constant types.
 
Field Summary
static Expr EMPTYNESS
          The "emptyness" constant.
static Expr FALSE
          The "FALSE" boolean value.
static Expr IDEN
          The "iden" relation.
static Expr MAX
          The largest integer value allowed by the current bitwidth.
static Expr MIN
          The smallest integer value allowed by the current bitwidth.
static Expr NEXT
          The "next" relation relating each integer to its next larger integer.
 int num
          If this node is a number constant, then this field stores the number, else this field stores 0.
static Expr ONE
          The "1" integer.
 ExprConstant.Op op
          The type of constant.
 java.lang.String string
          If this node is a String constant, then this field stores the String, else this field stores "".
static Expr TRUE
          The "TRUE" boolean value.
static Expr ZERO
          The "0" integer.
 
Fields inherited from class edu.mit.csail.sdg.alloy4compiler.ast.Expr
ambiguous, closingBracket, errors, mult, pos, weight
 
Method Summary
 int getDepth()
          Returns the height of the abstract syntax tree starting from this node.
 java.lang.String getHTML()
          Returns the description (as HTML) to show for this node.
 java.util.List<? extends Browsable> getSubnodes()
          Returns a list of subnodes for this node.
 boolean isSame(Expr obj)
          Returns true if we can determine the two expressions are equivalent; may sometimes return false.
static Expr makeNUMBER(int n)
          Constructs the integer "n"
 int num()
          Return the number if this node is a number constant, otherwise return 0.
 Expr resolve(Type type, java.util.Collection<ErrorWarning> warns)
          Resolves this expression if ambiguous.
 Pos span()
          Returns a Pos object representing the entire span of this Expr and all its subexpressions.
 void toString(java.lang.StringBuilder out, int indent)
          Print a textual description of it and all subnodes to a StringBuilder, with the given level of indentation.
 
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, toString, 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

op

public final ExprConstant.Op op
The type of constant.


string

public final java.lang.String string
If this node is a String constant, then this field stores the String, else this field stores "".


num

public final int num
If this node is a number constant, then this field stores the number, else this field stores 0.


TRUE

public static final Expr TRUE
The "TRUE" boolean value.


FALSE

public static final Expr FALSE
The "FALSE" boolean value.


IDEN

public static final Expr IDEN
The "iden" relation.


MIN

public static final Expr MIN
The smallest integer value allowed by the current bitwidth.


MAX

public static final Expr MAX
The largest integer value allowed by the current bitwidth.


NEXT

public static final Expr NEXT
The "next" relation relating each integer to its next larger integer.


ZERO

public static final Expr ZERO
The "0" integer.


ONE

public static final Expr ONE
The "1" integer.


EMPTYNESS

public static final Expr EMPTYNESS
The "emptyness" constant.

Method Detail

num

public int num()
Return the number if this node is a number constant, otherwise return 0.


span

public Pos span()
Returns a Pos object representing the entire span of this Expr and all its subexpressions.

Overrides:
span in class Browsable

toString

public void toString(java.lang.StringBuilder out,
                     int indent)
Print a textual description of it and all subnodes to a StringBuilder, with the given level of indentation. (If indent<0, it will be printed in one line without line break)

Specified by:
toString in class Expr

isSame

public boolean isSame(Expr obj)
Returns true if we can determine the two expressions are equivalent; may sometimes return false.

Overrides:
isSame in class Expr

makeNUMBER

public static Expr makeNUMBER(int n)
Constructs the integer "n"


resolve

public Expr resolve(Type type,
                    java.util.Collection<ErrorWarning> warns)
Resolves this expression if ambiguous. (And if t.size()>0, it represents the set of tuples whose presence/absence is relevent to the parent expression) (Note: it's possible for t to be EMPTY, or even ambiguous!)

On success: the return value will be well-typed and unambiguous

On failure: the return value's "errors" list will be nonempty

If we detect any type warnings, we will add the type warnings to the "warnings" collection.

Specified by:
resolve in class Expr
warns - - the list that will receive any warning we generate; can be null if we wish to ignore warnings

getDepth

public int getDepth()
Returns the height of the abstract syntax tree starting from this node.

Specified by:
getDepth in class Expr

getHTML

public java.lang.String getHTML()
Returns the description (as HTML) to show for this node.

Specified by:
getHTML in class Browsable

getSubnodes

public java.util.List<? extends Browsable> getSubnodes()
Returns a list of subnodes for this node.

Specified by:
getSubnodes in class Browsable