Class: C::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/csquare.rb

Instance Method Summary collapse

Instance Method Details

#depthObject



967
968
969
# File 'lib/csquare.rb', line 967

def depth
  self.expr.depth
end

#recombine!(function, blueprint, type_symbol, return_type = nil) ⇒ Object

Replace some expression with the pattern from Blueprint.



953
954
955
956
957
958
959
960
961
962
963
964
965
# File 'lib/csquare.rb', line 953

def recombine! function, blueprint, type_symbol, return_type=nil

  index_result = self.index.recombine! function, blueprint, type_symbol, :integer
  self.index.replace_with(index_result[0]) unless index_result.nil?

  # Recombine on the right-hand side
  # r_result: ast, return type (or just nil)
  expr_result = self.expr.recombine! function, blueprint, type_symbol, return_type
  self.expr.replace_with(expr_result[0]) unless expr_result.nil?

  # Mostly only need to figure out the return typename
  [self, self.return_typename(function, blueprint)]
end

#return_typename(function, blueprint) ⇒ Object



947
948
949
950
# File 'lib/csquare.rb', line 947

def return_typename function, blueprint
  t = function.type_of(self.expr.name, blueprint)
  t.is_a?(C::Pointer) || t.is_a?(C::Array) ? t.type.name : t.name
end