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
af112343
Commit
af112343
authored
9 years ago
by
Lars Hupel
Committed by
Etienne Kneuss
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
introduce 'ClassFlag's in analogy to 'FunctionFlag's
parent
97204e3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/frontends/scalac/CodeExtraction.scala
+2
-4
2 additions, 4 deletions
src/main/scala/leon/frontends/scalac/CodeExtraction.scala
src/main/scala/leon/purescala/Definitions.scala
+48
-34
48 additions, 34 deletions
src/main/scala/leon/purescala/Definitions.scala
with
50 additions
and
38 deletions
src/main/scala/leon/frontends/scalac/CodeExtraction.scala
+
2
−
4
View file @
af112343
...
@@ -511,14 +511,12 @@ trait CodeExtraction extends ASTExtractors {
...
@@ -511,14 +511,12 @@ trait CodeExtraction extends ASTExtractors {
classesToClasses
+=
sym
->
acd
classesToClasses
+=
sym
->
acd
parent
.
foreach
(
_
.
classDef
.
registerChild
(
acd
))
parent
.
foreach
(
_
.
classDef
.
registerChild
(
acd
))
acd
.
setAnnotations
(
annotationsOf
(
sym
))
acd
.
addFlags
(
annotationsOf
(
sym
).
map
{
case
(
name
,
args
)
=>
ClassFlag
.
fromName
(
name
,
args
)
}.
toSet
)
acd
}
else
{
}
else
{
val
ccd
=
CaseClassDef
(
id
,
tparams
,
parent
,
sym
.
isModuleClass
).
setPos
(
sym
.
pos
)
val
ccd
=
CaseClassDef
(
id
,
tparams
,
parent
,
sym
.
isModuleClass
).
setPos
(
sym
.
pos
)
classesToClasses
+=
sym
->
ccd
classesToClasses
+=
sym
->
ccd
parent
.
foreach
(
_
.
classDef
.
registerChild
(
ccd
))
parent
.
foreach
(
_
.
classDef
.
registerChild
(
ccd
))
ccd
.
setAnnotation
s
(
annotationsOf
(
sym
))
ccd
.
addFlag
s
(
annotationsOf
(
sym
)
.
map
{
case
(
name
,
args
)
=>
ClassFlag
.
fromName
(
name
,
args
)
}.
toSet
)
val
fields
=
args
.
map
{
case
(
fsym
,
t
)
=>
val
fields
=
args
.
map
{
case
(
fsym
,
t
)
=>
val
tpe
=
leonType
(
t
.
tpt
.
tpe
)(
defCtx
,
fsym
.
pos
)
val
tpe
=
leonType
(
t
.
tpt
.
tpe
)(
defCtx
,
fsym
.
pos
)
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/purescala/Definitions.scala
+
48
−
34
View file @
af112343
...
@@ -186,6 +186,40 @@ object Definitions {
...
@@ -186,6 +186,40 @@ object Definitions {
}
}
// A class that represents flags that annotate a FunDef with different attributes
sealed
trait
FunctionFlag
object
FunctionFlag
{
def
fromName
(
name
:
String
,
args
:
Seq
[
Option
[
Any
]])
:
FunctionFlag
=
name
match
{
case
"inline"
=>
IsInlined
case
_
=>
Annotation
(
name
,
args
)
}
}
// A class that represents flags that annotate a ClassDef with different attributes
sealed
trait
ClassFlag
object
ClassFlag
{
def
fromName
(
name
:
String
,
args
:
Seq
[
Option
[
Any
]])
:
ClassFlag
=
Annotation
(
name
,
args
)
}
// Whether this FunDef was originally a (lazy) field
case
class
IsField
(
isLazy
:
Boolean
)
extends
FunctionFlag
// Compiler annotations given in the source code as @annot
case
class
Annotation
(
annot
:
String
,
args
:
Seq
[
Option
[
Any
]])
extends
FunctionFlag
with
ClassFlag
// If this class was a method. owner is the original owner of the method
case
class
IsMethod
(
owner
:
ClassDef
)
extends
FunctionFlag
// If this function represents a loop that was there before XLangElimination
// Contains a copy of the original looping function
case
class
IsLoop
(
orig
:
FunDef
)
extends
FunctionFlag
// If extraction fails of the function's body fais, it is marked as abstract
case
object
IsAbstract
extends
FunctionFlag
// Currently, the only synthetic functions are those that calculate default values of parameters
case
object
IsSynthetic
extends
FunctionFlag
// Is inlined
case
object
IsInlined
extends
FunctionFlag
/** Useful because case classes and classes are somewhat unified in some
/** Useful because case classes and classes are somewhat unified in some
* patterns (of pattern-matching, that is) */
* patterns (of pattern-matching, that is) */
sealed
trait
ClassDef
extends
Definition
{
sealed
trait
ClassDef
extends
Definition
{
...
@@ -224,13 +258,19 @@ object Definitions {
...
@@ -224,13 +258,19 @@ object Definitions {
def
methods
=
_methods
def
methods
=
_methods
private
var
_
annotations
:
Map
[
String
,
Seq
[
Option
[
Any
]]]
=
Map
.
empty
private
var
_
flags
:
Set
[
ClassFlag
]
=
Set
()
def
setAnnotations
(
annotations
:
Map
[
String
,
Seq
[
Option
[
Any
]]])
{
def
addFlags
(
flags
:
Set
[
ClassFlag
])
:
this.
type
=
{
_annotations
=
annotations
this
.
_flags
++=
flags
this
}
}
def
annotations
=
_annotations
def
addFlag
(
flag
:
ClassFlag
)
:
this.
type
=
addFlags
(
Set
(
flag
))
def
flags
=
_flags
def
annotations
:
Set
[
String
]
=
extAnnotations
.
keySet
def
extAnnotations
:
Map
[
String
,
Seq
[
Option
[
Any
]]]
=
flags
.
collect
{
case
Annotation
(
s
,
args
)
=>
s
->
args
}.
toMap
lazy
val
ancestors
:
Seq
[
ClassDef
]
=
parent
.
toSeq
flatMap
{
p
=>
p
.
classDef
+:
p
.
classDef
.
ancestors
}
lazy
val
ancestors
:
Seq
[
ClassDef
]
=
parent
.
toSeq
flatMap
{
p
=>
p
.
classDef
+:
p
.
classDef
.
ancestors
}
...
@@ -314,32 +354,6 @@ object Definitions {
...
@@ -314,32 +354,6 @@ object Definitions {
def
typed
:
CaseClassType
=
typed
(
tparams
.
map
(
_
.
tp
))
def
typed
:
CaseClassType
=
typed
(
tparams
.
map
(
_
.
tp
))
}
}
// A class that represents flags that annotate a FunDef with different attributes
sealed
abstract
class
FunctionFlag
object
FunctionFlag
{
def
fromName
(
name
:
String
,
args
:
Seq
[
Option
[
Any
]])
:
FunctionFlag
=
name
match
{
case
"inline"
=>
IsInlined
case
_
=>
Annotation
(
name
,
args
)
}
}
// Whether this FunDef was originally a (lazy) field
case
class
IsField
(
isLazy
:
Boolean
)
extends
FunctionFlag
// Compiler annotations given in the source code as @annot
case
class
Annotation
(
annot
:
String
,
args
:
Seq
[
Option
[
Any
]])
extends
FunctionFlag
// If this class was a method. owner is the original owner of the method
case
class
IsMethod
(
owner
:
ClassDef
)
extends
FunctionFlag
// If this function represents a loop that was there before XLangElimination
// Contains a copy of the original looping function
case
class
IsLoop
(
orig
:
FunDef
)
extends
FunctionFlag
// If extraction fails of the function's body fais, it is marked as abstract
case
object
IsAbstract
extends
FunctionFlag
// Currently, the only synthetic functions are those that calculate default values of parameters
case
object
IsSynthetic
extends
FunctionFlag
// Is inlined
case
object
IsInlined
extends
FunctionFlag
/** Function/method definition.
/** Function/method definition.
*
*
* This class represents methods or fields of objects or classes. By "fields" we mean
* This class represents methods or fields of objects or classes. By "fields" we mean
...
@@ -408,19 +422,19 @@ object Definitions {
...
@@ -408,19 +422,19 @@ object Definitions {
/* Flags */
/* Flags */
private
[
this
]
var
flags
_
:
Set
[
FunctionFlag
]
=
Set
()
private
[
this
]
var
_
flags
:
Set
[
FunctionFlag
]
=
Set
()
def
addFlags
(
flags
:
Set
[
FunctionFlag
])
:
FunDef
=
{
def
addFlags
(
flags
:
Set
[
FunctionFlag
])
:
FunDef
=
{
this
.
flags
_
++=
flags
this
.
_
flags
++=
flags
this
this
}
}
def
addFlag
(
flag
:
FunctionFlag
)
:
FunDef
=
addFlags
(
Set
(
flag
))
def
addFlag
(
flag
:
FunctionFlag
)
:
FunDef
=
addFlags
(
Set
(
flag
))
def
flags
=
flags
_
def
flags
=
_
flags
def
annotations
:
Set
[
String
]
=
extAnnotations
.
keySet
def
annotations
:
Set
[
String
]
=
extAnnotations
.
keySet
def
extAnnotations
:
Map
[
String
,
Seq
[
Option
[
Any
]]]
=
flags
_
.
collect
{
case
Annotation
(
s
,
args
)
=>
s
->
args
}.
toMap
def
extAnnotations
:
Map
[
String
,
Seq
[
Option
[
Any
]]]
=
flags
.
collect
{
case
Annotation
(
s
,
args
)
=>
s
->
args
}.
toMap
def
canBeLazyField
=
flags
.
contains
(
IsField
(
true
))
&&
params
.
isEmpty
&&
tparams
.
isEmpty
def
canBeLazyField
=
flags
.
contains
(
IsField
(
true
))
&&
params
.
isEmpty
&&
tparams
.
isEmpty
def
canBeStrictField
=
flags
.
contains
(
IsField
(
false
))
&&
params
.
isEmpty
&&
tparams
.
isEmpty
def
canBeStrictField
=
flags
.
contains
(
IsField
(
false
))
&&
params
.
isEmpty
&&
tparams
.
isEmpty
def
canBeField
=
canBeLazyField
||
canBeStrictField
def
canBeField
=
canBeLazyField
||
canBeStrictField
...
...
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