-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I created too huge patterns to be matched against. Those crashed the compiler. This change optimizes the pattern (and the runtime const) of huge constants (numbers and characters) and other terms, whose representation is very large (int-lists and char-lists/strings).
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
macros/src/main/scala/me/rexim/morganey/meta/UnapplyConst.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.rexim.morganey.meta | ||
|
||
import me.rexim.morganey.ast.LambdaTerm | ||
|
||
/** | ||
* Helper class to match a constant in the quotation at runtime | ||
*/ | ||
class UnapplyConst[T](n: T)(implicit morganeyValue: Unliftable[T]) { | ||
|
||
def unapply(term: LambdaTerm): Boolean = term match { | ||
case morganeyValue(m) => n == m | ||
case _ => false | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters