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
be54e78b
Commit
be54e78b
authored
9 years ago
by
Christian Humer
Browse files
Options
Downloads
Patches
Plain Diff
Use replace vector nodes for field updates.
parent
4ebefce0
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.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java
+30
-13
30 additions, 13 deletions
...truffle/r/nodes/builtin/base/InfixEmulationFunctions.java
with
30 additions
and
13 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java
+
30
−
13
View file @
be54e78b
...
...
@@ -31,11 +31,12 @@ import com.oracle.truffle.api.dsl.*;
import
com.oracle.truffle.api.frame.*
;
import
com.oracle.truffle.api.profiles.*
;
import
com.oracle.truffle.api.source.*
;
import
com.oracle.truffle.r.nodes.access.*
;
import
com.oracle.truffle.r.nodes.access.vector.*
;
import
com.oracle.truffle.r.nodes.binary.*
;
import
com.oracle.truffle.r.nodes.builtin.*
;
import
com.oracle.truffle.r.nodes.builtin.base.InfixEmulationFunctionsFactory.PromiseEvaluatorNodeGen
;
import
com.oracle.truffle.r.nodes.function.*
;
import
com.oracle.truffle.r.nodes.unary.*
;
import
com.oracle.truffle.r.parser.ast.*
;
import
com.oracle.truffle.r.runtime.*
;
import
com.oracle.truffle.r.runtime.data.*
;
...
...
@@ -332,24 +333,40 @@ public class InfixEmulationFunctions {
@RBuiltin
(
name
=
"$<-"
,
kind
=
RBuiltinKind
.
PRIMITIVE
,
parameterNames
=
{
""
,
""
,
""
},
dispatch
=
INTERNAL_GENERIC
)
public
abstract
static
class
UpdateFieldBuiltin
extends
RBuiltinNode
{
@Child
private
UpdateFieldNode
updateNode
;
private
final
BranchProfile
errorProfile
=
BranchProfile
.
create
();
private
final
BranchProfile
coerceList
=
BranchProfile
.
create
();
@Child
private
ReplaceVectorNode
extract
=
ReplaceVectorNode
.
create
(
ElementAccessMode
.
SUBSCRIPT
,
true
);
@Child
private
CastListNode
castList
;
@Specialization
protected
Object
accessField
(
VirtualFrame
frame
,
Object
container
,
Object
field
,
Object
value
)
{
if
(
field
instanceof
String
)
{
if
(
updateNode
==
null
)
{
protected
Object
update
(
VirtualFrame
frame
,
Object
container
,
String
field
,
Object
value
)
{
Object
updatedObject
=
container
;
if
(!(
container
instanceof
RAbstractListVector
))
{
coerceList
.
enter
();
updatedObject
=
coerceList
(
container
,
updatedObject
);
}
return
extract
.
apply
(
frame
,
updatedObject
,
new
Object
[]{
field
},
value
);
}
private
Object
coerceList
(
Object
object
,
Object
vector
)
{
Object
updatedVector
=
vector
;
if
(
object
instanceof
RAbstractVector
)
{
if
(
castList
==
null
)
{
CompilerDirectives
.
transferToInterpreterAndInvalidate
();
updateNode
=
insert
(
UpdateFieldNodeGen
.
create
(
null
,
null
,
null
));
castList
=
insert
(
CastListNodeGen
.
create
(
true
,
true
,
false
));
}
return
updateNode
.
executeUpdate
(
frame
,
container
,
value
,
(
String
)
field
);
}
else
{
errorProfile
.
enter
();
// TODO: the error message is not quite correct for all types;
// for example: x<-list(a=7); `$<-`(x, c("a"), 42);)
throw
RError
.
error
(
this
,
RError
.
Message
.
INVALID_SUBSCRIPT_TYPE
,
RRuntime
.
classToString
(
field
.
getClass
()));
RError
.
warning
(
this
,
RError
.
Message
.
COERCING_LHS_TO_LIST
);
updatedVector
=
castList
.
executeList
(
vector
);
}
return
updatedVector
;
}
@Fallback
protected
Object
fallbackError
(
@SuppressWarnings
(
"unused"
)
Object
container
,
Object
field
,
@SuppressWarnings
(
"unused"
)
Object
value
)
{
// TODO: the error message is not quite correct for all types;
// for example: x<-list(a=7); `$<-`(x, c("a"), 42);)
throw
RError
.
error
(
this
,
RError
.
Message
.
INVALID_SUBSCRIPT_TYPE
,
RRuntime
.
classToString
(
field
.
getClass
()));
}
}
@RBuiltin
(
name
=
":"
,
kind
=
RBuiltinKind
.
PRIMITIVE
,
parameterNames
=
{
"from"
,
"to"
})
...
...
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