summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-05-11 13:02:53 -0700
committerPaul Phillips <paulp@improving.org>2013-05-11 13:02:53 -0700
commit751daa9b3825543bd04eaa4eab6438f8410f6040 (patch)
tree46d83d8adc9a5916c65a9ae1ca6ab173a2a80d6a /src/reflect
parent1850ddf380789e364813111282af5ff11e65b52c (diff)
downloadscala-751daa9b3825543bd04eaa4eab6438f8410f6040.tar.gz
scala-751daa9b3825543bd04eaa4eab6438f8410f6040.tar.bz2
scala-751daa9b3825543bd04eaa4eab6438f8410f6040.zip
Started eliminating modes.
Consolidating the scattered typer state in Context, where it's relatively easy to keep an eye on, rather than threaded throughout the typer in sneaky/sticky bitmasks. The general pattern will be what was once an explicitly passed around bit in Mode becomes an implicitly propagated-as-appropriate bit in Context. In this commit: ALTmode becomes context mode "PatternAlternative" STARmode becomes context mode "StarPatterns" SUPERCONSTRmode becomes context mode "SuperInit"
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Mode.scala68
1 files changed, 26 insertions, 42 deletions
diff --git a/src/reflect/scala/reflect/internal/Mode.scala b/src/reflect/scala/reflect/internal/Mode.scala
index 05fd5c3337..0cfd802b01 100644
--- a/src/reflect/scala/reflect/internal/Mode.scala
+++ b/src/reflect/scala/reflect/internal/Mode.scala
@@ -48,11 +48,6 @@ object Mode {
*/
final val TAPPmode: Mode = 0x080
- /** SUPERCONSTRmode is set for the super
- * in a superclass constructor call super.<init>.
- */
- final val SUPERCONSTRmode: Mode = 0x100
-
/** SNDTRYmode indicates that an application is typed for the 2nd time.
* In that case functions may no longer be coerced with implicit views.
*/
@@ -62,15 +57,6 @@ object Mode {
*/
final val LHSmode: Mode = 0x400
- /** STARmode is set when star patterns are allowed.
- * (This was formerly called REGPATmode.)
- */
- final val STARmode: Mode = 0x1000
-
- /** ALTmode is set when we are under a pattern alternative.
- */
- final val ALTmode: Mode = 0x2000
-
/** HKmode is set when we are typing a higher-kinded type.
* adapt should then check kind-arity based on the prototypical type's
* kind arity. Type arguments should not be inferred.
@@ -94,7 +80,7 @@ object Mode {
*/
final val RETmode: Mode = 0x20000
- final private val StickyModes: Mode = EXPRmode | PATTERNmode | TYPEmode | ALTmode
+ final private val StickyModes: Mode = EXPRmode | PATTERNmode | TYPEmode
/** Translates a mask of mode flags into something readable.
*/
@@ -107,12 +93,12 @@ object Mode {
(1 << 5) -> "POLYmode",
(1 << 6) -> "QUALmode",
(1 << 7) -> "TAPPmode",
- (1 << 8) -> "SUPERCONSTRmode",
+ (1 << 8) -> "<NO SUCH MODE>", // formerly SUPERCONSTRmode
(1 << 9) -> "SNDTRYmode",
(1 << 10) -> "LHSmode",
- (1 << 11) -> "<DOES NOT EXIST mode>",
- (1 << 12) -> "STARmode",
- (1 << 13) -> "ALTmode",
+ (1 << 11) -> "<NO SUCH MODE>",
+ (1 << 12) -> "<NO SUCH MODE>", // formerly STARmode
+ (1 << 13) -> "<NO SUCH MODE>", // formerly ALTmode
(1 << 14) -> "HKmode",
(1 << 15) -> "BYVALmode",
(1 << 16) -> "TYPEPATmode"
@@ -131,40 +117,38 @@ final class Mode private (val bits: Int) extends AnyVal {
if (inAny(PATTERNmode | TYPEPATmode)) TYPEmode | TYPEPATmode
else TYPEmode
- def inAll(required: Mode) = (this & required) == required
- def inAny(required: Mode) = (this & required) != NOmode
- def inNone(prohibited: Mode) = (this & prohibited) == NOmode
- def inAllButNone(required: Mode, prohibited: Mode) = inAll(required) && inNone(prohibited)
- def in(allOf: Mode = NOmode, noneOf: Mode = NOmode) = inAll(allOf) && inNone(noneOf)
+ def inAll(required: Mode) = (this & required) == required
+ def inAny(required: Mode) = (this & required) != NOmode
+ def inNone(prohibited: Mode) = (this & prohibited) == NOmode
- def inSccMode = inAll(SCCmode)
- def inQualMode = inAll(QUALmode)
- def inHKMode = inAll(HKmode)
+ /** True if this mode matches every mode in the 'all' Mode,
+ * and no modes in the 'none' Mode.
+ */
+ def in(all: Mode = NOmode, none: Mode = NOmode) = inAll(all) && inNone(none)
+
+ def inByValMode = inAll(BYVALmode)
+ def inExprMode = inAll(EXPRmode)
def inFunMode = inAll(FUNmode)
- def inPolyMode = inAll(POLYmode)
+ def inHKMode = inAll(HKmode)
+ def inLhsMode = inAll(LHSmode)
def inPatternMode = inAll(PATTERNmode)
- def inExprMode = inAll(EXPRmode)
- def inByValMode = inAll(BYVALmode)
+ def inPolyMode = inAll(POLYmode)
+ def inQualMode = inAll(QUALmode)
def inRetMode = inAll(RETmode)
- def inLhsMode = inAll(LHSmode)
+ def inSccMode = inAll(SCCmode)
def inTappMode = inAll(TAPPmode)
- def inAltMode = inAll(ALTmode)
def inTypeMode = inAll(TYPEmode)
def typingTypeByValue = inAll(TYPEmode | BYVALmode)
def typingExprByValue = inAll(EXPRmode | BYVALmode)
def typingExprFun = inAll(EXPRmode | FUNmode)
- def typingExprNotValue = inAllButNone(EXPRmode, BYVALmode)
- def typingExprNotLhs = inAllButNone(EXPRmode, LHSmode)
- def typingExprNotFun = inAllButNone(EXPRmode, FUNmode)
- def typingExprNotFunNotLhs = inAllButNone(EXPRmode, FUNmode | LHSmode)
- def typingMonoExprByValue = inAllButNone(EXPRmode | BYVALmode, POLYmode)
-
- def typingPatternNotFun = inAllButNone(PATTERNmode, FUNmode)
def typingPatternFun = inAll(PATTERNmode | FUNmode)
-
- def inExprModeOr(others: Mode) = inAny(EXPRmode | others)
- def inExprModeButNot(prohibited: Mode) = inAllButNone(EXPRmode, prohibited)
+ def typingExprNotValue = in(all = EXPRmode, none = BYVALmode)
+ def typingExprNotLhs = in(all = EXPRmode, none = LHSmode)
+ def typingExprNotFun = in(all = EXPRmode, none = FUNmode)
+ def typingExprNotFunNotLhs = in(all = EXPRmode, none = FUNmode | LHSmode)
+ def typingMonoExprByValue = in(all = EXPRmode | BYVALmode, none = POLYmode)
+ def typingPatternNotFun = in(all = PATTERNmode, none = FUNmode)
override def toString =
if (bits == 0) "NOmode"