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
e782ef6f
Commit
e782ef6f
authored
12 years ago
by
Etienne Kneuss
Committed by
Philippe Suter
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Provide all classes to CompilationUnit
parent
984286c4
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/codegen/CodeGeneration.scala
+4
-1
4 additions, 1 deletion
src/main/scala/leon/codegen/CodeGeneration.scala
src/main/scala/leon/codegen/CompilationUnit.scala
+20
-8
20 additions, 8 deletions
src/main/scala/leon/codegen/CompilationUnit.scala
with
24 additions
and
9 deletions
src/main/scala/leon/codegen/CodeGeneration.scala
+
4
−
1
View file @
e782ef6f
...
@@ -43,8 +43,11 @@ object CodeGeneration {
...
@@ -43,8 +43,11 @@ object CodeGeneration {
case
Int32Type
|
BooleanType
=>
case
Int32Type
|
BooleanType
=>
ch
<<
IRETURN
ch
<<
IRETURN
case
UnitType
|
TupleType
(
_
)
|
SetType
(
_
)
|
MapType
(
_
,
_
)
|
AbstractClassType
(
_
)
|
CaseClassType
(
_
)
=>
ch
<<
ARETURN
case
other
=>
case
other
=>
throw
CompilationException
(
"Unsupported return type : "
+
other
)
throw
CompilationException
(
"Unsupported return type : "
+
other
.
getClass
)
}
}
ch
.
freeze
ch
.
freeze
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/codegen/CompilationUnit.scala
+
20
−
8
View file @
e782ef6f
...
@@ -14,14 +14,14 @@ import cafebabe.Flags._
...
@@ -14,14 +14,14 @@ import cafebabe.Flags._
import
CodeGeneration._
import
CodeGeneration._
class
CompilationUnit
(
val
program
:
Program
,
val
mainClass
:
ClassFile
,
implicit
val
env
:
CompilationEnvironment
)
{
class
CompilationUnit
(
val
program
:
Program
,
val
classes
:
Seq
[
ClassFile
],
implicit
val
env
:
CompilationEnvironment
)
{
val
mainClassName
=
defToJVMName
(
program
,
program
.
mainObject
)
val
loader
=
new
CafebabeClassLoader
val
loader
=
new
CafebabeClassLoader
loader
.
register
(
mainClass
)
classes
.
foreach
(
loader
.
register
(
_
)
)
def
writeClassFiles
()
{
def
writeClassFiles
()
{
mainClass
.
writeToFile
(
mainClassName
+
".class"
)
for
(
cl
<-
classes
)
{
cl
.
writeToFile
(
cl
.
className
+
".class"
)
}
}
}
private
var
_nextExprId
=
0
private
var
_nextExprId
=
0
...
@@ -41,8 +41,12 @@ class CompilationUnit(val program: Program, val mainClass: ClassFile, implicit v
...
@@ -41,8 +41,12 @@ class CompilationUnit(val program: Program, val mainClass: ClassFile, implicit v
case
b
:
java.lang.Boolean
=>
case
b
:
java.lang.Boolean
=>
BooleanLiteral
(
b
.
booleanValue
)
BooleanLiteral
(
b
.
booleanValue
)
case
cc
:
runtime.CaseClass
=>
println
(
"YAY"
)
throw
CompilationException
(
"YAY Unsupported return value : "
+
e
)
case
_
=>
case
_
=>
throw
CompilationException
(
"Unsupported return value : "
+
e
)
throw
CompilationException
(
"
MEH
Unsupported return value : "
+
e
.
getClass
)
}
}
def
compileExpression
(
e
:
Expr
,
args
:
Seq
[
Identifier
])
:
CompiledExpression
=
{
def
compileExpression
(
e
:
Expr
,
args
:
Seq
[
Identifier
])
:
CompiledExpression
=
{
...
@@ -83,7 +87,7 @@ class CompilationUnit(val program: Program, val mainClass: ClassFile, implicit v
...
@@ -83,7 +87,7 @@ class CompilationUnit(val program: Program, val mainClass: ClassFile, implicit v
case
Int32Type
|
BooleanType
=>
case
Int32Type
|
BooleanType
=>
ch
<<
IRETURN
ch
<<
IRETURN
case
UnitType
|
TupleType
(
_
)
|
SetType
(
_
)
|
MapType
(
_
,
_
)
=>
case
UnitType
|
TupleType
(
_
)
|
SetType
(
_
)
|
MapType
(
_
,
_
)
|
AbstractClassType
(
_
)
|
CaseClassType
(
_
)
=>
ch
<<
ARETURN
ch
<<
ARETURN
case
other
=>
case
other
=>
...
@@ -102,13 +106,21 @@ object CompilationUnit {
...
@@ -102,13 +106,21 @@ object CompilationUnit {
def
compileProgram
(
p
:
Program
)
:
Option
[
CompilationUnit
]
=
{
def
compileProgram
(
p
:
Program
)
:
Option
[
CompilationUnit
]
=
{
implicit
val
env
=
CompilationEnvironment
.
fromProgram
(
p
)
implicit
val
env
=
CompilationEnvironment
.
fromProgram
(
p
)
var
classes
=
Seq
[
ClassFile
]()
for
((
parent
,
children
)
<-
p
.
algebraicDataTypes
)
{
for
((
parent
,
children
)
<-
p
.
algebraicDataTypes
)
{
val
acf
=
compileAbstractClassDef
(
p
,
parent
)
val
acf
=
compileAbstractClassDef
(
p
,
parent
)
val
ccfs
=
children
.
map
(
c
=>
compileCaseClassDef
(
p
,
c
))
val
ccfs
=
children
.
map
(
c
=>
compileCaseClassDef
(
p
,
c
))
classes
=
classes
:+
acf
classes
=
classes
++
ccfs
}
}
val
mainClassName
=
defToJVMName
(
p
,
p
.
mainObject
)
val
mainClassName
=
defToJVMName
(
p
,
p
.
mainObject
)
val
cf
=
new
ClassFile
(
mainClassName
,
None
)
val
cf
=
new
ClassFile
(
mainClassName
,
None
)
classes
=
classes
:+
cf
cf
.
addDefaultConstructor
cf
.
addDefaultConstructor
cf
.
setFlags
((
cf
.
setFlags
((
...
@@ -136,6 +148,6 @@ object CompilationUnit {
...
@@ -136,6 +148,6 @@ object CompilationUnit {
compileFunDef
(
funDef
,
m
.
codeHandler
)
compileFunDef
(
funDef
,
m
.
codeHandler
)
}
}
Some
(
new
CompilationUnit
(
p
,
c
f
,
env
))
Some
(
new
CompilationUnit
(
p
,
c
lasses
,
env
))
}
}
}
}
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