Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
e180d028
Commit
e180d028
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Comments
parent
ee1361f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/purescala/Expressions.scala
+13
-6
13 additions, 6 deletions
src/main/scala/leon/purescala/Expressions.scala
with
13 additions
and
6 deletions
src/main/scala/leon/purescala/Expressions.scala
+
13
−
6
View file @
e180d028
...
@@ -328,9 +328,13 @@ object Expressions {
...
@@ -328,9 +328,13 @@ object Expressions {
lazy
val
optionType
=
unapplyFun
.
returnType
.
asInstanceOf
[
AbstractClassType
]
lazy
val
optionType
=
unapplyFun
.
returnType
.
asInstanceOf
[
AbstractClassType
]
lazy
val
Seq
(
noneType
,
someType
)
=
optionType
.
knownCCDescendants
.
sortBy
(
_
.
fields
.
size
)
lazy
val
Seq
(
noneType
,
someType
)
=
optionType
.
knownCCDescendants
.
sortBy
(
_
.
fields
.
size
)
lazy
val
someValue
=
someType
.
classDef
.
fields
.
head
lazy
val
someValue
=
someType
.
classDef
.
fields
.
head
// Pattern match unapply(scrut)
// In case of None, return noneCase.
/** Construct a pattern matching against unapply(scrut) (as an if-expression)
// In case of Some(v), return someCase(v).
*
* @param scrut The scrutinee of the pattern matching
* @param noneCase The expression that will happen if unapply(scrut) is None
* @param someCase How unapply(scrut).get will be handled in case it exists
*/
def
patternMatch
(
scrut
:
Expr
,
noneCase
:
Expr
,
someCase
:
Expr
=>
Expr
)
:
Expr
=
{
def
patternMatch
(
scrut
:
Expr
,
noneCase
:
Expr
,
someCase
:
Expr
=>
Expr
)
:
Expr
=
{
// We use this hand-coded if-then-else because we don't want to generate
// We use this hand-coded if-then-else because we don't want to generate
// match exhaustiveness checks in the program
// match exhaustiveness checks in the program
...
@@ -345,14 +349,17 @@ object Expressions {
...
@@ -345,14 +349,17 @@ object Expressions {
)
)
)
)
}
}
// Inlined .get method
/** Inlined .get method */
def
get
(
scrut
:
Expr
)
=
patternMatch
(
def
get
(
scrut
:
Expr
)
=
patternMatch
(
scrut
,
scrut
,
Error
(
optionType
.
tps
.
head
,
"None.get"
),
Error
(
optionType
.
tps
.
head
,
"None.get"
),
e
=>
e
e
=>
e
)
)
// Selects Some.v field without type-checking.
// Use in a context where scrut.isDefined returns true.
/** Selects Some.v field without type-checking.
* Use in a context where scrut.isDefined returns true.
*/
def
getUnsafe
(
scrut
:
Expr
)
=
CaseClassSelector
(
def
getUnsafe
(
scrut
:
Expr
)
=
CaseClassSelector
(
someType
,
someType
,
FunctionInvocation
(
unapplyFun
,
Seq
(
scrut
)),
FunctionInvocation
(
unapplyFun
,
Seq
(
scrut
)),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment