4 * This structure contains the stack effect of a word: number of stack
5 * element consumed on input, and number of stack element produced on
12 * Get number of stack elements consumed on input; this is -1 if
13 * the stack effect is not known.
22 * Get number of stack elements produced on output; this is -1 if
23 * either the stack effect is not known, or if the word never
26 internal int DataOut {
33 * Tell whether the stack effect is known.
35 internal bool IsKnown {
42 * Tell whether the stack effect is known and the word never exits.
44 internal bool NoExit {
46 return din >= 0 && dout < 0;
52 internal SType(int din, int dout)
65 * Special value for the unknown stack effect.
67 internal static SType UNKNOWN = new SType(-1, -1);
70 * Constant for the "blank stack effect".
72 internal static SType BLANK = new SType(0, 0);
74 public static bool operator ==(SType s1, SType s2)
76 return s1.din == s2.din && s1.dout == s2.dout;
79 public static bool operator !=(SType s1, SType s2)
81 return s1.din != s2.din || s1.dout != s2.dout;
84 public override bool Equals(Object obj)
86 return (obj is SType) && ((SType)obj == this);
89 public override int GetHashCode()
91 return din * 31 + dout * 17;
94 public override string ToString()
99 return string.Format("in:{0},noexit", din);
101 return string.Format("in:{0},out:{1}", din, dout);
106 * Test whether this stack effect is a sub-effect of the provided
107 * stack effect s. Stack effect s1 is a sub-effect of stack-effect
108 * s2 if any of the following holds:
109 * -- s1 and s2 are known, s1.din <= s2.din and s1 does not exit.
110 * -- s1 and s2 are known, s1.din <= s2.din, s1 and s2 exit,
111 * and s1.din - s1.dout == s2.din - s2.dout.
113 internal bool IsSubOf(SType s)
115 if (!IsKnown || !s.IsKnown) {
127 return (din - dout) == (s.din - s.dout);