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
48b87da5
Commit
48b87da5
authored
14 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
now can compile from a string instead of a file.
parent
c72dba7e
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/funcheck/Main.scala
+43
-30
43 additions, 30 deletions
src/funcheck/Main.scala
with
43 additions
and
30 deletions
src/funcheck/Main.scala
+
43
−
30
View file @
48b87da5
...
...
@@ -4,42 +4,28 @@ import scala.tools.nsc.{Global,Settings,SubComponent,CompilerCommand}
import
purescala.Definitions.Program
/** This class is a compiler that will be used for running
* the plugin in standalone mode. Courtesy of D. Zufferey. */
class
PluginRunner
(
settings
:
Settings
,
reportingFunction
:
String
=>
Unit
,
actionOnProgram
:
Option
[
Program
=>
Unit
])
extends
Global
(
settings
,
new
SimpleReporter
(
settings
,
reportingFunction
))
{
val
funcheckPlugin
=
new
FunCheckPlugin
(
this
,
actionOnProgram
)
protected
def
addToPhasesSet
(
sub
:
SubComponent
,
descr
:
String
)
:
Unit
=
{
phasesSet
+=
sub
}
/** The phases to be run. */
override
protected
def
computeInternalPhases
()
:
Unit
=
{
val
phs
=
List
(
syntaxAnalyzer
->
"parse source into ASTs, perform simple desugaring"
,
analyzer
.
namerFactory
->
"resolve names, attach symbols to named trees"
,
analyzer
.
packageObjects
->
"load package objects"
,
analyzer
.
typerFactory
->
"the meat and potatoes: type the trees"
,
superAccessors
->
"add super accessors in traits and nested classes"
,
pickler
->
"serialize symbol tables"
,
refchecks
->
"reference and override checking, translate nested objects"
)
:::
{
val
zipped
=
funcheckPlugin
.
components
zip
funcheckPlugin
.
descriptions
zipped
}
phs
foreach
(
addToPhasesSet
_
).
tupled
}
}
object
Main
{
import
purescala.
{
Reporter
,
DefaultReporter
,
Definitions
,
Analysis
}
import
Definitions.Program
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
main
(
args
,
new
DefaultReporter
)
def
main
(
args
:
Array
[
String
])
:
Unit
=
run
(
args
)
def
runFromString
(
program
:
String
,
args
:
Array
[
String
],
reporter
:
Reporter
=
new
DefaultReporter
)
:
Unit
=
{
import
java.io.
{
BufferedWriter
,
File
,
FileWriter
,
IOException
}
try
{
val
file
:
File
=
File
.
createTempFile
(
"leon"
,
".scala"
)
file
.
deleteOnExit
val
out
=
new
BufferedWriter
(
new
FileWriter
(
file
))
out
.
write
(
program
)
out
.
close
run
(
file
.
getPath
.
toString
+:
args
,
reporter
)
}
catch
{
case
e
:
IOException
=>
reporter
.
error
(
e
.
getMessage
)
}
}
def
mai
n
(
args
:
Array
[
String
],
reporter
:
Reporter
)
:
Unit
=
{
def
ru
n
(
args
:
Array
[
String
],
reporter
:
Reporter
=
new
DefaultReporter
)
:
Unit
=
{
val
settings
=
new
Settings
runWithSettings
(
args
,
settings
,
s
=>
reporter
.
info
(
s
),
Some
(
p
=>
defaultAction
(
p
,
reporter
)))
}
...
...
@@ -69,3 +55,30 @@ object Main {
}
}
}
/** This class is a compiler that will be used for running the plugin in
* standalone mode. Original version courtesy of D. Zufferey. */
class
PluginRunner
(
settings
:
Settings
,
reportingFunction
:
String
=>
Unit
,
actionOnProgram
:
Option
[
Program
=>
Unit
])
extends
Global
(
settings
,
new
SimpleReporter
(
settings
,
reportingFunction
))
{
val
funcheckPlugin
=
new
FunCheckPlugin
(
this
,
actionOnProgram
)
protected
def
addToPhasesSet
(
sub
:
SubComponent
,
descr
:
String
)
:
Unit
=
{
phasesSet
+=
sub
}
/** The phases to be run. */
override
protected
def
computeInternalPhases
()
:
Unit
=
{
val
phs
=
List
(
syntaxAnalyzer
->
"parse source into ASTs, perform simple desugaring"
,
analyzer
.
namerFactory
->
"resolve names, attach symbols to named trees"
,
analyzer
.
packageObjects
->
"load package objects"
,
analyzer
.
typerFactory
->
"the meat and potatoes: type the trees"
,
superAccessors
->
"add super accessors in traits and nested classes"
,
pickler
->
"serialize symbol tables"
,
refchecks
->
"reference and override checking, translate nested objects"
)
:::
{
val
zipped
=
funcheckPlugin
.
components
zip
funcheckPlugin
.
descriptions
zipped
}
phs
foreach
(
addToPhasesSet
_
).
tupled
}
}
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