Class: So::Index

Inherits:
Expr show all
Defined in:
lib/spec_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expr

#!, #<, #==, #>, #[], #assert_time, #assert_value, #to_so_expr

Constructor Details

#initialize(x, index) ⇒ Index

Returns a new instance of Index.



180
181
182
183
# File 'lib/spec_object.rb', line 180

def initialize(x, index)
  @x = x
  @index = index
end

Class Method Details

.index(x, index) ⇒ Object



185
186
187
188
189
190
191
192
193
194
# File 'lib/spec_object.rb', line 185

def self.index(x, index)
  x = x.to_so_expr
  index = index.to_so_expr

  if x.kind_of?(Const) && index.kind_of?(Const)
    (x.value[index.value]).to_so_expr
  else
    new(x, index)
  end
end

Instance Method Details

#pp(n) ⇒ Object



196
197
198
# File 'lib/spec_object.rb', line 196

def pp(n)
  "#{@x.pp(n)}[#{@index.pp(0)}]"
end

#substitute(v, e) ⇒ Object



200
201
202
# File 'lib/spec_object.rb', line 200

def substitute(v, e)
  Index.index(@x.substitute(v, e), @index.substitute(v, e))
end