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
11a91e68
Commit
11a91e68
authored
10 years ago
by
Emmanouil (Manos) Koukoutos
Committed by
Etienne Kneuss
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Automatically add type annotations to type ensuring
parent
23469e1e
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/frontends/scalac/AddTypeAnnotations.scala
+52
-0
52 additions, 0 deletions
...main/scala/leon/frontends/scalac/AddTypeAnnotations.scala
src/main/scala/leon/frontends/scalac/ScalaCompiler.scala
+8
-0
8 additions, 0 deletions
src/main/scala/leon/frontends/scalac/ScalaCompiler.scala
with
60 additions
and
0 deletions
src/main/scala/leon/frontends/scalac/AddTypeAnnotations.scala
0 → 100644
+
52
−
0
View file @
11a91e68
/* Copyright 2009-2014 EPFL, Lausanne */
package
leon
package
frontends.scalac
import
scala.tools.nsc._
import
scala.tools.nsc.plugins._
trait
AddTypeAnnotations
extends
SubComponent
with
ASTExtractors
{
import
global._
import
global.definitions._
import
ExtractorHelpers._
val
phaseName
=
"addtypeannotations"
val
ctx
:
LeonContext
var
imports
:
Map
[
RefTree
,
List
[
Import
]]
=
Map
()
def
newPhase
(
prev
:
scala.tools.nsc.Phase
)
:
StdPhase
=
new
Phase
(
prev
)
class
Phase
(
prev
:
scala.tools.nsc.Phase
)
extends
StdPhase
(
prev
)
{
def
apply
(
unit
:
CompilationUnit
)
:
Unit
=
{
val
transformer
=
new
Transformer
{
override
def
transform
(
tree
:
Tree
)
:
Tree
=
tree
match
{
case
d
@DefDef
(
_
,
_
,
_
,
_
,
tpt
,
a
@Apply
(
s
@Select
(
bd
,
nameEns
@ExNamed
(
"ensuring"
)
),
f
)
)
=>
(
bd
,
tpt
.
symbol
)
match
{
case
(
Typed
(
_
,
_
),
_
)
|
(
_
,
null
)
=>
d
case
_
=>
d
.
copy
(
rhs
=
Apply
(
Select
(
Typed
(
bd
,
tpt
.
duplicate
.
setPos
(
bd
.
pos
.
focus
)).
setPos
(
bd
.
pos
),
nameEns
).
setPos
(
s
.
pos
),
f
).
setPos
(
a
.
pos
)
).
setPos
(
d
.
pos
)
}
case
other
=>
super
.
transform
(
other
)
}
}
unit
.
body
=
transformer
.
transform
(
unit
.
body
)
}
}
}
This diff is collapsed.
Click to expand it.
src/main/scala/leon/frontends/scalac/ScalaCompiler.scala
+
8
−
0
View file @
11a91e68
...
@@ -22,9 +22,17 @@ class ScalaCompiler(settings : NSCSettings, ctx: LeonContext) extends Global(set
...
@@ -22,9 +22,17 @@ class ScalaCompiler(settings : NSCSettings, ctx: LeonContext) extends Global(set
val
ctx
=
ScalaCompiler
.
this
.
ctx
val
ctx
=
ScalaCompiler
.
this
.
ctx
}
with
SaveImports
}
with
SaveImports
object
addTypeAnnotations
extends
{
val
global
:
ScalaCompiler.this.
type
=
ScalaCompiler
.
this
val
runsAfter
=
List
[
String
]()
val
runsRightAfter
=
Some
(
"parser"
)
val
ctx
=
ScalaCompiler
.
this
.
ctx
}
with
AddTypeAnnotations
override
protected
def
computeInternalPhases
()
:
Unit
=
{
override
protected
def
computeInternalPhases
()
:
Unit
=
{
val
phs
=
List
(
val
phs
=
List
(
syntaxAnalyzer
->
"parse source into ASTs, perform simple desugaring"
,
syntaxAnalyzer
->
"parse source into ASTs, perform simple desugaring"
,
addTypeAnnotations
->
"add type annotations useful for Leon"
,
analyzer
.
namerFactory
->
"resolve names, attach symbols to named trees"
,
analyzer
.
namerFactory
->
"resolve names, attach symbols to named trees"
,
analyzer
.
packageObjects
->
"load package objects"
,
analyzer
.
packageObjects
->
"load package objects"
,
analyzer
.
typerFactory
->
"the meat and potatoes: type the trees"
,
analyzer
.
typerFactory
->
"the meat and potatoes: type the trees"
,
...
...
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