Class: Wardite::Instance
- Inherits:
-
Object
- Object
- Wardite::Instance
- Defined in:
- lib/wardite.rb
Instance Attribute Summary collapse
-
#exports ⇒ Object
: Exports.
-
#import_object ⇒ Object
readonly
: Hash[Symbol, Hash[Symbol, Proc]].
-
#runtime ⇒ Object
: Runtime.
-
#sections ⇒ Object
: Array.
-
#store ⇒ Object
: Store.
-
#version ⇒ Object
: Integer.
Instance Method Summary collapse
- #code_section ⇒ Object
- #data_section ⇒ Object
- #export_section ⇒ Object
- #function_section ⇒ Object
- #import_section ⇒ Object
-
#initialize(import_object, &blk) ⇒ Instance
constructor
A new instance of Instance.
- #memory_section ⇒ Object
- #type_section ⇒ Object
Constructor Details
#initialize(import_object, &blk) ⇒ Instance
Returns a new instance of Instance.
631 632 633 634 635 636 637 638 |
# File 'lib/wardite.rb', line 631 def initialize(import_object, &blk) blk.call(self) @import_object = import_object @store = Store.new(self) @exports = Exports.new(self.export_section, store) @runtime = Runtime.new(self) end |
Instance Attribute Details
#exports ⇒ Object
: Exports
625 626 627 |
# File 'lib/wardite.rb', line 625 def exports @exports end |
#import_object ⇒ Object (readonly)
: Hash[Symbol, Hash[Symbol, Proc]]
627 628 629 |
# File 'lib/wardite.rb', line 627 def import_object @import_object end |
#runtime ⇒ Object
: Runtime
621 622 623 |
# File 'lib/wardite.rb', line 621 def runtime @runtime end |
#store ⇒ Object
: Store
623 624 625 |
# File 'lib/wardite.rb', line 623 def store @store end |
#version ⇒ Object
: Integer
617 618 619 |
# File 'lib/wardite.rb', line 617 def version @version end |
Instance Method Details
#code_section ⇒ Object
699 700 701 702 703 704 705 706 707 708 |
# File 'lib/wardite.rb', line 699 def code_section sec = @sections.find{|s| s.code == Const::SectionCode } if !sec return nil end if !sec.is_a?(CodeSection) raise(GenericError, "instance doesn't have required section") end sec end |
#data_section ⇒ Object
675 676 677 678 679 680 681 682 683 684 |
# File 'lib/wardite.rb', line 675 def data_section sec = @sections.find{|s| s.code == Const::SectionData } if !sec return nil end if !sec.is_a?(DataSection) raise(GenericError, "[BUG] found invalid data section") end sec end |
#export_section ⇒ Object
711 712 713 714 715 716 717 718 719 720 |
# File 'lib/wardite.rb', line 711 def export_section sec = @sections.find{|s| s.code == Const::SectionExport } if !sec return ExportSection.new end if !sec.is_a?(ExportSection) raise(GenericError, "instance doesn't have required section") end sec end |
#function_section ⇒ Object
687 688 689 690 691 692 693 694 695 696 |
# File 'lib/wardite.rb', line 687 def function_section sec = @sections.find{|s| s.code == Const::SectionFunction } if !sec return nil end if !sec.is_a?(FunctionSection) raise(GenericError, "instance doesn't have required section") end sec end |
#import_section ⇒ Object
641 642 643 644 645 646 647 648 |
# File 'lib/wardite.rb', line 641 def import_section sec = @sections.find{|s| s.code == Const::SectionImport } if !sec.is_a?(ImportSection) # returns dummy empty section return ImportSection.new end sec end |
#memory_section ⇒ Object
663 664 665 666 667 668 669 670 671 672 |
# File 'lib/wardite.rb', line 663 def memory_section sec = @sections.find{|s| s.code == Const::SectionMemory } if !sec return nil end if !sec.is_a?(MemorySection) raise(GenericError, "[BUG] found invalid memory section") end sec end |
#type_section ⇒ Object
651 652 653 654 655 656 657 658 659 660 |
# File 'lib/wardite.rb', line 651 def type_section sec = @sections.find{|s| s.code == Wardite::Const::SectionType } if !sec return nil end if !sec.is_a?(TypeSection) raise(GenericError, "instance doesn't have required section") end sec end |