Class | RDoc::TopLevel |
In: |
code_objects.rb
parsers/parse_f95.rb |
Parent: | Context |
Extend TopLevel class for parse_f95.rb. Original class is defined in code_objects.rb.
diagram | [RW] | |
file_absolute_name | [RW] | |
file_relative_name | [RW] | |
file_stat | [RW] |
# File code_objects.rb, line 741 741: def TopLevel.all_classes_and_modules 742: @@all_classes.values + @@all_modules.values 743: end
moved to parse_f95.rb #
!# !# def TopLevel.all_files !# @@all_files !# end !#
moved to parse_f95.rb #
# File code_objects.rb, line 755 755: def TopLevel.find_class_named(name) 756: @@all_classes.each_value do |c| 757: res = c.find_class_named(name) 758: return res if res 759: end 760: nil 761: end
# File parsers/parse_f95.rb, line 582 582: def initialize(file_name) 583: super() 584: @name = "TopLevel" 585: @file_relative_name = file_name 586: @file_absolute_name = file_name 587: @file_stat = File.stat(file_name) 588: @diagram = nil 589: @@all_files[file_name] = self 590: end
# File code_objects.rb, line 699 699: def initialize(file_name) 700: super() 701: @name = "TopLevel" 702: @file_relative_name = file_name 703: @file_absolute_name = file_name 704: @file_stat = File.stat(file_name) 705: @diagram = nil 706: #!# @@all_files[file_name] = self 707: end
# File parsers/parse_f95.rb, line 576 576: def TopLevel::reset 577: @@all_classes = {} 578: @@all_modules = {} 579: @@all_files = {} 580: end
Adding a class or module to a TopLevel is special, as we only want one copy of a particular top-level class. For example, if both file A and file B implement class C, we only want one ClassModule object for C. This code arranges to share classes and modules between files.
# File code_objects.rb, line 719 719: def add_class_or_module(collection, class_type, name, superclass) 720: cls = collection[name] 721: if cls 722: puts "Reusing class/module #{name}" if $DEBUG 723: else 724: if class_type == NormalModule 725: all = @@all_modules 726: else 727: all = @@all_classes 728: end 729: cls = all[name] 730: if !cls 731: cls = class_type.new(name, superclass) 732: all[name] = cls unless @done_documenting 733: end 734: puts "Adding class/module #{name} to #@name" if $DEBUG 735: collection[name] = cls unless @done_documenting 736: cls.parent = self 737: end 738: cls 739: end
# File code_objects.rb, line 767 767: def find_class_or_module_named(symbol) 768: @@all_classes.each_value {|c| return c if c.name == symbol} 769: @@all_modules.each_value {|m| return m if m.name == symbol} 770: nil 771: end
# File parsers/parse_f95.rb, line 600 600: def find_class_or_module_named(symbol, ignore_case=nil) 601: if !ignore_case 602: @@all_classes.each_value {|c| return c if c.name == symbol} 603: @@all_modules.each_value {|m| return m if m.name == symbol} 604: else 605: @@all_classes.each_value {|c| return c if c.name.upcase == symbol.upcase} 606: @@all_modules.each_value {|m| return m if m.name.upcase == symbol.upcase} 607: end 608: nil 609: end
Find a named file
# File parsers/parse_f95.rb, line 617 617: def find_file_named(name, method=nil, ignore_case=nil) 618: return nil unless name 619: result = nil 620: @@all_files.each{|file_name, toplevel| 621: result = toplevel if file_name == name 622: } 623: dir = File.dirname(@file_relative_name) 624: @@all_files.each{|file_name, toplevel| 625: if /^#{dir}\/(.*)/ =~ file_name 626: result = toplevel if $1 == name 627: end 628: } 629: if result 630: if method 631: result_method = result.find_local_symbol(method, ignore_case) 632: return result_method 633: else 634: return result 635: end 636: else 637: return nil 638: end 639: end
# File code_objects.rb, line 763 763: def find_local_symbol(symbol) 764: find_class_or_module_named(symbol) || super 765: end
# File parsers/parse_f95.rb, line 596 596: def find_local_symbol(symbol, ignore_case=nil) 597: find_class_or_module_named(symbol, ignore_case) || super 598: end
Find a named module
# File code_objects.rb, line 774 774: def find_module_named(name) 775: find_class_or_module_named(name) || find_enclosing_module_named(name) 776: end