Class: TypeProf::Core::AST::AttrReaderMetaNode

Inherits:
Node
  • Object
show all
Defined in:
lib/typeprof/core/ast/meta.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#changes, #lenv, #prev_node, #ret, #static_ret

Instance Method Summary collapse

Methods inherited from Node

#boxes, #code_range, #define, #define0, #define_copy, #diagnostics, #diff, #each_subnode, #get_vertexes, #install, #install_copy, #modified_vars, #pretty_print_instance_variables, #retrieve_at, #subnodes, #traverse, #undefine, #undefine0, #uninstall

Constructor Details

#initialize(raw_node, lenv) ⇒ AttrReaderMetaNode

Returns a new instance of AttrReaderMetaNode.



48
49
50
51
52
53
54
55
56
# File 'lib/typeprof/core/ast/meta.rb', line 48

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



58
59
60
# File 'lib/typeprof/core/ast/meta.rb', line 58

def args
  @args
end

Instance Method Details

#attrsObject



60
# File 'lib/typeprof/core/ast/meta.rb', line 60

def attrs = { args: }

#install0(genv) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/typeprof/core/ast/meta.rb', line 76

def install0(genv)
  @args.each do |arg|
    ivar_name = :"@#{ arg }"
    ivar_box = @changes.add_ivar_read_box(genv, @lenv.cref.cpath, false, ivar_name)
    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])
  end
  Source.new
end

#mname_code_range(name) ⇒ Object



70
71
72
73
74
# File 'lib/typeprof/core/ast/meta.rb', line 70

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

#opt_keywordsObject



67
# File 'lib/typeprof/core/ast/meta.rb', line 67

def opt_keywords = []

#opt_positionalsObject



63
# File 'lib/typeprof/core/ast/meta.rb', line 63

def opt_positionals = []

#post_positionalsObject



64
# File 'lib/typeprof/core/ast/meta.rb', line 64

def post_positionals = []

#req_keywordsObject



66
# File 'lib/typeprof/core/ast/meta.rb', line 66

def req_keywords = []

#req_positionalsObject



62
# File 'lib/typeprof/core/ast/meta.rb', line 62

def req_positionals = []

#rest_keywordsObject



68
# File 'lib/typeprof/core/ast/meta.rb', line 68

def rest_keywords = nil

#rest_positionalsObject



65
# File 'lib/typeprof/core/ast/meta.rb', line 65

def rest_positionals = nil