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
cdbb1aeb
Commit
cdbb1aeb
authored
7 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
handle list case in binary operations
parent
62df0d45
No related branches found
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/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java
+59
-0
59 additions, 0 deletions
.../com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java
with
59 additions
and
0 deletions
com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java
+
59
−
0
View file @
cdbb1aeb
...
...
@@ -35,9 +35,18 @@ import com.oracle.truffle.r.runtime.RDeparse;
import
com.oracle.truffle.r.runtime.RError
;
import
com.oracle.truffle.r.runtime.RError.Message
;
import
com.oracle.truffle.r.runtime.RType
;
import
com.oracle.truffle.r.runtime.data.RComplex
;
import
com.oracle.truffle.r.runtime.data.RComplexVector
;
import
com.oracle.truffle.r.runtime.data.RDoubleVector
;
import
com.oracle.truffle.r.runtime.data.RIntVector
;
import
com.oracle.truffle.r.runtime.data.RLanguage
;
import
com.oracle.truffle.r.runtime.data.RLogicalVector
;
import
com.oracle.truffle.r.runtime.data.RRaw
;
import
com.oracle.truffle.r.runtime.data.RRawVector
;
import
com.oracle.truffle.r.runtime.data.RString
;
import
com.oracle.truffle.r.runtime.data.RStringVector
;
import
com.oracle.truffle.r.runtime.data.RSymbol
;
import
com.oracle.truffle.r.runtime.data.RVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractIntVector
;
...
...
@@ -153,6 +162,56 @@ public abstract class BinaryBooleanNode extends RBuiltinNode.Arg2 {
return
RString
.
valueOf
(
RDeparse
.
deparse
(
val
,
RDeparse
.
MAX_CUTOFF
,
false
,
RDeparse
.
KEEPINTEGER
,
-
1
));
}
protected
static
boolean
isOneList
(
Object
left
,
Object
right
)
{
return
isRAbstractListVector
(
left
)
^
isRAbstractListVector
(
right
);
}
@Specialization
(
guards
=
{
"isOneList(left, right)"
})
protected
Object
doList
(
VirtualFrame
frame
,
RAbstractVector
left
,
RAbstractVector
right
,
@Cached
(
"create()"
)
CastTypeNode
cast
,
@Cached
(
"createRecursive()"
)
BinaryBooleanNode
recursive
)
{
Object
recursiveLeft
=
left
;
if
(
isRAbstractListVector
(
left
))
{
recursiveLeft
=
castListToAtomic
(
left
,
cast
,
right
.
getRType
());
}
Object
recursiveRight
=
right
;
if
(
isRAbstractListVector
(
right
))
{
recursiveRight
=
castListToAtomic
(
right
,
cast
,
left
.
getRType
());
}
return
recursive
.
execute
(
frame
,
recursiveLeft
,
recursiveRight
);
}
@TruffleBoundary
private
static
Object
castListToAtomic
(
RAbstractVector
source
,
CastTypeNode
cast
,
RType
type
)
{
RVector
<?>
result
=
type
.
create
(
source
.
getLength
(),
false
);
Object
store
=
result
.
getInternalStore
();
for
(
int
i
=
0
;
i
<
source
.
getLength
();
i
++)
{
Object
value
=
source
.
getDataAtAsObject
(
i
);
if
(
type
==
RType
.
Character
)
{
value
=
RDeparse
.
deparse
(
value
);
((
RStringVector
)
result
).
setDataAt
(
store
,
i
,
(
String
)
value
);
}
else
{
value
=
cast
.
execute
(
value
,
type
);
if
(
value
instanceof
RAbstractVector
&&
((
RAbstractVector
)
value
).
getLength
()
==
1
)
{
value
=
((
RAbstractVector
)
value
).
getDataAtAsObject
(
0
);
}
if
(
type
==
RType
.
Integer
&&
value
instanceof
Integer
)
{
((
RIntVector
)
result
).
setDataAt
(
store
,
i
,
(
int
)
value
);
}
else
if
(
type
==
RType
.
Double
&&
value
instanceof
Double
)
{
((
RDoubleVector
)
result
).
setDataAt
(
store
,
i
,
(
double
)
value
);
}
else
if
(
type
==
RType
.
Logical
&&
value
instanceof
Byte
)
{
((
RLogicalVector
)
result
).
setDataAt
(
store
,
i
,
(
byte
)
value
);
}
else
if
(
type
==
RType
.
Complex
&&
value
instanceof
RComplex
)
{
((
RComplexVector
)
result
).
setDataAt
(
store
,
i
,
(
RComplex
)
value
);
}
else
if
(
type
==
RType
.
Raw
&&
value
instanceof
RRaw
)
{
((
RRawVector
)
result
).
setRawDataAt
(
store
,
i
,
((
RRaw
)
value
).
getValue
());
}
}
}
return
result
;
}
protected
BinaryBooleanNode
createRecursive
()
{
return
BinaryBooleanNode
.
create
(
factory
);
}
...
...
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