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
d6837f0b
Commit
d6837f0b
authored
8 years ago
by
Mikaël Mayer
Committed by
Ravi
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reduced the AbstractEvaluator's overhead by simplifying some expressions in the pattern matching.
parent
6876a0df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/evaluators/AbstractEvaluator.scala
+18
-2
18 additions, 2 deletions
src/main/scala/leon/evaluators/AbstractEvaluator.scala
with
18 additions
and
2 deletions
src/main/scala/leon/evaluators/AbstractEvaluator.scala
+
18
−
2
View file @
d6837f0b
...
...
@@ -57,6 +57,8 @@ class AbstractEvaluator(ctx: LeonContext, prog: Program) extends ContextualEvalu
override
val
description
:
String
=
"Evaluates string programs but keeps the formula which generated the value"
override
val
name
:
String
=
"Abstract evaluator"
/** True if CaseClassSelector(...CaseClass(...)) have to be simplified. */
var
evaluateCaseClassSelector
=
true
protected
def
e
(
expr
:
Expr
)(
implicit
rctx
:
RC
,
gctx
:
GC
)
:
(
Expr
,
Expr
)
=
{
implicit
def
aToC
:
AbstractEvaluator.this.underlying.RC
=
DefaultRecContext
(
rctx
.
mappings
.
filter
{
case
(
k
,
v
)
=>
ExprOps
.
isValue
(
v
)
})
...
...
@@ -165,7 +167,13 @@ class AbstractEvaluator(ctx: LeonContext, prog: Program) extends ContextualEvalu
case
(
CaseClassPattern
(
ob
,
pct
,
subs
),
CaseClass
(
ct
,
args
))
=>
if
(
pct
==
ct
)
{
val
res
=
(
subs
zip
args
zip
ct
.
classDef
.
fieldsIds
).
map
{
case
((
s
,
a
),
id
)
=>
matchesPattern
(
s
,
a
,
CaseClassSelector
(
ct
,
exprFromScrut
,
id
))
case
((
s
,
a
),
id
)
=>
exprFromScrut
match
{
case
CaseClass
(
ct
,
args
)
if
evaluateCaseClassSelector
=>
matchesPattern
(
s
,
a
,
args
(
ct
.
classDef
.
selectorID2Index
(
id
)))
case
_
=>
matchesPattern
(
s
,
a
,
CaseClassSelector
(
ct
,
exprFromScrut
,
id
))
}
}
if
(
res
.
forall
(
_
.
isDefined
))
{
Some
(
obind
(
ob
,
expr
,
exprFromScrut
)
++
res
.
flatten
.
flatten
)
...
...
@@ -193,7 +201,15 @@ class AbstractEvaluator(ctx: LeonContext, prog: Program) extends ContextualEvalu
}
case
(
TuplePattern
(
ob
,
subs
),
Tuple
(
args
))
=>
if
(
subs
.
size
==
args
.
size
)
{
val
res
=
(
subs
zip
args
).
zipWithIndex
.
map
{
case
((
s
,
a
),
i
)
=>
matchesPattern
(
s
,
a
,
TupleSelect
(
exprFromScrut
,
i
+
1
))
}
val
res
=
(
subs
zip
args
).
zipWithIndex
.
map
{
case
((
s
,
a
),
i
)
=>
exprFromScrut
match
{
case
TupleSelect
(
Tuple
(
args
),
i
)
if
evaluateCaseClassSelector
=>
matchesPattern
(
s
,
a
,
args
(
i
-
1
))
case
_
=>
matchesPattern
(
s
,
a
,
TupleSelect
(
exprFromScrut
,
i
+
1
))
}
}
if
(
res
.
forall
(
_
.
isDefined
))
{
Some
(
obind
(
ob
,
expr
,
exprFromScrut
)
++
res
.
flatten
.
flatten
)
}
else
{
...
...
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