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
ea9a4dd3
Commit
ea9a4dd3
authored
10 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
small refactoring in IsTypeFunctions
parent
54e2bdb3
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/IsTypeFunctions.java
+20
-25
20 additions, 25 deletions
.../oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java
with
20 additions
and
25 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java
+
20
−
25
View file @
ea9a4dd3
...
...
@@ -43,35 +43,18 @@ public class IsTypeFunctions {
protected
abstract
static
class
ErrorAdapter
extends
RBuiltinNode
{
protected
final
BranchProfile
errorProfile
=
BranchProfile
.
create
();
protected
RError
missingError
()
throws
RError
{
errorProfile
.
enter
();
throw
RError
.
error
(
getEncapsulatingSourceSection
(),
RError
.
Message
.
ARGUMENT_MISSING
,
"x"
);
}
}
protected
abstract
static
class
IsFalseAdapter
extends
ErrorAdapter
{
@Override
public
RNode
[]
getParameterValues
()
{
return
new
RNode
[]{
ConstantNode
.
create
(
RMissing
.
instance
)};
}
@Specialization
protected
byte
isType
(
RMissing
value
)
throws
RError
{
controlVisibility
();
throw
missingError
();
}
@Fallback
protected
byte
isType
(
Object
value
)
{
return
RRuntime
.
LOGICAL_FALSE
;
protected
RError
missingError
()
throws
RError
{
errorProfile
.
enter
();
throw
RError
.
error
(
getEncapsulatingSourceSection
(),
RError
.
Message
.
ARGUMENT_MISSING
,
"x"
);
}
}
protected
abstract
static
class
IsTrueAdapter
extends
ErrorAdapter
{
@Override
public
RNode
[]
getParameterValues
()
{
return
new
RNode
[]{
ConstantNode
.
create
(
RMissing
.
instance
)};
}
protected
abstract
static
class
IsFalseAdapter
extends
ErrorAdapter
{
@Specialization
protected
byte
isType
(
RMissing
value
)
throws
RError
{
...
...
@@ -81,7 +64,8 @@ public class IsTypeFunctions {
@Fallback
protected
byte
isType
(
Object
value
)
{
return
RRuntime
.
LOGICAL_TRUE
;
controlVisibility
();
return
RRuntime
.
LOGICAL_FALSE
;
}
}
...
...
@@ -97,7 +81,13 @@ public class IsTypeFunctions {
}
@RBuiltin
(
name
=
"is.recursive"
,
kind
=
PRIMITIVE
,
parameterNames
=
{
"x"
})
public
abstract
static
class
IsRecursive
extends
IsTrueAdapter
{
public
abstract
static
class
IsRecursive
extends
ErrorAdapter
{
@Specialization
protected
byte
isRecursive
(
RMissing
value
)
throws
RError
{
controlVisibility
();
throw
missingError
();
}
@Specialization
protected
byte
isRecursive
(
RNull
arg
)
{
...
...
@@ -112,13 +102,13 @@ public class IsTypeFunctions {
}
@Specialization
protected
byte
is
Atomic
(
RList
arg
)
{
protected
byte
is
Recursive
(
RList
arg
)
{
controlVisibility
();
return
RRuntime
.
LOGICAL_TRUE
;
}
@Specialization
protected
byte
is
Atomic
(
RFactor
arg
)
{
protected
byte
is
Recursive
(
RFactor
arg
)
{
controlVisibility
();
return
RRuntime
.
LOGICAL_FALSE
;
}
...
...
@@ -127,6 +117,11 @@ public class IsTypeFunctions {
return
arg
.
getElementClass
()
==
Object
.
class
;
}
@Fallback
protected
byte
isRecursiveFallback
(
Object
value
)
{
controlVisibility
();
return
RRuntime
.
LOGICAL_TRUE
;
}
}
@RBuiltin
(
name
=
"is.atomic"
,
kind
=
PRIMITIVE
,
parameterNames
=
{
"x"
})
...
...
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