summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-03 01:20:37 +0000
committerPaul Phillips <paulp@improving.org>2011-08-03 01:20:37 +0000
commit39ebbf6743d0b861096051286d7608ffc9736888 (patch)
tree4b538f0302203ac2eb4466cec98dfc0eaa5bca8e /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent254ad276ca07c20a2782678a234c75ea1e7b9e83 (diff)
downloadscala-39ebbf6743d0b861096051286d7608ffc9736888.tar.gz
scala-39ebbf6743d0b861096051286d7608ffc9736888.tar.bz2
scala-39ebbf6743d0b861096051286d7608ffc9736888.zip
Finished up some backend cleanups I'd had lying...
Finished up some backend cleanups I'd had lying around since scala days. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 6b9f7bf79e..68651fc1c9 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -42,31 +42,33 @@ trait ParsersCommon extends ScannersCommon {
* will be called, so a parse error will still result. If the grouping is
* optional, in.token should be tested before calling these methods.
*/
- def inParens[T](body: => T): T = {
+ @inline final def inParens[T](body: => T): T = {
accept(LPAREN)
val ret = body
accept(RPAREN)
ret
}
- def inParensOrError[T](body: => T, alt: T): T =
+ @inline final def inParensOrError[T](body: => T, alt: T): T =
if (in.token == LPAREN) inParens(body)
else { accept(LPAREN) ; alt }
- def inParensOrUnit[T](body: => Tree): Tree = inParensOrError(body, Literal(Constant()))
- def inParensOrNil[T](body: => List[T]): List[T] = inParensOrError(body, Nil)
- def inBraces[T](body: => T): T = {
+ @inline final def inParensOrUnit[T](body: => Tree): Tree = inParensOrError(body, Literal(Constant()))
+ @inline final def inParensOrNil[T](body: => List[T]): List[T] = inParensOrError(body, Nil)
+
+ @inline final def inBraces[T](body: => T): T = {
accept(LBRACE)
val ret = body
accept(RBRACE)
ret
}
- def inBracesOrError[T](body: => T, alt: T): T =
+ @inline final def inBracesOrError[T](body: => T, alt: T): T =
if (in.token == LBRACE) inBraces(body)
else { accept(LBRACE) ; alt }
- def inBracesOrNil[T](body: => List[T]): List[T] = inBracesOrError(body, Nil)
- def inBracesOrUnit[T](body: => Tree): Tree = inBracesOrError(body, Literal(Constant()))
- def inBrackets[T](body: => T): T = {
+ @inline final def inBracesOrNil[T](body: => List[T]): List[T] = inBracesOrError(body, Nil)
+ @inline final def inBracesOrUnit[T](body: => Tree): Tree = inBracesOrError(body, Literal(Constant()))
+
+ @inline final def inBrackets[T](body: => T): T = {
accept(LBRACKET)
val ret = body
accept(RBRACKET)
@@ -75,7 +77,7 @@ trait ParsersCommon extends ScannersCommon {
/** Creates an actual Parens node (only used during parsing.)
*/
- def makeParens(body: => List[Tree]): Parens =
+ @inline final def makeParens(body: => List[Tree]): Parens =
Parens(inParens(if (in.token == RPAREN) Nil else body))
}
}
@@ -206,13 +208,11 @@ self =>
}
private var smartParsing = false
- private def withSmartParsing[T](body: => T): T = {
+ @inline private def withSmartParsing[T](body: => T): T = {
val saved = smartParsing
- try {
- smartParsing = true
- body
- }
- finally smartParsing = saved // false
+ smartParsing = true
+ try body
+ finally smartParsing = saved
}
val syntaxErrors = new ListBuffer[(Int, String)]
@@ -275,7 +275,7 @@ self =>
/** The types of the context bounds of type parameters of the surrounding class
*/
private var classContextBounds: List[Tree] = Nil
- private def savingClassContextBounds[T](op: => T): T = {
+ @inline private def savingClassContextBounds[T](op: => T): T = {
val saved = classContextBounds
try op
finally classContextBounds = saved
@@ -462,12 +462,10 @@ self =>
var assumedClosingParens = collection.mutable.Map(RPAREN -> 0, RBRACKET -> 0, RBRACE -> 0)
private var inFunReturnType = false
- private def fromWithinReturnType[T](body: => T): T = {
+ @inline private def fromWithinReturnType[T](body: => T): T = {
val saved = inFunReturnType
- try {
- inFunReturnType = true
- body
- }
+ inFunReturnType = true
+ try body
finally inFunReturnType = saved
}
@@ -719,7 +717,7 @@ self =>
}
/** {{{ part { `sep` part } }}},or if sepFirst is true, {{{ { `sep` part } }}}. */
- def tokenSeparated[T](separator: Int, sepFirst: Boolean, part: => T): List[T] = {
+ final def tokenSeparated[T](separator: Int, sepFirst: Boolean, part: => T): List[T] = {
val ts = new ListBuffer[T]
if (!sepFirst)
ts += part
@@ -730,9 +728,9 @@ self =>
}
ts.toList
}
- def commaSeparated[T](part: => T): List[T] = tokenSeparated(COMMA, false, part)
- def caseSeparated[T](part: => T): List[T] = tokenSeparated(CASE, true, part)
- def readAnnots[T](part: => T): List[T] = tokenSeparated(AT, true, part)
+ @inline final def commaSeparated[T](part: => T): List[T] = tokenSeparated(COMMA, false, part)
+ @inline final def caseSeparated[T](part: => T): List[T] = tokenSeparated(CASE, true, part)
+ @inline final def readAnnots[T](part: => T): List[T] = tokenSeparated(AT, true, part)
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */