Class: RMasm::Section
- Includes:
- DirectiveContainer
- Defined in:
- lib/rmasm/section.rb
Constant Summary collapse
- CODE_CORE =
1
- DATA_CORE =
2
- BSS =
4
- READABLE =
8
- WRITABLE =
16
- EXECUTABLE =
32
- VALID_SECTION =
[:CODE_CORE,:DATA_CORE,:BSS,:READABLE,:WRITABLE,:EXECUTABLE]
- CODE =
CODE_CORE | READABLE | EXECUTABLE
- DATA =
DATA_CORE | READABLE | WRITABLE
- DATA_READONLY =
DATA_CORE | READABLE
- @@section_currently_defined =
0
Instance Attribute Summary collapse
-
#directive_list ⇒ Object
readonly
Returns the value of attribute directive_list.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Directive
Class Method Summary collapse
- .define(*args, &block) ⇒ Object
-
.end(*args) ⇒ Object
Close the current section.
Instance Method Summary collapse
- #accept(directive) ⇒ Object
- #add_directive(directive) ⇒ Object
- #container_block_begin ⇒ Object
- #container_block_end ⇒ Object
-
#initialize(name) ⇒ Section
constructor
A new instance of Section.
- #to_s ⇒ Object
Methods included from DirectiveContainer
#<<, #add_directive_core, #init_container, #parent, #parent=
Methods inherited from Directive
Constructor Details
#initialize(name) ⇒ Section
Returns a new instance of Section.
57 58 59 60 61 62 |
# File 'lib/rmasm/section.rb', line 57 def initialize(name) super :section @name = name @directive_list = [] init_container end |
Instance Attribute Details
#directive_list ⇒ Object (readonly)
Returns the value of attribute directive_list.
40 41 42 |
# File 'lib/rmasm/section.rb', line 40 def directive_list @directive_list end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/rmasm/section.rb', line 40 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
40 41 42 |
# File 'lib/rmasm/section.rb', line 40 def type @type end |
Class Method Details
.define(*args, &block) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/rmasm/section.rb', line 111 def self.define(*args, &block) # todo check arg length sym = args[0] if ! sym.is_a?(Symbol) return Report.error(:R00E1, sym) end # Call the block structure definition with the new structure new_section = $rmasm.sections.get_or_set( Section.new(sym) ) # Send the section directive to the assembler with the block (if any) $rmasm << [new_section,block] # return this section new_section end |
.end(*args) ⇒ Object
Close the current section
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rmasm/section.rb', line 90 def self.end(*args) # No args expected, else log error if !args.empty? return Report.error(:R0013, args.length, "none", "section.end") end # Cannot close a section being evaluated inside do...end (This would lead to unexpected section declaration) if @@section_currently_defined > 0 return Report.error(:R00F1, $rmasm.context.name) end # Check if the current context is a section, otherwise log an error if ! $rmasm.context.is_a?(Section) return Report.error(:R00G1) end # If ok, then replace the current context with the parent context $rmasm.context = $rmasm.context.parent true end |
Instance Method Details
#accept(directive) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rmasm/section.rb', line 64 def accept(directive) # A section accept any directive except Section and Align case directive.id when :section :process when :struct :parent else :accept end end |
#add_directive(directive) ⇒ Object
85 86 87 |
# File 'lib/rmasm/section.rb', line 85 def add_directive(directive) @directive_list << directive end |
#container_block_begin ⇒ Object
76 77 78 |
# File 'lib/rmasm/section.rb', line 76 def container_block_begin() @@section_currently_defined += 1 end |
#container_block_end ⇒ Object
80 81 82 |
# File 'lib/rmasm/section.rb', line 80 def container_block_end() @@section_currently_defined -= 1 end |
#to_s ⇒ Object
129 130 131 |
# File 'lib/rmasm/section.rb', line 129 def to_s() "Section #{@name}" end |