Class: Crokus::BasicBlock
- Inherits:
-
Object
- Object
- Crokus::BasicBlock
- Defined in:
- lib/crokus/cfg.rb
Constant Summary collapse
- @@id =
-1
Instance Attribute Summary collapse
-
#id ⇒ Object
(also: #label)
Returns the value of attribute id.
-
#infos ⇒ Object
Returns the value of attribute infos.
-
#stmts ⇒ Object
Returns the value of attribute stmts.
-
#succs ⇒ Object
Returns the value of attribute succs.
Instance Method Summary collapse
- #<<(e) ⇒ Object
- #code4dot ⇒ Object
- #falseBranch ⇒ Object
-
#initialize(infos = {}) ⇒ BasicBlock
constructor
A new instance of BasicBlock.
- #nextBranch ⇒ Object
- #size ⇒ Object
- #to(bb) ⇒ Object
- #trueBranch ⇒ Object
Constructor Details
#initialize(infos = {}) ⇒ BasicBlock
Returns a new instance of BasicBlock.
50 51 52 53 54 55 56 |
# File 'lib/crokus/cfg.rb', line 50 def initialize infos={} @@id+=1 @id="L"+@@id.to_s @stmts=[] @succs=[] @infos=infos end |
Instance Attribute Details
#id ⇒ Object Also known as: label
Returns the value of attribute id.
46 47 48 |
# File 'lib/crokus/cfg.rb', line 46 def id @id end |
#infos ⇒ Object
Returns the value of attribute infos.
47 48 49 |
# File 'lib/crokus/cfg.rb', line 47 def infos @infos end |
#stmts ⇒ Object
Returns the value of attribute stmts.
46 47 48 |
# File 'lib/crokus/cfg.rb', line 46 def stmts @stmts end |
#succs ⇒ Object
Returns the value of attribute succs.
46 47 48 |
# File 'lib/crokus/cfg.rb', line 46 def succs @succs end |
Instance Method Details
#<<(e) ⇒ Object
58 59 60 |
# File 'lib/crokus/cfg.rb', line 58 def <<(e) @stmts << e end |
#code4dot ⇒ Object
80 81 82 83 |
# File 'lib/crokus/cfg.rb', line 80 def code4dot @ppr||=PrettyPrinter.new @stmts.compact.collect{|stmt| stmt.accept(@ppr)}.join("\n") end |
#falseBranch ⇒ Object
73 74 75 76 77 78 |
# File 'lib/crokus/cfg.rb', line 73 def falseBranch unless @succs.size==2 raise "request for falseBranch failed because #{@succs.size} branch(es) found. Strange." end return @succs.last end |
#nextBranch ⇒ Object
85 86 87 |
# File 'lib/crokus/cfg.rb', line 85 def nextBranch @succs.first end |
#size ⇒ Object
89 90 91 |
# File 'lib/crokus/cfg.rb', line 89 def size @stmts.size end |
#to(bb) ⇒ Object
62 63 64 |
# File 'lib/crokus/cfg.rb', line 62 def to bb @succs << bb end |
#trueBranch ⇒ Object
66 67 68 69 70 71 |
# File 'lib/crokus/cfg.rb', line 66 def trueBranch unless @succs.size==2 raise "request for trueBranch failed because #{@succs.size} branch(es) found. Strange." end return @succs.first end |