Class: Lisp::NativeObject
Instance Attribute Summary
Attributes inherited from Atom
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Atom
#alist?, #all?, #apply_to, #car, #cdr, #character?, #class?, #copy, #doc, #eq?, #evaluate, #frame?, #function?, #length, #lisp_object?, #list?, #macro?, #negative?, #number?, #pair?, #positive?, #primitive?, #print_string, #quoted, #set!, #special?, #string?, #symbol?, #vector?, #zero?
Constructor Details
Returns a new instance of NativeObject.
28
29
30
|
# File 'lib/rubylisp/object.rb', line 28
def initialize(o=nil)
@value = o
end
|
Class Method Details
.new_instance_of(c) ⇒ Object
20
21
22
|
# File 'lib/rubylisp/object.rb', line 20
def self.new_instance_of(c)
self.new(c.alloc.init)
end
|
.with_value(o) ⇒ Object
24
25
26
|
# File 'lib/rubylisp/object.rb', line 24
def self.with_value(o)
self.new(o)
end
|
.wrap_impl(args, env) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/rubylisp/object.rb', line 9
def self.wrap_impl(args, env)
raise "wrap-object requires 1 argument" unless args.length == 1
raw_val = args.car.evaluate(env)
val = if raw_val.list?
raw_val.to_a
else
raw_val
end
NativeObject.with_value(val)
end
|
Instance Method Details
56
57
58
|
# File 'lib/rubylisp/object.rb', line 56
def false?
@value == nil
end
|
#native_type ⇒ Object
44
45
46
|
# File 'lib/rubylisp/object.rb', line 44
def native_type
@value.class
end
|
36
37
38
|
# File 'lib/rubylisp/object.rb', line 36
def object?
true
end
|
48
49
50
|
# File 'lib/rubylisp/object.rb', line 48
def to_s
"<a #{@value.class}: #{@value}>"
end
|
52
53
54
|
# File 'lib/rubylisp/object.rb', line 52
def true?
@value != nil
end
|
40
41
42
|
# File 'lib/rubylisp/object.rb', line 40
def type
:object
end
|
#with_value(&block) ⇒ Object
32
33
34
|
# File 'lib/rubylisp/object.rb', line 32
def with_value(&block)
block.call(@value)
end
|