class Archruby::Ruby::TypeInference::Ruby::ParserForTypeinference
Attributes
dependencies[R]
method_definitions[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 12 def initialize super() @current_scope = LocalScope.new @current_dependency_class = [] @current_dependency_class_name = nil @current_class = nil @module_names = [] @complete_class_name = [] @classes = [] @current_class = [] @method_definitions = [] @dependencies = [] end
Public Instance Methods
add_dependencies(args = nil, method_calls = nil, class_name = nil)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 153 def add_dependencies(args = nil, method_calls = nil, class_name = nil) return if @current_class.last.nil? class_dependency = ClassDependency.new(@classes.last) if class_name class_dependency.add_dependency(class_name) end if args args.each do |key, value| if value.length > 0 #it is a set object class_dependency.add_dependency(value.first) end end end if method_calls method_calls.each do |method_call| class_dependency.add_dependency(method_call.class_name) end end @dependencies << class_dependency end
add_method_definition(method_name, args, method_calls)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 144 def add_method_definition(method_name, args, method_calls) @method_definitions << MethodDefinition.new( @classes.last, method_name, args, method_calls ) end
build_full_name(const_name)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 74 def build_full_name(const_name) @current_dependency_class.unshift(const_name) full_class_path = @current_dependency_class.join('::') @current_dependency_class = [] full_class_path end
get_complete_class_name(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 109 def get_complete_class_name exp if exp[0] == :const _, const_name = exp @complete_class_name.unshift const_name return else _, first_part, last_constant_part = exp if ( _ == :colon3 ) process(exp) else @complete_class_name.unshift(last_constant_part) get_complete_class_name first_part end end end
parse(content)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 26 def parse(content) ast = ruby_parser.parse(content) process(ast) [@dependencies, @method_definitions] end
populate_scope_with_formal_parameters(args)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 174 def populate_scope_with_formal_parameters(args) if !args.empty? args.each do |key, value| #value it is a set object @current_scope.add_formal_parameter(key, value.first) end end end
process_alias(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 282 def process_alias(exp) end
process_and(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 203 def process_and(exp) _, left_side, right_side = exp process(left_side) process(right_side) end
process_array(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 194 def process_array(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_attrasgn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 395 def process_attrasgn(exp) _, receiver, method, arg, value = exp process(receiver) process(value) end
process_begin(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 360 def process_begin(exp) end
process_block(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 32 def process_block(exp) _, *args = exp args.map! { |subtree| process(subtree) } end
process_block_pass(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 265 def process_block_pass(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_break(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 442 def process_break(exp) end
process_call(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 46 def process_call(exp) _, receiver, method_name, *args = exp process(receiver) args.map! { |subtree| process(subtree) } end
process_case(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 215 def process_case(exp) _, condition, when_part, ensure_part = exp process(condition) process(when_part) process(ensure_part) end
process_cdecl(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 186 def process_cdecl(exp) end
process_class(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 89 def process_class exp _, class_name, *args = exp if class_name.class == Symbol if !@module_names.empty? @classes << "#{@module_names.join("::")}::#{class_name}" else @classes << class_name.to_s end @current_class << @classes.last else # cai aqui quando a definicao é algo do tipo: class Teste::De end get_complete_class_name class_name @classes << @complete_class_name.join("::") @complete_class_name = [] @current_class << @classes.last end args.map! {|sub_tree| process(sub_tree) if sub_tree.class == Sexp} @current_class.pop end
process_colon2(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 62 def process_colon2(exp) _, first_part, last_part = exp @current_dependency_class.unshift(last_part) process(first_part) end
process_colon3(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 68 def process_colon3(exp) _, constant_name = exp const_name = build_full_name("::#{constant_name}") add_dependencies(nil, nil, const_name) end
process_const(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 52 def process_const(exp) _, const_name = exp if !@current_dependency_class.empty? @current_dependency_class_name = build_full_name(const_name) else @current_dependency_class_name = const_name.to_s end add_dependencies(nil, nil, @current_dependency_class_name) end
process_cvar(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 438 def process_cvar(exp) # class variable end
process_cvdecl(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 366 def process_cvdecl(exp) _, instance_classvar_name, *value = exp value.map! {|sub_tree| process(sub_tree)} end
process_defined(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 371 def process_defined(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_defn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 125 def process_defn(exp) _, method_name, method_arguments, *method_body = exp @current_scope.add_new_scope args = ProcessMethodArguments.new(method_arguments).parse populate_scope_with_formal_parameters(args) method_calls = ProcessMethodBody.new(method_body, @current_scope).parse add_method_definition(method_name, args, method_calls) add_dependencies(args, method_calls) @current_scope.remove_scope end
process_defs(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 136 def process_defs(exp) #transformando em um defn without_node_type = exp[2..-1].to_a without_node_type.unshift(:defn) new_sexp = Sexp.from_array(without_node_type) process_defn(new_sexp) end
process_dot2(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 300 def process_dot2(exp) _, left, right = exp process(left) process(right) end
process_dregx(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 234 def process_dregx(exp) _, str, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_dregx_once(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 239 def process_dregx_once(exp) _, start, *args = exp args.map! {|sub_tree| process(sub_tree) if sub_tree.class == Sexp} end
process_dstr(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 448 def process_dstr(exp) # string dinamica, pode ser interessante se # quisermos pegar alguma coisa dentro delas end
process_dsym(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 384 def process_dsym(exp) _, str, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_dxstr(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 249 def process_dxstr(exp) _, str, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_ensure(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 260 def process_ensure(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_evstr(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 244 def process_evstr(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_false(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 457 def process_false(exp) end
process_for(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 339 def process_for(exp) _, x, y, body = exp process(x) process(y) process(body) end
process_gasgn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 433 def process_gasgn(exp) _, global_var_name, *value = exp value.map! {|sub_tree| process(sub_tree)} end
process_gvar(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 199 def process_gvar(exp) #global variables end
process_hash(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 417 def process_hash(exp) _, key, value = exp process(key) process(value) end
process_iasgn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 379 def process_iasgn(exp) _, instance_varialbe_name, *value = exp value.map! { |subtree| process(subtree) } end
process_if(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 189 def process_if(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree) if sub_tree.class == Sexp } end
process_iter(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 406 def process_iter(exp) _, first_part, second_part, *body = exp process(first_part) body.map! {|sub_tree| process(sub_tree)} end
process_ivar(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 285 def process_ivar(exp) _, var_name, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_lasgn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 37 def process_lasgn(exp) _, variable_name, *args = exp args.map! { |subtree| process(subtree) } if @current_dependency_class_name @current_scope.add_variable(variable_name, @current_dependency_class_name) end @current_dependency_class_name = nil end
process_lit(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 183 def process_lit(exp) end
process_lvar(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 353 def process_lvar(exp) #chamado para pegar o valor end
process_masgn(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 311 def process_masgn(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_match2(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 316 def process_match2(exp) _, rec, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_match3(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 321 def process_match3(exp) _, first, second = exp process(first) process(second) end
process_module(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 81 def process_module(exp) _, module_name, *args = exp if module_name.class == Symbol @module_names.push(module_name.to_s) end args.map! {|sub_tree| process(sub_tree)} end
process_next(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 279 def process_next(exp) end
process_nil(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 463 def process_nil(exp) end
process_not(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 295 def process_not(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_nth_ref(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 445 def process_nth_ref(exp) end
process_op_asgn1(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 423 def process_op_asgn1(exp) _, receiver, arg, method_name, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_op_asgn2(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 270 def process_op_asgn2(exp) _, receiver, method, met, last = exp process(receiver) process(last) end
process_op_asgn_or(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 428 def process_op_asgn_or(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_or(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 209 def process_or(exp) _, left_side, right_side = exp process(left_side) process(right_side) end
process_postexe(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 376 def process_postexe(exp) end
process_resbody(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 254 def process_resbody(exp) _, body, resbody = exp process(body) process(resbody) end
process_rescue(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 228 def process_rescue(exp) _, body, rescbody = exp process(body) process(rescbody) end
process_retry(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 363 def process_retry(exp) end
process_return(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 276 def process_return(exp) end
process_sclass(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 412 def process_sclass(exp) _, singleton_class, *body = exp body.map! {|sub_tree| process(sub_tree)} end
process_self(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 460 def process_self(exp) end
process_splat(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 401 def process_splat(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_str(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 357 def process_str(exp) end
process_super(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 392 def process_super(exp) end
process_svalue(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 290 def process_svalue(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_to_ary(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 306 def process_to_ary(exp) _, *args = exp args.map! {|sub_tree| process(sub_tree)} end
process_true(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 454 def process_true(exp) end
process_undef(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 389 def process_undef(exp) end
process_until(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 333 def process_until(exp) _, condition, body = exp process(condition) process(body) end
process_valias(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 346 def process_valias(exp) end
process_when(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 222 def process_when(exp) _, condition, body = exp process(condition) process(body) end
process_while(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 327 def process_while(exp) _, condition, body = exp process(condition) process(body) end
process_xstr(exp)
click to toggle source
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 350 def process_xstr(exp) end
ruby_parser()
click to toggle source
def process_sclass
(exp)
binding.pry
end
# File lib/archruby/ruby/type_inference/ruby/parser_for_typeinference.rb, line 470 def ruby_parser RubyParser.new end