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
- #global_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.
42 43 44 45 46 47 48 49 |
# File 'lib/wardite.rb', line 42 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
36 37 38 |
# File 'lib/wardite.rb', line 36 def exports @exports end |
#import_object ⇒ Object (readonly)
: Hash[Symbol, Hash[Symbol, Proc]]
38 39 40 |
# File 'lib/wardite.rb', line 38 def import_object @import_object end |
#runtime ⇒ Object
: Runtime
32 33 34 |
# File 'lib/wardite.rb', line 32 def runtime @runtime end |
#store ⇒ Object
: Store
34 35 36 |
# File 'lib/wardite.rb', line 34 def store @store end |
#version ⇒ Object
: Integer
28 29 30 |
# File 'lib/wardite.rb', line 28 def version @version end |
Instance Method Details
#code_section ⇒ Object
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/wardite.rb', line 122 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
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/wardite.rb', line 98 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
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/wardite.rb', line 134 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
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/wardite.rb', line 110 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 |
#global_section ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/wardite.rb', line 86 def global_section sec = @sections.find{|s| s.code == Const::SectionGlobal } if !sec return nil end if !sec.is_a?(GlobalSection) raise(GenericError, "instance doesn't have required section") end sec end |
#import_section ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/wardite.rb', line 52 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
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/wardite.rb', line 74 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
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wardite.rb', line 62 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 |