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
8a5336b2
Commit
8a5336b2
authored
15 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
c480f00b
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/funcheck/CodeExtraction.scala
+20
-0
20 additions, 0 deletions
src/funcheck/CodeExtraction.scala
src/funcheck/purescala/Symbols.scala
+5
-5
5 additions, 5 deletions
src/funcheck/purescala/Symbols.scala
with
25 additions
and
5 deletions
src/funcheck/CodeExtraction.scala
+
20
−
0
View file @
8a5336b2
...
...
@@ -7,6 +7,7 @@ import purescala.Definitions._
import
purescala.Trees._
import
purescala.TypeTrees._
import
purescala.Common._
import
purescala.Symbols._
trait
CodeExtraction
extends
Extractors
{
self
:
AnalysisComponent
=>
...
...
@@ -16,6 +17,11 @@ trait CodeExtraction extends Extractors {
import
ExpressionExtractors._
def
extractCode
(
unit
:
CompilationUnit
)
:
Program
=
{
import
scala.collection.mutable.HashMap
// register where the symbols where extracted from
val
symbolDefMap
=
new
HashMap
[
Symbol
,
Tree
]
def
s2ps
(
tree
:
Tree
)
:
Expr
=
toPureScala
(
unit
)(
tree
)
match
{
case
Some
(
ex
)
=>
ex
case
None
=>
stopIfErrors
;
throw
new
Error
(
"unreachable"
)
...
...
@@ -38,6 +44,12 @@ trait CodeExtraction extends Extractors {
// case _ => ;
// }
/** Populates the symbolDefMap and returns the symbol corresponding to
* the expected single top-level object. */
def
extractSymbols
:
ObjectSymbol
=
{
null
}
def
extractObject
(
name
:
Identifier
,
tmpl
:
Template
)
:
ObjectDef
=
{
var
funDefs
:
List
[
FunDef
]
=
Nil
var
valDefs
:
List
[
ValDef
]
=
Nil
...
...
@@ -84,6 +96,14 @@ trait CodeExtraction extends Extractors {
// Extraction of the expressions.
// (new ForeachTreeTraverser(trav)).traverse(unit.body)
// Step-by-step algo:
// 1) extract class and object symbols (will already be nested)
// 2) extract function and val symbols (can now have a type, since we
// have full class hierarchy)
// 3) extract val and function bodies (can do it, since we have all
// definitions, hence we can resolve all symbols)
stopIfErrors
program
.
get
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/purescala/Symbols.scala
+
5
−
5
View file @
8a5336b2
...
...
@@ -3,23 +3,23 @@ package funcheck.purescala
import
Common._
import
TypeTrees._
/** There's a need for symbols, as we have purely functional trees with
* potential recursive calls, and we want references to be resolved once and
* for all. */
object
Symbols
{
trait
Symbolic
{
self
=>
private
var
__s
:
Option
[
Symbol
]
=
None
def
symbol
:
Symbol
=
__s
.
getOrElse
(
throw
new
Exception
(
"Undefined symbol
!
"
))
def
symbol
:
Symbol
=
__s
.
getOrElse
(
throw
new
Exception
(
"Undefined symbol
.
"
))
def
setSymbol
(
s
:
Symbol
)
:
self.
type
=
__s
match
{
case
Some
(
_
)
=>
throw
new
Exception
(
"Symbol already set
!
"
)
case
Some
(
_
)
=>
throw
new
Exception
(
"Symbol already set
.
"
)
case
None
=>
{
__s
=
Some
(
s
);
this
}
}
}
/** There's a need for symbols, as we have purely functional trees with
* potential recursive calls, and we want references to be resolved once
* and for all. */
sealed
abstract
class
Symbol
{
val
id
:
Identifier
}
...
...
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