Class: Keisan::AST::Node
- Inherits:
-
Object
show all
- Defined in:
- lib/keisan/ast/node.rb
Instance Method Summary
collapse
Instance Method Details
#%(other) ⇒ Object
105
106
107
108
109
|
# File 'lib/keisan/ast/node.rb', line 105
def %(other)
Modulo.new(
[self, other.to_node]
)
end
|
#&(other) ⇒ Object
131
132
133
|
# File 'lib/keisan/ast/node.rb', line 131
def &(other)
BitwiseAnd.new([self, other.to_node])
end
|
#*(other) ⇒ Object
93
94
95
96
97
|
# File 'lib/keisan/ast/node.rb', line 93
def *(other)
Times.new(
[self, other.to_node]
)
end
|
#**(other) ⇒ Object
127
128
129
|
# File 'lib/keisan/ast/node.rb', line 127
def **(other)
Exponent.new([self, other.to_node])
end
|
#+(other) ⇒ Object
81
82
83
84
85
|
# File 'lib/keisan/ast/node.rb', line 81
def +(other)
Plus.new(
[self, other.to_node]
)
end
|
#+@ ⇒ Object
119
120
121
|
# File 'lib/keisan/ast/node.rb', line 119
def +@
self
end
|
#-(other) ⇒ Object
87
88
89
90
91
|
# File 'lib/keisan/ast/node.rb', line 87
def -(other)
Plus.new(
[self, UnaryMinus.new(other.to_node)]
)
end
|
#-@ ⇒ Object
123
124
125
|
# File 'lib/keisan/ast/node.rb', line 123
def -@
UnaryMinus.new(self)
end
|
#/(other) ⇒ Object
99
100
101
102
103
|
# File 'lib/keisan/ast/node.rb', line 99
def /(other)
Times.new(
[self, UnaryInverse.new(other.to_node)]
)
end
|
#<(other) ⇒ Object
159
160
161
|
# File 'lib/keisan/ast/node.rb', line 159
def <(other)
LogicalLessThan.new([self, other.to_node])
end
|
#<<(other) ⇒ Object
143
144
145
|
# File 'lib/keisan/ast/node.rb', line 143
def <<(other)
BitwiseLeftShift.new([self, other.to_node])
end
|
#>(other) ⇒ Object
151
152
153
|
# File 'lib/keisan/ast/node.rb', line 151
def >(other)
LogicalGreaterThan.new([self, other.to_node])
end
|
#>>(other) ⇒ Object
147
148
149
|
# File 'lib/keisan/ast/node.rb', line 147
def >>(other)
BitwiseRightShift.new([self, other.to_node])
end
|
#^(other) ⇒ Object
135
136
137
|
# File 'lib/keisan/ast/node.rb', line 135
def ^(other)
BitwiseXor.new([self, other.to_node])
end
|
#and(other) ⇒ Object
175
176
177
|
# File 'lib/keisan/ast/node.rb', line 175
def and(other)
LogicalAnd.new([self, other.to_node])
end
|
#coerce(other) ⇒ Object
60
61
62
|
# File 'lib/keisan/ast/node.rb', line 60
def coerce(other)
[other.to_node, self]
end
|
#deep_dup ⇒ Object
20
21
22
|
# File 'lib/keisan/ast/node.rb', line 20
def deep_dup
dup
end
|
#differentiate(variable, context = nil) ⇒ Object
#differentiated(variable, context = nil) ⇒ Object
48
49
50
|
# File 'lib/keisan/ast/node.rb', line 48
def differentiated(variable, context = nil)
deep_dup.differentiate(variable, context)
end
|
#equal(other) ⇒ Object
167
168
169
|
# File 'lib/keisan/ast/node.rb', line 167
def equal(other)
LogicalEqual.new([self, other.to_node])
end
|
#evaluate(context = nil) ⇒ Object
36
37
38
|
# File 'lib/keisan/ast/node.rb', line 36
def evaluate(context = nil)
value(context)
end
|
#evaluate_assignments(context = nil) ⇒ Object
40
41
42
|
# File 'lib/keisan/ast/node.rb', line 40
def evaluate_assignments(context = nil)
self
end
|
#evaluated(context = nil) ⇒ Object
32
33
34
|
# File 'lib/keisan/ast/node.rb', line 32
def evaluated(context = nil)
deep_dup.evaluate(context)
end
|
77
78
79
|
# File 'lib/keisan/ast/node.rb', line 77
def false?
!true?
end
|
#not_equal(other) ⇒ Object
171
172
173
|
# File 'lib/keisan/ast/node.rb', line 171
def not_equal(other)
LogicalNotEqual.new([self, other.to_node])
end
|
#or(other) ⇒ Object
179
180
181
|
# File 'lib/keisan/ast/node.rb', line 179
def or(other)
LogicalOr.new([self, other.to_node])
end
|
#replace(variable, replacement) ⇒ Object
52
53
54
|
# File 'lib/keisan/ast/node.rb', line 52
def replace(variable, replacement)
self
end
|
#replaced(variable, replacement) ⇒ Object
56
57
58
|
# File 'lib/keisan/ast/node.rb', line 56
def replaced(variable, replacement)
deep_dup.replace(variable, replacement)
end
|
#simplified(context = nil) ⇒ Object
24
25
26
|
# File 'lib/keisan/ast/node.rb', line 24
def simplified(context = nil)
deep_dup.simplify(context)
end
|
#simplify(context = nil) ⇒ Object
28
29
30
|
# File 'lib/keisan/ast/node.rb', line 28
def simplify(context = nil)
self
end
|
#to_cell ⇒ Object
68
69
70
|
# File 'lib/keisan/ast/node.rb', line 68
def to_cell
AST::Cell.new(self)
end
|
#to_node ⇒ Object
64
65
66
|
# File 'lib/keisan/ast/node.rb', line 64
def to_node
self
end
|
Will only return False for AST::Boolean(false) and AST::Null
73
74
75
|
# File 'lib/keisan/ast/node.rb', line 73
def true?
true
end
|
#unbound_functions(context = nil) ⇒ Object
12
13
14
|
# File 'lib/keisan/ast/node.rb', line 12
def unbound_functions(context = nil)
Set.new
end
|
#unbound_variables(context = nil) ⇒ Object
8
9
10
|
# File 'lib/keisan/ast/node.rb', line 8
def unbound_variables(context = nil)
Set.new
end
|
#value(context = nil) ⇒ Object
#well_defined?(context = nil) ⇒ Boolean
16
17
18
|
# File 'lib/keisan/ast/node.rb', line 16
def well_defined?(context = nil)
unbound_variables(context).empty? && unbound_functions(context).empty?
end
|
#|(other) ⇒ Object
139
140
141
|
# File 'lib/keisan/ast/node.rb', line 139
def |(other)
BitwiseOr.new([self, other.to_node])
end
|