Class: Rubex::AST::Expression::StructOrUnionMemberCall

Inherits:
CommandCall show all
Defined in:
lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb

Direct Known Subclasses

ElementRefMemberCall

Instance Attribute Summary

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from CommandCall

#generate_assignment_code, #generate_disposal_code, #initialize

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #expression?, #from_ruby_object, #generate_and_dispose_subexprs, #generate_assignment_code, #generate_disposal_code, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object

Constructor Details

This class inherits a constructor from Rubex::AST::Expression::CommandCall

Instance Method Details

#analyse_types(local_scope) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb', line 5

def analyse_types(local_scope)
  scope = @expr.type.base_type.scope

  if @command.is_a? String
    @command = Expression::Name.new @command
    @command.analyse_types scope
  elsif @command.is_a? Rubex::AST::Expression::ElementRef
    @command = Expression::ElementRefMemberCall.new @expr, @command, @arg_list
    @command.analyse_types local_scope, scope
  end
  @has_temp = @command.has_temp
  @type = @command.type
  @subexprs = [@expr, @command]
end

#c_code(_local_scope) ⇒ Object



32
33
34
# File 'lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb', line 32

def c_code(_local_scope)
  @c_code
end

#generate_evaluation_code(code, local_scope) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb', line 20

def generate_evaluation_code code, local_scope
  @expr.generate_evaluation_code code, local_scope
  @command.generate_evaluation_code code, local_scope
  @c_code =
    if @command.has_temp
      @command.c_code(local_scope)
    else
      op = @expr.type.cptr? ? '->' : '.'
      "#{@expr.c_code(local_scope)}#{op}#{@command.c_code(local_scope)}"
    end
end