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 655 655: def initialize(file_name) 656: super() 657: @name = "TopLevel" 658: @file_relative_name = file_name 659: @file_absolute_name = file_name 660: @file_stat = File.stat(file_name) 661: @diagram = nil 662: @@all_files[file_name] = self 663: 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 649 649: def TopLevel::reset 650: @@all_classes = {} 651: @@all_modules = {} 652: @@all_files = {} 653: 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 673 673: def find_class_or_module_named(symbol, ignore_case=nil) 674: if !ignore_case 675: @@all_classes.each_value {|c| return c if c.name == symbol} 676: @@all_modules.each_value {|m| return m if m.name == symbol} 677: else 678: @@all_classes.each_value {|c| return c if c.name.upcase == symbol.upcase} 679: @@all_modules.each_value {|m| return m if m.name.upcase == symbol.upcase} 680: end 681: nil 682: end
Find a named file
# File parsers/parse_f95.rb, line 690 690: def find_file_named(name, method=nil, ignore_case=nil) 691: return nil unless name 692: result = nil 693: @@all_files.each{|file_name, toplevel| 694: result = toplevel if file_name == name 695: } 696: dir = File.dirname(@file_relative_name) 697: @@all_files.each{|file_name, toplevel| 698: if /^#{dir}\/(.*)/ =~ file_name 699: result = toplevel if $1 == name 700: end 701: } 702: if result 703: if method 704: result_method = result.find_local_symbol(method, ignore_case) 705: return result_method 706: else 707: return result 708: end 709: else 710: return nil 711: end 712: 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 669 669: def find_local_symbol(symbol, ignore_case=nil) 670: find_class_or_module_named(symbol, ignore_case) || super 671: 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