Class: Rubex::AST::TopStatement::RubyMethodDef

Inherits:
MethodDef
  • Object
show all
Defined in:
lib/rubex/ast/top_statement.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

Constructor Details

#initialize(name, arg_list, statements, singleton: false) ⇒ RubyMethodDef

Returns a new instance of RubyMethodDef.



247
248
249
250
# File 'lib/rubex/ast/top_statement.rb', line 247

def initialize name, arg_list, statements, singleton: false
  super(name, arg_list, statements)
  @singleton = singleton
end

Instance Attribute Details

#singletonObject (readonly)

Returns the value of attribute singleton.



245
246
247
# File 'lib/rubex/ast/top_statement.rb', line 245

def singleton
  @singleton
end

Instance Method Details

#==(other) ⇒ Object



263
264
265
266
267
268
# File 'lib/rubex/ast/top_statement.rb', line 263

def == other
  self.class == other.class && @name == other.name &&
  @c_name == other.c_name && @arg_list == other.arg_list &&
  @statements == other.statements && @entry == other.entry &&
  @type == other.type
end

#analyse_statement(local_scope) ⇒ Object



252
253
254
255
# File 'lib/rubex/ast/top_statement.rb', line 252

def analyse_statement local_scope
  super
  @entry.singleton = @singleton
end

#generate_code(code) ⇒ Object



257
258
259
260
261
# File 'lib/rubex/ast/top_statement.rb', line 257

def generate_code code
  code.write_ruby_method_header(type: @entry.type.type.to_s,
    c_name: @entry.c_name)
  super
end