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
d072e872
Commit
d072e872
authored
14 years ago
by
Philippe Suter
Browse files
Options
Downloads
Patches
Plain Diff
some changes on case classes
parent
6e755bdd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ParseMe.scala
+4
-0
4 additions, 0 deletions
ParseMe.scala
src/funcheck/CodeExtraction.scala
+8
-6
8 additions, 6 deletions
src/funcheck/CodeExtraction.scala
src/funcheck/Extractors.scala
+29
-5
29 additions, 5 deletions
src/funcheck/Extractors.scala
with
41 additions
and
11 deletions
ParseMe.scala
+
4
−
0
View file @
d072e872
...
@@ -2,6 +2,10 @@ import scala.collection.immutable.Set
...
@@ -2,6 +2,10 @@ import scala.collection.immutable.Set
object
ParseMe
{
object
ParseMe
{
sealed
abstract
class
Tree
case
class
Node
(
left
:
Tree
,
value
:
Int
,
right
:
Tree
)
extends
Tree
case
class
Leaf
()
extends
Tree
def
fromSet
(
i
:
Set
[
Set
[
Boolean
]])
:
Int
=
{
def
fromSet
(
i
:
Set
[
Set
[
Boolean
]])
:
Int
=
{
5
5
}
}
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/CodeExtraction.scala
+
8
−
6
View file @
d072e872
...
@@ -68,22 +68,24 @@ trait CodeExtraction extends Extractors {
...
@@ -68,22 +68,24 @@ trait CodeExtraction extends Extractors {
var
objectDefs
:
List
[
ObjectDef
]
=
Nil
var
objectDefs
:
List
[
ObjectDef
]
=
Nil
var
funDefs
:
List
[
FunDef
]
=
Nil
var
funDefs
:
List
[
FunDef
]
=
Nil
tmpl
.
body
.
foreach
(
tree
=>
{
tmpl
.
body
.
foreach
(
//println("[[[ " + tree + "]]]\n");
_
match
{
tree
match
{
case
ExCaseClassSyntheticJunk
()
=>
;
case
ExObjectDef
(
o2
,
t2
)
=>
{
objectDefs
=
extractObjectDef
(
o2
,
t2
)
::
objectDefs
}
case
ExObjectDef
(
o2
,
t2
)
=>
{
objectDefs
=
extractObjectDef
(
o2
,
t2
)
::
objectDefs
}
case
ExAbstractClass
(
o2
)
=>
;
case
ExAbstractClass
(
o2
)
=>
println
(
"That seems to be an abstract class: [["
+
o2
+
"]]"
)
case
ExCaseClass
(
o2
)
=>
println
(
o2
)
case
ExConstructorDef
()
=>
;
case
ExConstructorDef
()
=>
;
case
ExMainFunctionDef
()
=>
;
case
ExMainFunctionDef
()
=>
;
case
ExFunctionDef
(
n
,
p
,
t
,
b
)
=>
{
funDefs
=
extractFunDef
(
n
,
p
,
t
,
b
)
::
funDefs
}
case
ExFunctionDef
(
n
,
p
,
t
,
b
)
=>
{
funDefs
=
extractFunDef
(
n
,
p
,
t
,
b
)
::
funDefs
}
case
_
=>
;
case
tree
=>
{
println
(
"Something else: "
);
println
(
"[[[ "
+
tree
+
"]]]\n"
)
}
}
})
})
// val theSym = new purescala.Symbols.ObjectSymbol(name, classSyms.reverse, objectSyms.reverse)
// val theSym = new purescala.Symbols.ObjectSymbol(name, classSyms.reverse, objectSyms.reverse)
// we register the tree associated to the symbol to be able to fill in
// we register the tree associated to the symbol to be able to fill in
// the rest later
// the rest later
// symbolDefMap(theSym) = tmpl
// symbolDefMap(theSym) = tmpl
val
theDef
=
new
ObjectDef
(
name
,
objectDefs
.
reverse
:::
classDefs
.
reverse
:::
funDefs
.
reverse
,
Nil
)
val
theDef
=
new
ObjectDef
(
name
,
objectDefs
.
reverse
:::
classDefs
.
reverse
:::
funDefs
.
reverse
,
Nil
)
theDef
theDef
}
}
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/Extractors.scala
+
29
−
5
View file @
d072e872
...
@@ -54,7 +54,7 @@ trait Extractors {
...
@@ -54,7 +54,7 @@ trait Extractors {
* visibility. Does not match on the automatically generated companion
* visibility. Does not match on the automatically generated companion
* objects of case classes (or any synthetic class). */
* objects of case classes (or any synthetic class). */
def
unapply
(
cd
:
ClassDef
)
:
Option
[(
String
,
Template
)]
=
cd
match
{
def
unapply
(
cd
:
ClassDef
)
:
Option
[(
String
,
Template
)]
=
cd
match
{
case
ClassDef
(
_
,
name
,
tparams
,
impl
)
if
(
cd
.
symbol
.
isModuleClass
&&
tparams
.
isEmpty
&&
!
cd
.
symbol
.
hasFlag
(
symtab
.
Flags
.
SYNTHETIC
)
)
=>
{
case
ClassDef
(
_
,
name
,
tparams
,
impl
)
if
(
cd
.
symbol
.
isModuleClass
&&
tparams
.
isEmpty
&&
!
cd
.
symbol
.
isSynthetic
)
=>
{
Some
((
name
.
toString
,
impl
))
Some
((
name
.
toString
,
impl
))
}
}
case
_
=>
None
case
_
=>
None
...
@@ -66,16 +66,40 @@ trait Extractors {
...
@@ -66,16 +66,40 @@ trait Extractors {
* constrctor args (in the case of a class), no implementation details,
* constrctor args (in the case of a class), no implementation details,
* no abstract members. */
* no abstract members. */
def
unapply
(
cd
:
ClassDef
)
:
Option
[(
String
)]
=
cd
match
{
def
unapply
(
cd
:
ClassDef
)
:
Option
[(
String
)]
=
cd
match
{
case
ClassDef
(
_
,
name
,
tparams
,
impl
)
if
(
cd
.
symbol
.
isTrait
&&
tparams
.
isEmpty
&&
impl
.
body
.
length
==
2
)
=>
{
// trait
println
(
name
+
" seems to be a cool trait"
)
// case ClassDef(_, name, tparams, impl) if (cd.symbol.isTrait && tparams.isEmpty && impl.body.isEmpty) => Some(name.toString)
Some
(
name
.
toString
)
}
// abstract class
case
ClassDef
(
_
,
name
,
tparams
,
impl
)
if
(
cd
.
symbol
.
isAbstractClass
&&
tparams
.
isEmpty
&&
impl
.
body
.
size
==
1
)
=>
Some
(
name
.
toString
)
case
_
=>
None
case
_
=>
None
}
}
}
}
object
ExCaseClass
{
object
ExCaseClass
{
def
unapply
(
cd
:
ClassDef
)
:
Option
[(
String
)]
=
cd
match
{
case
ClassDef
(
_
,
name
,
tparams
,
impl
)
if
(
cd
.
symbol
.
isCase
&&
!
cd
.
symbol
.
isAbstractClass
&&
tparams
.
isEmpty
&&
impl
.
body
.
size
>=
8
)
=>
{
println
(
"I think I have something here"
)
println
(
impl
.
body
.
size
)
cd
.
symbol
.
tpe
match
{
case
ClassInfoType
(
prts
,
decls
,
cls
)
=>
{
println
(
"## "
+
prts
)
println
(
"## "
+
decls
)
println
(
"## "
+
cls
)
}
case
_
=>
;
}
Some
(
name
.
toString
)
}
case
_
=>
None
}
}
object
ExCaseClassSyntheticJunk
{
def
unapply
(
cd
:
ClassDef
)
:
Boolean
=
cd
match
{
case
ClassDef
(
_
,
_
,
_
,
_
)
if
(
cd
.
symbol
.
isSynthetic
&&
cd
.
symbol
.
isFinal
)
=>
true
case
_
=>
false
}
}
}
object
ExConstructorDef
{
object
ExConstructorDef
{
...
...
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