Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Julien Lopez
QueryR
Commits
fce0cfca
Commit
fce0cfca
authored
8 years ago
by
Adam Welc
Committed by
Mick Jordan
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added handling of pair lists during native evaluation.
parent
40297bbe
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java
+33
-0
33 additions, 0 deletions
.../com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java
with
33 additions
and
0 deletions
com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java
+
33
−
0
View file @
fce0cfca
...
...
@@ -23,16 +23,21 @@
package
com.oracle.truffle.r.runtime.ffi.jnr
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.oracle.truffle.api.CompilerDirectives.TruffleBoundary
;
import
com.oracle.truffle.api.source.Source
;
import
com.oracle.truffle.r.runtime.RArguments
;
import
com.oracle.truffle.r.runtime.RCaller
;
import
com.oracle.truffle.r.runtime.RCleanUp
;
import
com.oracle.truffle.r.runtime.RDeparse
;
import
com.oracle.truffle.r.runtime.REnvVars
;
import
com.oracle.truffle.r.runtime.RError
;
import
com.oracle.truffle.r.runtime.RErrorHandling
;
import
com.oracle.truffle.r.runtime.RInternalError
;
import
com.oracle.truffle.r.runtime.RRuntime
;
import
com.oracle.truffle.r.runtime.RSerialize
;
import
com.oracle.truffle.r.runtime.RType
;
import
com.oracle.truffle.r.runtime.RStartParams.SA_TYPE
;
import
com.oracle.truffle.r.runtime.context.Engine.ParseException
;
...
...
@@ -728,6 +733,32 @@ public class CallRFFIHelper {
return
result
;
}
private
static
Object
convertPairList
(
RPairList
list
)
{
try
{
if
(
list
.
getType
()
==
SEXPTYPE
.
LANGSXP
)
{
RPairList
pl
=
(
RPairList
)
list
;
Map
<
String
,
Object
>
constants
=
new
HashMap
<>();
String
deparse
=
RDeparse
.
deparseDeserialize
(
constants
,
pl
);
Source
source
=
Source
.
fromText
(
deparse
,
"<PAIR LIST CONVERT deparse>"
);
RExpression
expr
=
RContext
.
getEngine
().
parse
(
constants
,
source
);
assert
expr
.
getLength
()
==
1
;
Object
result
=
expr
.
getDataAt
(
0
);
RAttributes
attrs
=
pl
.
getAttributes
();
if
(
result
instanceof
RAttributable
)
{
RSerialize
.
copyAttributes
((
RAttributable
)
result
,
attrs
);
}
return
result
;
}
else
{
throw
RInternalError
.
shouldNotReachHere
();
}
}
catch
(
Throwable
x
)
{
throw
RInternalError
.
shouldNotReachHere
();
}
}
@TruffleBoundary
public
static
Object
Rf_eval
(
Object
expr
,
Object
env
)
{
RFFIUtils
.
traceUpCall
(
"Rf_eval"
,
expr
,
env
);
guarantee
(
env
instanceof
REnvironment
);
...
...
@@ -738,6 +769,8 @@ public class CallRFFIHelper {
result
=
RContext
.
getEngine
().
eval
((
RExpression
)
expr
,
(
REnvironment
)
env
,
RCaller
.
createInvalid
(
null
));
}
else
if
(
expr
instanceof
RLanguage
)
{
result
=
RContext
.
getEngine
().
eval
((
RLanguage
)
expr
,
(
REnvironment
)
env
,
RCaller
.
createInvalid
(
null
));
}
else
if
(
expr
instanceof
RPairList
)
{
result
=
Rf_eval
(
convertPairList
((
RPairList
)
expr
),
env
);
}
else
{
// just return value
result
=
expr
;
...
...
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