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
949f28fb
Commit
949f28fb
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Print functions/unapply objects with paths, fix printing with braces
parent
d6ea932c
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/purescala/PrettyPrinter.scala
+16
-12
16 additions, 12 deletions
src/main/scala/leon/purescala/PrettyPrinter.scala
src/main/scala/leon/purescala/PrinterHelpers.scala
+2
-1
2 additions, 1 deletion
src/main/scala/leon/purescala/PrinterHelpers.scala
with
18 additions
and
13 deletions
src/main/scala/leon/purescala/PrettyPrinter.scala
+
16
−
12
View file @
949f28fb
...
@@ -53,11 +53,10 @@ class PrettyPrinter(opts: PrinterOptions,
...
@@ -53,11 +53,10 @@ class PrettyPrinter(opts: PrinterOptions,
def
pp
(
tree
:
Tree
)(
implicit
ctx
:
PrinterContext
)
:
Unit
=
{
def
pp
(
tree
:
Tree
)(
implicit
ctx
:
PrinterContext
)
:
Unit
=
{
if
(
requiresBraces
(
tree
,
ctx
.
parent
))
{
if
(
requiresBraces
(
tree
,
ctx
.
parent
)
&&
!
ctx
.
parent
.
contains
(
tree
))
{
val
ctx1
:
PrinterContext
=
ctx
.
copy
(
parents
=
Nil
)
p
"""|{
p
"""|{
| $tree
| $tree
|}"""
(
ctx1
)
|}"""
return
return
}
}
...
@@ -213,14 +212,14 @@ class PrettyPrinter(opts: PrinterOptions,
...
@@ -213,14 +212,14 @@ class PrettyPrinter(opts: PrinterOptions,
p
"($presentArgs)"
p
"($presentArgs)"
}
}
case
FunctionInvocation
(
tfd
,
args
)
=>
case
FunctionInvocation
(
TypedFunDef
(
fd
,
tps
)
,
args
)
=>
p
"${tfd.id}"
p
rintWithPath
(
fd
)
if
(
tfd
.
tps
.
nonEmpty
)
{
if
(
tps
.
nonEmpty
)
{
p
"[$
{tfd.
tps
}
]"
p
"[$tps]"
}
}
if
(
tfd
.
fd
.
isRealFunction
)
{
if
(
fd
.
isRealFunction
)
{
// The non-present arguments are synthetic function invocations
// The non-present arguments are synthetic function invocations
val
presentArgs
=
args
filter
{
val
presentArgs
=
args
filter
{
case
MethodInvocation
(
_
,
_
,
tfd
,
_
)
if
tfd
.
fd
.
isSynthetic
=>
false
case
MethodInvocation
(
_
,
_
,
tfd
,
_
)
if
tfd
.
fd
.
isSynthetic
=>
false
...
@@ -377,12 +376,17 @@ class PrettyPrinter(opts: PrinterOptions,
...
@@ -377,12 +376,17 @@ class PrettyPrinter(opts: PrinterOptions,
ob
.
foreach
{
b
=>
p
"$b @ "
}
ob
.
foreach
{
b
=>
p
"$b @ "
}
// @mk: I admit this is pretty ugly
// @mk: I admit this is pretty ugly
val
id
=
for
{
(
for
{
p
<-
opgm
p
<-
opgm
mod
<-
p
.
modules
.
find
(
_
.
definedFunctions
contains
tfd
.
fd
)
mod
<-
p
.
modules
.
find
(
_
.
definedFunctions
contains
tfd
.
fd
)
}
yield
mod
.
id
}
yield
mod
)
match
{
case
Some
(
obj
)
=>
p
"${id.getOrElse("
<
unknown
object
>
")}(${nary(subps)})"
printWithPath
(
obj
)
case
None
=>
p
"<unkown object>"
}
p
"(${nary(subps)})"
case
LiteralPattern
(
ob
,
lit
)
=>
case
LiteralPattern
(
ob
,
lit
)
=>
ob
foreach
{
b
=>
p
"$b @ "
}
ob
foreach
{
b
=>
p
"$b @ "
}
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/purescala/PrinterHelpers.scala
+
2
−
1
View file @
949f28fb
...
@@ -54,7 +54,8 @@ object PrinterHelpers {
...
@@ -54,7 +54,8 @@ object PrinterHelpers {
nary
(
ts
).
print
(
nctx
)
nary
(
ts
).
print
(
nctx
)
case
t
:
Tree
=>
case
t
:
Tree
=>
val
parents
=
if
(
nctx
.
current
==
t
)
{
// Don't add same tree twice in parents
val
parents
=
if
(
nctx
.
parents
.
headOption
contains
nctx
.
current
)
{
nctx
.
parents
nctx
.
parents
}
else
{
}
else
{
nctx
.
current
::
nctx
.
parents
nctx
.
current
::
nctx
.
parents
...
...
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