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
dc01ccda
Commit
dc01ccda
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Specify ids with per-name counters
parent
7f9a3874
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/Common.scala
+13
-19
13 additions, 19 deletions
src/main/scala/leon/purescala/Common.scala
with
13 additions
and
19 deletions
src/main/scala/leon/purescala/Common.scala
+
13
−
19
View file @
dc01ccda
...
...
@@ -6,14 +6,14 @@ object Common {
import
TypeTrees.Typed
// the type is left blank (Untyped) for Identifiers that are not variables
class
Identifier
private
[
Common
](
val
name
:
String
,
val
id
:
Int
,
alwaysShowUniqueID
:
Boolean
=
false
)
extends
Typed
{
class
Identifier
private
[
Common
](
val
name
:
String
,
private
val
globalId
:
Int
,
val
id
:
Int
,
alwaysShowUniqueID
:
Boolean
=
false
)
extends
Typed
{
self
:
Serializable
=>
override
def
equals
(
other
:
Any
)
:
Boolean
=
{
if
(
other
==
null
||
!
other
.
isInstanceOf
[
Identifier
])
false
else
other
.
asInstanceOf
[
Identifier
].
i
d
==
this
.
i
d
other
.
asInstanceOf
[
Identifier
].
globalI
d
==
this
.
globalI
d
}
override
def
hashCode
:
Int
=
id
...
...
@@ -23,7 +23,7 @@ object Common {
// angle brackets: name + "\u3008" + id + "\u3009"
name
+
"["
+
id
+
"]"
}
else
if
(
alwaysShowUniqueID
)
{
name
+
id
name
+
(
if
(
id
>
0
)
id
else
""
)
}
else
{
name
}
...
...
@@ -39,28 +39,22 @@ object Common {
}
private
object
UniqueCounter
{
private
var
soFar
:
Int
=
-
1
private
var
globalId
=
-
1
private
var
nameIds
=
Map
[
String
,
Int
]().
withDefaultValue
(-
1
)
def
next
:
Int
=
{
soFar
=
soFar
+
1
soFar
def
next
(
name
:
String
)
:
Int
=
{
nameIds
+=
name
->
(
1
+
nameIds
(
name
))
nameIds
(
name
)
}
def
last
:
Int
=
{
soFar
def
nextGlobal
=
{
globalId
+=
1
globalId
}
}
object
FreshIdentifier
{
def
forceSkip
(
i
:
Int
)
:
Unit
=
{
while
(
UniqueCounter
.
last
<
i
)
{
UniqueCounter
.
next
}
}
def
last
:
Int
=
UniqueCounter
.
last
def
apply
(
name
:
String
,
alwaysShowUniqueID
:
Boolean
=
false
)
:
Identifier
=
new
Identifier
(
name
,
UniqueCounter
.
next
,
alwaysShowUniqueID
)
def
apply
(
name
:
String
,
alwaysShowUniqueID
:
Boolean
=
false
)
:
Identifier
=
new
Identifier
(
name
,
UniqueCounter
.
nextGlobal
,
UniqueCounter
.
next
(
name
),
alwaysShowUniqueID
)
}
trait
ScalacPositional
{
...
...
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