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 748 748: def initialize(file_name) 749: super() 750: @name = "TopLevel" 751: @file_relative_name = file_name 752: @file_absolute_name = file_name 753: @file_stat = File.stat(file_name) 754: @diagram = nil 755: @@all_files[file_name] = self 756: 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 742 742: def TopLevel::reset 743: @@all_classes = {} 744: @@all_modules = {} 745: @@all_files = {} 746: 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 766 766: def find_class_or_module_named(symbol, ignore_case=nil) 767: if !ignore_case 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: else 771: @@all_classes.each_value {|c| return c if c.name.upcase == symbol.upcase} 772: @@all_modules.each_value {|m| return m if m.name.upcase == symbol.upcase} 773: end 774: nil 775: end
Find a named file
# File parsers/parse_f95.rb, line 783 783: def find_file_named(name, method=nil, ignore_case=nil) 784: return nil unless name 785: result = nil 786: @@all_files.each{|file_name, toplevel| 787: result = toplevel if file_name == name 788: } 789: dir = File.dirname(@file_relative_name) 790: @@all_files.each{|file_name, toplevel| 791: if /^#{dir}\/(.*)/ =~ file_name 792: result = toplevel if $1 == name 793: end 794: } 795: if result 796: if method 797: result_method = result.find_local_symbol(method, ignore_case) 798: return result_method 799: else 800: return result 801: end 802: else 803: return nil 804: end 805: 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 762 762: def find_local_symbol(symbol, ignore_case=nil) 763: find_class_or_module_named(symbol, ignore_case) || super 764: 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