Class: Furnace::CFG::Node
- Inherits:
-
Object
- Object
- Furnace::CFG::Node
- Defined in:
- lib/furnace/cfg/node.rb
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
Returns the value of attribute cfg.
-
#control_transfer_instruction ⇒ Object
(also: #cti)
Returns the value of attribute control_transfer_instruction.
-
#exception_label ⇒ Object
Returns the value of attribute exception_label.
-
#instructions ⇒ Object
(also: #insns)
Returns the value of attribute instructions.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#target_labels ⇒ Object
Returns the value of attribute target_labels.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #exception ⇒ Object
- #exception_source_labels ⇒ Object
- #exception_sources ⇒ Object
- #exits? ⇒ Boolean
-
#initialize(cfg, label = nil, insns = [], cti = nil, target_labels = [], exception_label = nil, metadata = {}) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #source_labels ⇒ Object
- #sources ⇒ Object
- #targets ⇒ Object
Constructor Details
#initialize(cfg, label = nil, insns = [], cti = nil, target_labels = [], exception_label = nil, metadata = {}) ⇒ Node
Returns a new instance of Node.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/furnace/cfg/node.rb', line 15 def initialize(cfg, label=nil, insns=[], cti=nil, target_labels=[], exception_label=nil, ={}) @cfg, @label = cfg, label @metadata = @instructions = insns @control_transfer_instruction = cti @target_labels = target_labels @exception_label = exception_label end |
Instance Attribute Details
#cfg ⇒ Object (readonly)
Returns the value of attribute cfg.
3 4 5 |
# File 'lib/furnace/cfg/node.rb', line 3 def cfg @cfg end |
#control_transfer_instruction ⇒ Object Also known as: cti
Returns the value of attribute control_transfer_instruction.
6 7 8 |
# File 'lib/furnace/cfg/node.rb', line 6 def control_transfer_instruction @control_transfer_instruction end |
#exception_label ⇒ Object
Returns the value of attribute exception_label.
5 6 7 |
# File 'lib/furnace/cfg/node.rb', line 5 def exception_label @exception_label end |
#instructions ⇒ Object Also known as: insns
Returns the value of attribute instructions.
6 7 8 |
# File 'lib/furnace/cfg/node.rb', line 6 def instructions @instructions end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/furnace/cfg/node.rb', line 3 def label @label end |
#metadata ⇒ Object
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/furnace/cfg/node.rb', line 8 def @metadata end |
#target_labels ⇒ Object
Returns the value of attribute target_labels.
5 6 7 |
# File 'lib/furnace/cfg/node.rb', line 5 def target_labels @target_labels end |
Instance Method Details
#==(other) ⇒ Object
62 63 64 |
# File 'lib/furnace/cfg/node.rb', line 62 def ==(other) other.is_a?(Node) && self.label == other.label end |
#exception ⇒ Object
46 47 48 |
# File 'lib/furnace/cfg/node.rb', line 46 def exception @cfg.find_node @exception_label if @exception_label end |
#exception_source_labels ⇒ Object
50 51 52 |
# File 'lib/furnace/cfg/node.rb', line 50 def exception_source_labels exception_sources.map &:label end |
#exception_sources ⇒ Object
54 55 56 |
# File 'lib/furnace/cfg/node.rb', line 54 def exception_sources @cfg.sources_for(self, true) end |
#exits? ⇒ Boolean
58 59 60 |
# File 'lib/furnace/cfg/node.rb', line 58 def exits? targets == [@cfg.exit] end |
#inspect ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/furnace/cfg/node.rb', line 66 def inspect if @label && @instructions "<#{@label}:#{@instructions.join ", "}>" elsif @label "<#{@label}>" elsif @instructions "<!unlabeled:#{@instructions.join ", "}>" else "<!exit#{}>" end end |
#source_labels ⇒ Object
38 39 40 |
# File 'lib/furnace/cfg/node.rb', line 38 def source_labels sources.map &:label end |
#sources ⇒ Object
42 43 44 |
# File 'lib/furnace/cfg/node.rb', line 42 def sources @cfg.sources_for(self) end |
#targets ⇒ Object
32 33 34 35 36 |
# File 'lib/furnace/cfg/node.rb', line 32 def targets @target_labels.map do |label| @cfg.find_node label end.freeze end |