Class: StatementClass

Inherits:
ClassName show all
Defined in:
lib/core/runtime_class/StatementClass.rb

Instance Method Summary collapse

Methods inherited from ClassName

#describe, #to_literal_string

Methods inherited from Array

#cauldron_method_calls, #contains?, #select_all, #to_declaration, #to_intrinsic, #to_literal, #to_var

Constructor Details

#initializeStatementClass

Returns a new instance of StatementClass.



3
4
5
# File 'lib/core/runtime_class/StatementClass.rb', line 3

def initialize
  super
end

Instance Method Details

#class_method_calls(available = []) ⇒ Object

Returns an array of class methods call for Statement. For example

ClassMethodCallContainer.new(StatementClass.new,New.new(Unknown.new,Equal.new,x))



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/core/runtime_class/StatementClass.rb', line 23

def class_method_calls(available=[])

  # NOTE: I could create a LiteralDeclarationDeclaration
  fixnum_declarations = available.select{|y| y.kind_of?(Literal)}.collect do |x|
    ClassMethodCallContainer.new(
      StatementClass.new,
      New.new,
      ClassMethodCallContainer.new(UnknownClass.new,New.new),
      ClassMethodCallContainer.new(EqualClass.new,New.new),
      InstanceCallContainer.new(x.to_declaration,ToDeclarationCall.new)
    )
  end
  
  # Create ClassMethodCallContainer.new(StatementClass.new,New.new(Unknown.new,Equal.new,InstanceCallContainer.new(unknown_var,StringLength)))
  # TODO  This uses UnknownVariable but we don't know if the UnknownVariable is a string or not
  available_unknown_variables = available.select_all {|x| x.kind_of?(UnknownVariable)}
  string_length_statement = available_unknown_variables.collect do |x|
    ClassMethodCallContainer.new(
      StatementClass.new,
      New.new,
      ClassMethodCallContainer.new(UnknownClass.new,New.new),
      ClassMethodCallContainer.new(EqualClass.new,New.new),
      #InstanceCallContainer.new(x,StringLength.new)
      ClassMethodCallContainer.new(InstanceCallContainerClass.new(),New.new,x, ClassMethodCallContainer.new(StringLengthClass.new,New.new))
    )
  end 
  
  return fixnum_declarations+string_length_statement
end

#copyObject



11
12
13
# File 'lib/core/runtime_class/StatementClass.rb', line 11

def copy
  return StatementClass.new
end

#valueObject



15
16
17
# File 'lib/core/runtime_class/StatementClass.rb', line 15

def value
  return Statement
end

#write(context = nil) ⇒ Object



7
8
9
# File 'lib/core/runtime_class/StatementClass.rb', line 7

def write(context=nil)
  return 'Statement'
end