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
9f530f53
Commit
9f530f53
authored
12 years ago
by
Etienne Kneuss
Committed by
Philippe Suter
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Renamings
parent
27600072
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/CompilationUnit.scala
+5
-5
5 additions, 5 deletions
src/main/scala/leon/codegen/CompilationUnit.scala
src/main/scala/leon/codegen/CompiledExpression.scala
+3
-3
3 additions, 3 deletions
src/main/scala/leon/codegen/CompiledExpression.scala
with
8 additions
and
8 deletions
src/main/scala/leon/codegen/CompilationUnit.scala
+
5
−
5
View file @
9f530f53
...
...
@@ -33,11 +33,11 @@ class CompilationUnit(val program: Program, val classes: Map[Definition, ClassFi
_nextExprId
}
private
[
codegen
]
def
groundExprToJava
(
e
:
Expr
)
:
Any
=
{
compileExpression
(
e
,
Seq
()).
evalToJ
ava
(
Seq
())
private
[
codegen
]
def
valueToJVM
(
e
:
Expr
)
:
Any
=
{
compileExpression
(
e
,
Seq
()).
evalToJ
VM
(
Seq
())
}
private
[
codegen
]
def
j
avaToGroundExpr
(
e
:
AnyRef
)
:
Expr
=
e
match
{
private
[
codegen
]
def
j
vmToValue
(
e
:
AnyRef
)
:
Expr
=
e
match
{
case
i
:
Integer
=>
IntLiteral
(
i
.
toInt
)
...
...
@@ -49,14 +49,14 @@ class CompilationUnit(val program: Program, val classes: Map[Definition, ClassFi
jvmClassToDef
.
get
(
e
.
getClass
.
getName
)
match
{
case
Some
(
cc
:
CaseClassDef
)
=>
CaseClass
(
cc
,
fields
.
map
(
j
avaToGroundExpr
))
CaseClass
(
cc
,
fields
.
map
(
j
vmToValue
))
case
_
=>
throw
CompilationException
(
"Unsupported return value : "
+
e
)
}
case
tpl
:
runtime.Tuple
=>
val
elems
=
for
(
i
<-
0
until
tpl
.
getArity
)
yield
{
j
avaToGroundExpr
(
tpl
.
get
(
i
))
j
vmToValue
(
tpl
.
get
(
i
))
}
Tuple
(
elems
)
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/codegen/CompiledExpression.scala
+
3
−
3
View file @
9f530f53
...
...
@@ -14,7 +14,7 @@ import cafebabe.Flags._
class
CompiledExpression
(
unit
:
CompilationUnit
,
cf
:
ClassFile
,
argsDecl
:
Seq
[
Identifier
])
{
def
evalToJ
ava
(
args
:
Seq
[
Expr
])
:
AnyRef
=
{
def
evalToJ
VM
(
args
:
Seq
[
Expr
])
:
AnyRef
=
{
val
cl
=
unit
.
loader
.
loadClass
(
cf
.
className
)
val
meth
=
cl
.
getMethods
()(
0
)
...
...
@@ -23,12 +23,12 @@ class CompiledExpression(unit: CompilationUnit, cf: ClassFile, argsDecl: Seq[Ide
if
(
args
.
isEmpty
)
{
meth
.
invoke
(
null
)
}
else
{
meth
.
invoke
(
null
,
args
.
map
(
unit
.
groundExprToJava
).
toArray
)
meth
.
invoke
(
null
,
args
.
map
(
unit
.
valueToJVM
).
toArray
)
}
}
def
eval
(
args
:
Seq
[
Expr
])
:
Expr
=
{
unit
.
j
avaToGroundExpr
(
evalToJ
ava
(
args
))
unit
.
j
vmToValue
(
evalToJ
VM
(
args
))
}
}
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