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
78b370b5
Commit
78b370b5
authored
15 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
5b109a79
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/funcheck/AnalysisComponent.scala
+11
-29
11 additions, 29 deletions
src/funcheck/AnalysisComponent.scala
src/funcheck/CodeExtraction.scala
+18
-11
18 additions, 11 deletions
src/funcheck/CodeExtraction.scala
src/funcheck/purescala/Common.scala
+1
-1
1 addition, 1 deletion
src/funcheck/purescala/Common.scala
with
30 additions
and
41 deletions
src/funcheck/AnalysisComponent.scala
+
11
−
29
View file @
78b370b5
...
...
@@ -5,7 +5,6 @@ import scala.tools.nsc.plugins._
class
AnalysisComponent
(
val
global
:
Global
,
val
pluginInstance
:
FunCheckPlugin
)
extends
PluginComponent
with
Extractors
// all these traits define functions applied during tree traversals
with
CodeExtraction
with
ForallInjection
{
...
...
@@ -17,17 +16,23 @@ class AnalysisComponent(val global: Global, val pluginInstance: FunCheckPlugin)
val
phaseName
=
pluginInstance
.
name
private
def
stopIfErrors
:
Unit
=
{
if
(
reporter
.
hasErrors
)
{
println
(
"There were errors."
)
exit
(
0
)
}
}
def
newPhase
(
prev
:
Phase
)
=
new
AnalysisPhase
(
prev
)
class
AnalysisPhase
(
prev
:
Phase
)
extends
StdPhase
(
prev
)
{
import
StructuralExtractors._
def
apply
(
unit
:
CompilationUnit
)
:
Unit
=
{
//
(new ForeachTreeTraverser(firstFilter(unit))).traverse(unit.body)
//
stopIfErrors
(
new
ForeachTreeTraverser
(
firstFilter
(
unit
))).
traverse
(
unit
.
body
)
stopIfErrors
// (new ForeachTreeTraverser(findContracts)).traverse(unit.body)
// stopIfErrors
(
new
ForeachTreeTraverser
(
extractCode
(
unit
))).
traverse
(
unit
.
body
)
extractCode
(
unit
)
if
(
pluginInstance
.
stopAfterAnalysis
)
{
println
(
"Analysis complete. Now terminating the compiler process."
)
...
...
@@ -35,34 +40,11 @@ class AnalysisComponent(val global: Global, val pluginInstance: FunCheckPlugin)
}
}
private
def
stopIfErrors
:
Unit
=
{
if
(
reporter
.
hasErrors
)
{
println
(
"There were errors."
)
exit
(
0
)
}
}
/** Weeds out programs containing unsupported features. */
def
firstFilter
(
unit
:
CompilationUnit
)(
tree
:
Tree
)
:
Unit
=
{
def
unsup
(
s
:
String
)
:
String
=
"FunCheck: Unsupported construct: "
+
s
tree
match
{
case
c
@
ClassDef
(
mods
,
name
,
tparams
,
impl
)
=>
{
/*
val s = c.symbol
println(s)
if(s.isTrait)
unit.error(tree.pos, unsup("trait."))
else if(s.isModule)
println("Seems like " + name + " is an object.")
else if(s.isClass && !(mods.isCase || mods.isAbstract))
unit.error(tree.pos, unsup("non-abstract, non-case class."))
*/
}
case
ValDef
(
mods
,
name
,
tpt
,
rhs
)
if
mods
.
isVariable
=>
unit
.
error
(
tree
.
pos
,
unsup
(
"mutable variable/field."
))
case
LabelDef
(
name
,
params
,
rhs
)
=>
unit
.
error
(
tree
.
pos
,
unsup
(
"loop."
))
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/CodeExtraction.scala
+
18
−
11
View file @
78b370b5
...
...
@@ -2,7 +2,11 @@ package funcheck
import
scala.tools.nsc._
import
scala.tools.nsc.plugins._
import
purescala.Definitions._
import
purescala.Trees._
import
purescala.TypeTrees._
import
purescala.Common._
trait
CodeExtraction
{
self
:
AnalysisComponent
=>
...
...
@@ -36,20 +40,23 @@ trait CodeExtraction {
case
_
=>
;
}
def
extractCode
(
unit
:
CompilationUnit
)(
tree
:
Tree
)
:
Unit
=
tree
match
{
case
d
@
DefDef
(
mods
,
name
,
tparams
,
vparamss
,
tpt
,
body
)
if
!
d
.
symbol
.
isConstructor
=>
{
println
(
"In: "
+
name
)
println
(
d
.
symbol
)
println
(
d
.
mods
)
toPureScala
(
unit
)(
body
)
match
{
case
Some
(
t
)
=>
println
(
" the body was extracted as: "
+
t
)
case
None
=>
println
(
" the body could not be extracted. Is it pure Scala?"
)
def
extractCode
(
unit
:
CompilationUnit
)
:
Unit
=
{
def
trav
(
tree
:
Tree
)
:
Unit
=
tree
match
{
case
d
@
DefDef
(
mods
,
name
,
tparams
,
vparamss
,
tpt
,
body
)
if
!
d
.
symbol
.
isConstructor
=>
{
println
(
"In: "
+
name
)
println
(
d
.
symbol
)
println
(
d
.
mods
)
toPureScala
(
unit
)(
body
)
match
{
case
Some
(
t
)
=>
println
(
" the body was extracted as: "
+
t
)
case
None
=>
println
(
" the body could not be extracted. Is it pure Scala?"
)
}
}
case
_
=>
;
}
case
_
=>
;
(
new
ForeachTreeTraverser
(
trav
)).
traverse
(
unit
.
body
)
}
/** An exception thrown when non-purescala compatible code is encountered. */
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/Common.scala
→
src/funcheck/
purescala/
Common.scala
+
1
−
1
View file @
78b370b5
package
funcheck
package
funcheck
.purescala
object
Common
{
type
Identifier
=
String
...
...
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