Class: Rubex::AST::TopStatement::CFunctionDef

Inherits:
MethodDef
  • Object
show all
Defined in:
lib/rubex/ast/top_statement/method_def/c_function_def.rb

Instance Attribute Summary collapse

Attributes inherited from MethodDef

#arg_list, #entry, #name, #scope, #self_name, #statements

Instance Method Summary collapse

Methods inherited from MethodDef

#rescan_declarations

Methods included from Helpers::Writers

#declare_carrays, #declare_ruby_objects, #declare_temps, #declare_types, #declare_vars, #sue_footer, #sue_header, #write_char_2_ruby_str_code, #write_char_2_ruby_str_header, #write_usability_functions_code, #write_usability_functions_header, #write_usability_macros

Constructor Details

#initialize(type, return_ptr_level, name, arg_list, function_tags, statements) ⇒ CFunctionDef

Returns a new instance of CFunctionDef.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 7

def initialize(type, return_ptr_level, name, arg_list, function_tags, statements)
  super(name, arg_list, statements)
  @type = type
  @return_ptr_level = return_ptr_level
  @function_tags = function_tags
  @no_gil = false
  if @function_tags == "no_gil"
    @no_gil = true
  end
end

Instance Attribute Details

#no_gilObject (readonly)

Returns the value of attribute no_gil.



5
6
7
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 5

def no_gil
  @no_gil
end

#return_ptr_levelObject (readonly)

Returns the value of attribute return_ptr_level.



5
6
7
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 5

def return_ptr_level
  @return_ptr_level
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 5

def type
  @type
end

Instance Method Details

#analyse_statement(outer_scope, extern: false) ⇒ Object



18
19
20
21
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 18

def analyse_statement(outer_scope, extern: false)
  super(outer_scope)
  @entry.no_gil = @no_gil
end

#generate_code(code) ⇒ Object



23
24
25
26
27
28
# File 'lib/rubex/ast/top_statement/method_def/c_function_def.rb', line 23

def generate_code(code)
  code.write_c_method_header(type: @entry.type.type.to_s,
                             c_name: @entry.c_name,
                             args: Helpers.create_arg_arrays(@arg_list))
  super code, c_function: true
end