Skip to content

Commit 6026ead

Browse files
committed
[GR-17457] Remove ImmediateValue
PullRequest: truffleruby/2482
2 parents 2e22010 + 76d43c2 commit 6026ead

File tree

12 files changed

+93
-84
lines changed

12 files changed

+93
-84
lines changed

lib/truffle/truffle/cext_structs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def RDATA(object)
2323
end
2424

2525
def RBASIC(object)
26-
if ImmediateValue === object
26+
if Primitive.immediate_value?(object)
2727
raise TypeError, "immediate values don't include the RBasic struct"
2828
end
2929
RBasic.new(object)

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@ public boolean isTruffleBootMainMethod(SharedMethodInfo info) {
10131013
"/core/splitter.rb",
10141014
"/core/stat.rb",
10151015
"/core/io.rb",
1016-
"/core/immediate.rb",
10171016
"/core/proc.rb",
10181017
"/core/enumerable_helper.rb",
10191018
"/core/enumerable.rb",

src/main/java/org/truffleruby/core/support/TypeNodes.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.truffleruby.core.string.StringNodes;
3939
import org.truffleruby.core.string.StringUtils;
4040
import org.truffleruby.core.symbol.RubySymbol;
41+
import org.truffleruby.language.Nil;
4142
import org.truffleruby.language.NotProvided;
4243
import org.truffleruby.language.RubyDynamicObject;
4344
import org.truffleruby.language.RubyNode;
@@ -122,6 +123,46 @@ protected boolean objectEqual(Object a, Object b,
122123

123124
}
124125

126+
@Primitive(name = "immediate_value?")
127+
public static abstract class IsImmediateValueNode extends PrimitiveArrayArgumentsNode {
128+
129+
@Specialization
130+
protected boolean doBoolean(boolean value) {
131+
return true;
132+
}
133+
134+
@Specialization
135+
protected boolean doInt(int value) {
136+
return true;
137+
}
138+
139+
@Specialization
140+
protected boolean doLong(long value) {
141+
return true;
142+
}
143+
144+
@Specialization
145+
protected boolean doFloat(double value) {
146+
return true;
147+
}
148+
149+
@Specialization
150+
protected boolean doSymbol(RubySymbol value) {
151+
return true;
152+
}
153+
154+
@Specialization
155+
protected boolean doNil(Nil value) {
156+
return true;
157+
}
158+
159+
@Fallback
160+
protected boolean doFallback(Object value) {
161+
return false;
162+
}
163+
164+
}
165+
125166
@Primitive(name = "nil?")
126167
public static abstract class IsNilNode extends PrimitiveArrayArgumentsNode {
127168

src/main/ruby/truffleruby/core/false.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def inspect
3939
end
4040

4141
alias_method :===, :===
42+
43+
class << self
44+
undef_method :new
45+
end
46+
47+
def self.__allocate__
48+
raise TypeError, "allocator undefined for #{self}"
49+
end
4250
end
4351

4452
FALSE = false

src/main/ruby/truffleruby/core/float.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,12 @@ def coerce(other)
260260
def finite?
261261
not (nan? or infinite?)
262262
end
263+
264+
class << self
265+
undef_method :new
266+
end
267+
268+
def self.__allocate__
269+
raise TypeError, "allocator undefined for #{self}"
270+
end
263271
end

src/main/ruby/truffleruby/core/immediate.rb

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/main/ruby/truffleruby/core/integer.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,12 @@ def self.sqrt(n)
354354
end
355355
self
356356
end
357+
358+
class << self
359+
undef_method :new
360+
end
361+
362+
def self.__allocate__
363+
raise TypeError, "allocator undefined for #{self}"
364+
end
357365
end

src/main/ruby/truffleruby/core/marshal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def const_lookup(name, type = nil)
542542
end
543543

544544
def add_non_immediate_object(obj)
545-
return if Primitive.object_kind_of? obj, ImmediateValue
545+
return if Primitive.immediate_value?(obj)
546546
add_object(obj)
547547
end
548548

src/main/ruby/truffleruby/core/nil.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ def to_h
7878
end
7979

8080
alias_method :===, :===
81+
82+
class << self
83+
undef_method :new
84+
end
85+
86+
def self.__allocate__
87+
raise TypeError, "allocator undefined for #{self}"
88+
end
8189
end
8290

8391
NIL = nil

src/main/ruby/truffleruby/core/symbol.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ def [](index, other = undefined)
159159

160160
# Use equal? for ===
161161
alias_method :===, :equal?
162+
163+
class << self
164+
undef_method :new
165+
end
166+
167+
def self.__allocate__
168+
raise TypeError, "allocator undefined for #{self}"
169+
end
162170
end
163171

164172
module Truffle::SymbolOperations

0 commit comments

Comments
 (0)