Class: Rsense::Server::Command::AliasNativeMethod

Inherits:
Java::org.cx4a.rsense.typing.runtime::SpecialMethod
  • Object
show all
Defined in:
lib/rsense/server/command/alias_native_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAliasNativeMethod

Returns a new instance of AliasNativeMethod.



12
13
14
# File 'lib/rsense/server/command/alias_native_method.rb', line 12

def initialize
  super
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



10
11
12
# File 'lib/rsense/server/command/alias_native_method.rb', line 10

def context
  @context
end

Instance Method Details

#call(runtime, receivers, args, blcck, result) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rsense/server/command/alias_native_method.rb', line 16

def call(runtime, receivers, args, blcck, result)
  callNextMethod = true
  if args
    receivers.each do |receiver|
      callNextMethod = false
      new_name = Java::org.cx4a.rsense.typing.vertex::Vertex.getStringOrSymbol(args[0])
      if args.size > 1
        old_name = Java::org.cx4a.rsense.typing.vertex::Vertex.getStringOrSymbol(args[1])
      end
      rsense_module = receiver
      visibility = Java::org.cx4a.rsense.ruby::Visibility::PUBLIC
      if old_name && new_name
        rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation = Rsense::Server::Command::RsenseMethod.make_method(rsense_module, old_name, visibility, args.first.node.parent)
        rsense_method = Rsense::Server::Command::RsenseMethod.new(rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation)
        rsense_module.addMethod(old_name, rsense_method)
        rsense_module.addMethod(new_name, Java::org.cx4a.rsense.typing.runtime::AliasMethod.new(new_name, rsense_method))
      else
        rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation = Rsense::Server::Command::RsenseMethod.make_method(rsense_module, new_name, visibility, args.first.node.closest_module)
        rsense_method = Rsense::Server::Command::RsenseMethod.new(rcbase, rname, rbodyNode, rargsNode, rvisibility, rlocation)
        rsense_module.addMethod(new_name, rsense_method)
      end
    end
  end
  result.setCallNextMethod(callNextMethod)
end