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 625 625: def TopLevel.all_classes_and_modules 626: @@all_classes.values + @@all_modules.values 627: end
moved to parse_f95.rb #
!# !# def TopLevel.all_files !# @@all_files !# end !#
moved to parse_f95.rb #
# File code_objects.rb, line 639 639: def TopLevel.find_class_named(name) 640: @@all_classes.each_value do |c| 641: res = c.find_class_named(name) 642: return res if res 643: end 644: nil 645: end
# File parsers/parse_f95.rb, line 572 572: def initialize(file_name) 573: super() 574: @name = "TopLevel" 575: @file_relative_name = file_name 576: @file_absolute_name = file_name 577: @file_stat = File.stat(file_name) 578: @diagram = nil 579: @@all_files[file_name] = self 580: end
# File code_objects.rb, line 583 583: def initialize(file_name) 584: super() 585: @name = "TopLevel" 586: @file_relative_name = file_name 587: @file_absolute_name = file_name 588: @file_stat = File.stat(file_name) 589: @diagram = nil 590: #!# @@all_files[file_name] = self 591: end
# File parsers/parse_f95.rb, line 566 566: def TopLevel::reset 567: @@all_classes = {} 568: @@all_modules = {} 569: @@all_files = {} 570: 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 603 603: def add_class_or_module(collection, class_type, name, superclass) 604: cls = collection[name] 605: if cls 606: puts "Reusing class/module #{name}" if $DEBUG 607: else 608: if class_type == NormalModule 609: all = @@all_modules 610: else 611: all = @@all_classes 612: end 613: cls = all[name] 614: if !cls 615: cls = class_type.new(name, superclass) 616: all[name] = cls unless @done_documenting 617: end 618: puts "Adding class/module #{name} to #@name" if $DEBUG 619: collection[name] = cls unless @done_documenting 620: cls.parent = self 621: end 622: cls 623: end
# File parsers/parse_f95.rb, line 590 590: def find_class_or_module_named(symbol, ignore_case=nil) 591: if !ignore_case 592: @@all_classes.each_value {|c| return c if c.name == symbol} 593: @@all_modules.each_value {|m| return m if m.name == symbol} 594: else 595: @@all_classes.each_value {|c| return c if c.name.upcase == symbol.upcase} 596: @@all_modules.each_value {|m| return m if m.name.upcase == symbol.upcase} 597: end 598: nil 599: end
Find a named file
# File parsers/parse_f95.rb, line 607 607: def find_file_named(name, method=nil, ignore_case=nil) 608: return nil unless name 609: result = nil 610: @@all_files.each{|file_name, toplevel| 611: result = toplevel if file_name == name 612: } 613: dir = File.dirname(@file_relative_name) 614: @@all_files.each{|file_name, toplevel| 615: if /^#{dir}\/(.*)/ =~ file_name 616: result = toplevel if $1 == name 617: end 618: } 619: if result 620: if method 621: result_method = result.find_local_symbol(method, ignore_case) 622: return result_method 623: else 624: return result 625: end 626: else 627: return nil 628: end 629: end
# File parsers/parse_f95.rb, line 586 586: def find_local_symbol(symbol, ignore_case=nil) 587: find_class_or_module_named(symbol, ignore_case) || super 588: end