FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jruby/src/org/jruby/ast/Colon2ConstNode.java at serializable_procs · MSNexploder/jruby · GitHub
MSNexploder
/
jruby
Public
forked from
jruby/jruby
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
ast
/
Colon2ConstNode.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
83 lines (66 loc) · 2.69 KB
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
ast
/
Colon2ConstNode.java
Copy path
File metadata and controls
83 lines (66 loc) · 2.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
org
.
jruby
.
ast
;
import
org
.
jruby
.
Ruby
;
import
org
.
jruby
.
RubyModule
;
import
org
.
jruby
.
exceptions
.
JumpException
;
import
org
.
jruby
.
javasupport
.
util
.
RuntimeHelpers
;
import
org
.
jruby
.
lexer
.
yacc
.
ISourcePosition
;
import
org
.
jruby
.
runtime
.
Block
;
import
org
.
jruby
.
runtime
.
ThreadContext
;
import
org
.
jruby
.
runtime
.
builtin
.
IRubyObject
;
/**
*
* @author enebo
*/
public
class
Colon2ConstNode
extends
Colon2Node
{
private
static
final
long
serialVersionUID
=
0L
;
private
volatile
transient
int
hash
= -
1
;
public
Colon2ConstNode
() {
super
();
}
public
Colon2ConstNode
(
ISourcePosition
position
,
Node
leftNode
,
String
name
) {
super
(
position
,
leftNode
,
name
);
assert
leftNode
!=
null
:
"Colon2ConstNode cannot have null leftNode"
;
}
@
Override
public
IRubyObject
interpret
(
Ruby
runtime
,
ThreadContext
context
,
IRubyObject
self
,
Block
aBlock
) {
RubyModule
target
=
RuntimeHelpers
.
checkIsModule
(
leftNode
.
interpret
(
runtime
,
context
,
self
,
aBlock
));
IRubyObject
value
=
getValue
(
context
,
target
);
return
value
!=
null
?
value
:
target
.
fastGetConstantFromConstMissing
(
name
);
}
@
Override
public
String
definition
(
Ruby
runtime
,
ThreadContext
context
,
IRubyObject
self
,
Block
aBlock
) {
IRubyObject
lastError
=
context
.
getErrorInfo
();
try
{
if
(
RuntimeHelpers
.
isModuleAndHasConstant
(
leftNode
.
interpret
(
runtime
,
context
,
self
,
aBlock
),
name
))
return
"constant"
;
}
catch
(
JumpException
e
) {
// replace lastError
context
.
setErrorInfo
(
lastError
);
}
return
null
;
}
public
IRubyObject
getValue
(
ThreadContext
context
,
RubyModule
target
) {
IRubyObject
value
=
cachedValue
;
// Store to temp so it does null out on us mid-stream
return
isCached
(
context
,
target
,
value
) ?
value
:
reCache
(
context
,
target
);
}
private
boolean
isCached
(
ThreadContext
context
,
RubyModule
target
,
IRubyObject
value
) {
// We could probably also detect if LHS value came out of cache and avoid some of this
return
value
!=
null
&&
generation
==
context
.
getRuntime
().
getConstantGeneration
() &&
hash
==
target
.
hashCode
();
}
public
IRubyObject
reCache
(
ThreadContext
context
,
RubyModule
target
) {
int
newGeneration
=
context
.
getRuntime
().
getConstantGeneration
();
IRubyObject
value
=
target
.
fastGetConstantFromNoConstMissing
(
name
);
cachedValue
=
value
;
if
(
value
!=
null
) {
generation
=
newGeneration
;
hash
=
target
.
hashCode
();
}
return
value
;
}
}
Back
|
FazBrowse Home
|
New Git URL