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
959719aa
Commit
959719aa
authored
13 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
add support for array in argument list
parent
4f050d7a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/ArrayTransformation.scala
+44
-5
44 additions, 5 deletions
src/main/scala/leon/ArrayTransformation.scala
testcases/regression/valid/Array4.scala
+7
-0
7 additions, 0 deletions
testcases/regression/valid/Array4.scala
with
51 additions
and
5 deletions
src/main/scala/leon/ArrayTransformation.scala
+
44
−
5
View file @
959719aa
...
...
@@ -12,15 +12,54 @@ object ArrayTransformation extends Pass {
def
apply
(
pgm
:
Program
)
:
Program
=
{
val
allFuns
=
pgm
.
definedFunctions
allFuns
.
foreach
(
fd
=>
fd
.
body
.
map
(
body
=>
{
val
newBody
=
transform
(
body
)
fd
.
body
=
Some
(
newBody
)
}))
pgm
val
newFuns
:
Seq
[
Definition
]
=
allFuns
.
map
(
fd
=>
{
if
(
fd
.
hasImplementation
)
{
val
body
=
fd
.
body
.
get
id2id
=
Map
()
val
args
=
fd
.
args
val
newFd
=
if
(
args
.
exists
(
vd
=>
containsArrayType
(
vd
.
tpe
)))
{
println
(
"args has array"
)
val
newArgs
=
args
.
map
(
vd
=>
{
val
freshId
=
FreshIdentifier
(
vd
.
id
.
name
).
setType
(
TupleType
(
Seq
(
vd
.
tpe
,
Int32Type
)))
id2id
+=
(
vd
.
id
->
freshId
)
val
newTpe
=
transform
(
vd
.
tpe
)
VarDecl
(
freshId
,
newTpe
)
})
val
freshFunName
=
FreshIdentifier
(
fd
.
id
.
name
)
val
freshFunDef
=
new
FunDef
(
freshFunName
,
fd
.
returnType
,
newArgs
)
freshFunDef
.
fromLoop
=
fd
.
fromLoop
freshFunDef
.
parent
=
fd
.
parent
freshFunDef
.
precondition
=
fd
.
precondition
freshFunDef
.
postcondition
=
fd
.
postcondition
freshFunDef
.
addAnnotation
(
fd
.
annotations
.
toSeq
:_
*
)
freshFunDef
}
else
fd
val
newBody
=
transform
(
body
)
newFd
.
body
=
Some
(
newBody
)
newFd
}
else
fd
})
val
Program
(
id
,
ObjectDef
(
objId
,
_
,
invariants
))
=
pgm
val
allClasses
:
Seq
[
Definition
]
=
pgm
.
definedClasses
Program
(
id
,
ObjectDef
(
objId
,
allClasses
++
newFuns
,
invariants
))
}
private
var
id2id
:
Map
[
Identifier
,
Identifier
]
=
Map
()
private
def
transform
(
tpe
:
TypeTree
)
:
TypeTree
=
tpe
match
{
case
ArrayType
(
base
)
=>
TupleType
(
Seq
(
ArrayType
(
transform
(
base
)),
Int32Type
))
case
TupleType
(
tpes
)
=>
TupleType
(
tpes
.
map
(
transform
))
case
t
=>
t
}
private
def
containsArrayType
(
tpe
:
TypeTree
)
:
Boolean
=
tpe
match
{
case
ArrayType
(
base
)
=>
true
case
TupleType
(
tpes
)
=>
tpes
.
exists
(
containsArrayType
)
case
t
=>
false
}
private
def
transform
(
expr
:
Expr
)
:
Expr
=
expr
match
{
case
fill
@ArrayFill
(
length
,
default
)
=>
{
var
rLength
=
transform
(
length
)
...
...
This diff is collapsed.
Click to expand it.
testcases/regression/valid/Array4.scala
0 → 100644
+
7
−
0
View file @
959719aa
object
Array4
{
def
foo
(
a
:
Array
[
Int
])
:
Int
=
{
a
(
2
)
}
ensuring
(
_
==
3
)
}
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