class TypeProf::Core::AST::IncludeMetaNode::AttrReaderMetaNode::AttrAccessorMetaNode - typeprof: Ruby Standard Library Documentation

# class TypeProf::Core::AST::IncludeMetaNode::AttrReaderMetaNode::AttrAccessorMetaNode

### Attributes

args[R]

### Public Class Methods

new(raw_node, lenv) click to toggle source
Calls superclass method `TypeProf::Core::AST::Node::new`

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 89
    def initialize(raw_node, lenv)
      super(raw_node, lenv)
      @args = []
      raw_node.arguments.arguments.each do |raw_arg|
        @args << raw_arg.value.to_sym if raw_arg.type == :symbol_node
      end
      # TODO: error for non-LIT
      # TODO: fine-grained hover
    end

### Public Instance Methods

attrs(= { args: }) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 101
      def attrs = { args: }

      def mname_code_range(name)
        idx = @args.index(name.to_sym) # TODO: support string args
        node = @raw_node.arguments.arguments[idx].location
        TypeProf::CodeRange.from_node(node)
      end

      def define0(genv)
        @args.map do |arg|
          mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
          mod.add_def(self)
          mod
        end
      end

      def define_copy(genv)
        @args.map do |arg|
          mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
          mod.add_def(self)
          mod.remove_def(@prev_node)
          mod
        end
        super(genv)
      end

      def undefine0(genv)
        @args.each do |arg|
          mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
          mod.remove_def(self)
        end
      end

      def install0(genv)
        @args.zip(@static_ret) do |arg, ive|
          ivar_box = @changes.add_ivar_read_box(genv, @lenv.cref.cpath, false, :"@#{ arg }")
          e_ret = Vertex.new(self)
          ret_box = @changes.add_escape_box(genv, ivar_box.ret, e_ret)
          @changes.add_method_def_box(genv, @lenv.cref.cpath, false, arg, FormalArguments::Empty, [ret_box])

          vtx = Vertex.new(self)
          @changes.add_edge(genv, vtx, ive.vtx)
          f_args = FormalArguments.new([vtx], [], nil, [], [], [], nil, nil)
          @changes.add_method_def_box(genv, @lenv.cref.cpath, false, :"#{ arg }=", f_args, [ret_box])
        end
        Source.new
      end
    end

define0(genv) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 109
    def define0(genv)
      @args.map do |arg|
        mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
        mod.add_def(self)
        mod
      end
    end

define_copy(genv) click to toggle source
Calls superclass method `TypeProf::Core::AST::Node#define_copy`

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 117
    def define_copy(genv)
      @args.map do |arg|
        mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
        mod.add_def(self)
        mod.remove_def(@prev_node)
        mod
      end
      super(genv)
    end

install0(genv) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 134
    def install0(genv)
      @args.zip(@static_ret) do |arg, ive|
        ivar_box = @changes.add_ivar_read_box(genv, @lenv.cref.cpath, false, :"@#{ arg }")
        e_ret = Vertex.new(self)
        ret_box = @changes.add_escape_box(genv, ivar_box.ret, e_ret)
        @changes.add_method_def_box(genv, @lenv.cref.cpath, false, arg, FormalArguments::Empty, [ret_box])

        vtx = Vertex.new(self)
        @changes.add_edge(genv, vtx, ive.vtx)
        f_args = FormalArguments.new([vtx], [], nil, [], [], [], nil, nil)
        @changes.add_method_def_box(genv, @lenv.cref.cpath, false, :"#{ arg }=", f_args, [ret_box])
      end
      Source.new
    end

mname_code_range(name) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 103
    def mname_code_range(name)
      idx = @args.index(name.to_sym) # TODO: support string args
      node = @raw_node.arguments.arguments[idx].location
      TypeProf::CodeRange.from_node(node)
    end

undefine0(genv) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/ast/meta.rb, line 127
    def undefine0(genv)
      @args.each do |arg|
        mod = genv.resolve_ivar(lenv.cref.cpath, false, :"@#{ arg }")
        mod.remove_def(self)
      end
    end