Class: Ikra::Symbolic::ArrayIdentityCommand

Inherits:
Object
  • Object
show all
Includes:
ArrayCommand
Defined in:
lib/symbolic/visitor.rb,
lib/symbolic/symbolic.rb

Constant Summary collapse

Block =
Proc.new do |element|
    element
end
@@unique_id =
1

Instance Attribute Summary collapse

Attributes included from ArrayCommand

#unique_id

Instance Method Summary collapse

Methods included from ArrayCommand

#[], #ast, #block_parameter_names, #lexical_externals, #pmap, #to_command

Constructor Details

#initialize(target) ⇒ ArrayIdentityCommand

Returns a new instance of ArrayIdentityCommand.



191
192
193
194
195
196
197
198
# File 'lib/symbolic/symbolic.rb', line 191

def initialize(target)
    super()

    @target = target

    # Ensure that base array cannot be modified
    target.freeze
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



183
184
185
# File 'lib/symbolic/symbolic.rb', line 183

def target
  @target
end

Instance Method Details

#accept(visitor) ⇒ Object



22
23
24
# File 'lib/symbolic/visitor.rb', line 22

def accept(visitor)
    visitor.visit_array_identity_command(self)
end

#base_typeObject



213
214
215
216
217
218
219
220
221
222
# File 'lib/symbolic/symbolic.rb', line 213

def base_type
    # TODO: add caching (@target is frozen)
    type = Types::UnionType.new

    @target.each do |element|
        type.expand_with_singleton_type(element.class.to_ikra_type)
    end

    type
end

#executeObject



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

def execute
    @target
end

#externalsObject

Returns a collection of external objects that are accessed within a parallel section. This includes all elements of the base array.



209
210
211
# File 'lib/symbolic/symbolic.rb', line 209

def externals
    lexical_externals.keys + @target
end

#sizeObject



204
205
206
# File 'lib/symbolic/symbolic.rb', line 204

def size
    @target.size
end